diff --git a/.chronus/changes/switch_to_rest-2024-4-30-12-59-16.md b/.chronus/changes/switch_to_rest-2024-4-30-12-59-16.md deleted file mode 100644 index 0368c675010..00000000000 --- a/.chronus/changes/switch_to_rest-2024-4-30-12-59-16.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@autorest/python" ---- - -remove support for deprecated azure.core.pipeline.transport requests and responses \ No newline at end of file diff --git a/packages/autorest.python/autorest/codegen/models/client.py b/packages/autorest.python/autorest/codegen/models/client.py index 953ad7d63d8..3d880e32852 100644 --- a/packages/autorest.python/autorest/codegen/models/client.py +++ b/packages/autorest.python/autorest/codegen/models/client.py @@ -253,6 +253,18 @@ def link_lro_initial_operations(self) -> None: if isinstance(operation, (LROOperation, LROPagingOperation)): operation.initial_operation = self.lookup_operation(id(operation.yaml_data["initialOperation"])) + @property + def need_request_converter(self) -> bool: + """ + Whether we need to convert our created azure.core.rest.HttpRequest to + azure.core.pipeline.transport.HttpRequest + """ + return ( + self.code_model.options["show_operations"] + and bool(self.request_builders) + and not self.code_model.options["version_tolerant"] + ) + @property def has_abstract_operations(self) -> bool: """Whether there is abstract operation in any operation group.""" diff --git a/packages/autorest.python/autorest/codegen/models/code_model.py b/packages/autorest.python/autorest/codegen/models/code_model.py index c94ec77c2b7..ab3c41f4ac6 100644 --- a/packages/autorest.python/autorest/codegen/models/code_model.py +++ b/packages/autorest.python/autorest/codegen/models/code_model.py @@ -120,7 +120,11 @@ def need_vendored_code(self, async_mode: bool) -> bool: return True if async_mode: return self.need_mixin_abc - return self.need_mixin_abc or self.has_etag or self.has_form_data + return self.need_request_converter or self.need_mixin_abc or self.has_etag or self.has_form_data + + @property + def need_request_converter(self) -> bool: + return any(c for c in self.clients if c.need_request_converter) @property def need_mixin_abc(self) -> bool: diff --git a/packages/autorest.python/autorest/codegen/models/operation.py b/packages/autorest.python/autorest/codegen/models/operation.py index c121649ca88..09136058537 100644 --- a/packages/autorest.python/autorest/codegen/models/operation.py +++ b/packages/autorest.python/autorest/codegen/models/operation.py @@ -366,6 +366,8 @@ def imports( # pylint: disable=too-many-branches, disable=too-many-statements file_import.add_import("warnings", ImportType.STDLIB) relative_path = "..." if async_mode else ".." + if self.code_model.need_request_converter: + file_import.add_submodule_import(f"{relative_path}_vendor", "_convert_request", ImportType.LOCAL) if self.has_etag: file_import.add_submodule_import( "exceptions", @@ -375,18 +377,32 @@ def imports( # pylint: disable=too-many-branches, disable=too-many-statements if not async_mode: file_import.add_submodule_import(f"{relative_path}_vendor", "prep_if_match", ImportType.LOCAL) file_import.add_submodule_import(f"{relative_path}_vendor", "prep_if_none_match", ImportType.LOCAL) - if async_mode: - file_import.add_submodule_import( - "rest", - "AsyncHttpResponse", - ImportType.SDKCORE, - ) + if self.code_model.need_request_converter: + if async_mode: + file_import.add_submodule_import( + "azure.core.pipeline.transport", + "AsyncHttpResponse", + ImportType.SDKCORE, + ) + else: + file_import.add_submodule_import( + "azure.core.pipeline.transport", + "HttpResponse", + ImportType.SDKCORE, + ) else: - file_import.add_submodule_import( - "rest", - "HttpResponse", - ImportType.SDKCORE, - ) + if async_mode: + file_import.add_submodule_import( + "rest", + "AsyncHttpResponse", + ImportType.SDKCORE, + ) + else: + file_import.add_submodule_import( + "rest", + "HttpResponse", + ImportType.SDKCORE, + ) if self.code_model.options["builders_visibility"] == "embedded" and not async_mode: file_import.merge(self.request_builder.imports()) file_import.add_submodule_import( diff --git a/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py b/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py index ea292d0aea2..42df4ae0ff9 100644 --- a/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py +++ b/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py @@ -846,6 +846,11 @@ def _create_request_builder_call( def _postprocess_http_request(self, builder: OperationType, template_url: Optional[str] = None) -> List[str]: retval: List[str] = [] + if not self.code_model.options["version_tolerant"]: + pass_files = "" + if builder.parameters.has_body and builder.parameters.body_parameter.client_name == "files": + pass_files = ", _files" + retval.append(f"_request = _convert_request(_request{pass_files})") if builder.parameters.path: retval.extend(self.serialize_path(builder)) url_to_format = "_request.url" @@ -964,12 +969,13 @@ def response_headers_and_deserialization( def handle_error_response(self, builder: OperationType) -> List[str]: async_await = "await " if self.async_mode else "" retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"] - retval.extend( - [ - " if _stream:", - f" {async_await} response.read() # Load the body in memory and close the socket", - ] - ) + if not self.code_model.need_request_converter: + retval.extend( + [ + " if _stream:", + f" {async_await} response.read() # Load the body in memory and close the socket", + ] + ) type_ignore = " # type: ignore" if _need_type_ignore(builder) else "" retval.append( f" map_error(status_code=response.status_code, response=response, error_map=error_map){type_ignore}" diff --git a/packages/autorest.python/autorest/codegen/serializers/general_serializer.py b/packages/autorest.python/autorest/codegen/serializers/general_serializer.py index b3b0877da3c..f70f00a38f0 100644 --- a/packages/autorest.python/autorest/codegen/serializers/general_serializer.py +++ b/packages/autorest.python/autorest/codegen/serializers/general_serializer.py @@ -87,6 +87,13 @@ def serialize_vendor_file(self, clients: List[Client]) -> str: # configure imports file_import = FileImport(self.code_model) + if self.code_model.need_request_converter: + file_import.add_submodule_import( + "azure.core.pipeline.transport", + "HttpRequest", + ImportType.SDKCORE, + ) + if self.code_model.need_mixin_abc: file_import.add_submodule_import( "abc", diff --git a/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 b/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 index bc15b14dd56..5e790a5697a 100644 --- a/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 +++ b/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 @@ -3,6 +3,14 @@ {{ imports }} +{% if code_model.need_request_converter and not async_mode %} +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request +{% endif %} {% if code_model.need_mixin_abc %} {% for client in clients | selectattr("has_mixin") %} {% set pylint_disable = "# pylint: disable=name-too-long" if (client.name | length) + ("MixinABC" | length) > 40 else "" %} diff --git a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_vendor.py b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py index 1ee6aaec91d..ee0912a5af5 100644 --- a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py index 2649d7f9ba4..8d073da10e7 100644 --- a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py +++ b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py index 1a8e5f2ceae..4be9f4faa37 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -90,6 +92,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -144,6 +145,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -291,6 +291,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,8 +302,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -361,6 +360,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -376,6 +376,7 @@ 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 @@ -397,8 +398,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -477,6 +476,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,8 +487,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py index 18e160f50f7..690f2856ffb 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -82,6 +84,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,8 +95,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py index cdaa5e61d23..f8c3e856901 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,6 +169,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -222,6 +222,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +233,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -436,6 +434,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,6 +450,7 @@ 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 @@ -472,8 +472,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -552,6 +550,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -562,8 +561,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py index e27867bf6fd..9a1698f1e80 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py index b6b6ea30af5..5a0be7edf6a 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -77,6 +79,7 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -137,6 +138,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,8 +149,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py index 52ad664194c..60a12c78568 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -185,6 +186,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +197,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py index 2dca79cc775..4319a9592b6 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -87,6 +89,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py index 0ff32041779..c5eb192672d 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,6 +127,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py index b7ab5ba85fe..966f69141c4 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -229,6 +229,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py index 62dcf13cde0..b6b3ebd461a 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +109,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +120,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_vendor.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_vendor.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py index 1864cba2ae2..3607f228970 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,13 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -76,6 +78,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -91,6 +94,7 @@ 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 @@ -112,8 +116,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -165,6 +167,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +178,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py index e65dc20427f..3c1c3e5b565 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -90,6 +92,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,6 +108,7 @@ 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 @@ -126,8 +130,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -218,6 +220,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -228,8 +231,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py index c6a8b9c2a2c..ffaf7a29d00 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -136,6 +138,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +149,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -182,6 +183,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +194,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py index 0e78b6b6062..573fcbb01a2 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py @@ -20,14 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,6 +120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -134,6 +136,7 @@ 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 @@ -155,8 +158,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py index e1449550c17..6be2c244390 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,6 +142,7 @@ 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 @@ -161,8 +164,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -253,6 +254,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,8 +265,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py index 4752c605c6b..dc2e7f1a577 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,6 +181,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +192,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -226,6 +226,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +237,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py index 62d89fee002..5a6fdc953fd 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._duration_operations import ( build_get_invalid_request, build_get_null_request, @@ -83,6 +85,7 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -93,8 +96,6 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -140,6 +141,7 @@ async def put_positive_duration( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +152,6 @@ async def put_positive_duration( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +184,7 @@ async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +195,6 @@ async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -232,6 +231,7 @@ async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -242,8 +242,6 @@ async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py index 5888447d655..97fec1d0745 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -140,6 +142,7 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +153,6 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +198,7 @@ def put_positive_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +209,6 @@ def put_positive_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -241,6 +241,7 @@ def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -251,8 +252,6 @@ def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -289,6 +288,7 @@ def get_invalid(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +299,6 @@ def get_invalid(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py index e450414482d..db72dc2daf6 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._parameter_grouping_operations import ( build_group_with_constant_request, build_post_multi_param_groups_request, @@ -108,6 +110,7 @@ async def post_required( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +121,6 @@ async def post_required( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -167,6 +168,7 @@ async def post_optional( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ async def post_optional( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -229,6 +229,7 @@ async def post_reserved_words( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ async def post_reserved_words( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -301,6 +300,7 @@ async def post_multi_param_groups( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,8 +311,6 @@ async def post_multi_param_groups( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -357,6 +355,7 @@ async def post_shared_parameter_group_object( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -367,8 +366,6 @@ async def post_shared_parameter_group_object( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -414,6 +411,7 @@ async def group_with_constant( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -424,8 +422,6 @@ async def group_with_constant( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py index d1d5dd07afa..7fdc047cb9f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -254,6 +256,7 @@ def post_required( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,8 +267,6 @@ def post_required( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -313,6 +314,7 @@ def post_optional( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -323,8 +325,6 @@ def post_optional( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -375,6 +375,7 @@ def post_reserved_words( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -385,8 +386,6 @@ def post_reserved_words( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -447,6 +446,7 @@ def post_multi_param_groups( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -457,8 +457,6 @@ def post_multi_param_groups( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -503,6 +501,7 @@ def post_shared_parameter_group_object( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -513,8 +512,6 @@ def post_shared_parameter_group_object( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -560,6 +557,7 @@ def group_with_constant( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -570,8 +568,6 @@ def group_with_constant( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_vendor.py index f2b160bbc2a..8a8317945dd 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestReportServiceForAzureConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutoRestReportServiceForAzureMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_vendor.py index cff94c45790..53160cab8e8 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestReportServiceForAzureConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py index d81c000f4db..328832f5291 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._auto_rest_report_service_for_azure_operations import build_get_report_request from .._vendor import AutoRestReportServiceForAzureMixinABC @@ -67,6 +69,7 @@ async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -77,8 +80,6 @@ async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py index 8b892cd76ce..e230c78f039 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import AutoRestReportServiceForAzureMixinABC +from .._vendor import AutoRestReportServiceForAzureMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -90,6 +91,7 @@ def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +102,6 @@ def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py index 518a503d154..a0d06bbb4af 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._api_version_default_operations import ( build_get_method_global_not_provided_valid_request, build_get_method_global_valid_request, @@ -85,6 +87,7 @@ async def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -133,6 +134,7 @@ async def get_method_global_not_provided_valid( # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -143,8 +145,6 @@ async def get_method_global_not_provided_valid( # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -179,6 +179,7 @@ async def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +190,6 @@ async def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -225,6 +224,7 @@ async def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -235,8 +235,6 @@ async def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py index 868d2bf5115..986313069c4 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._api_version_local_operations import ( build_get_method_local_null_request, build_get_method_local_valid_request, @@ -85,6 +87,7 @@ async def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -135,6 +136,7 @@ async def get_method_local_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +147,6 @@ async def get_method_local_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -181,6 +181,7 @@ async def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,8 +192,6 @@ async def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -227,6 +226,7 @@ async def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -237,8 +237,6 @@ async def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py index 90984ec1f6b..999f39840b4 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._header_operations import ( build_custom_named_request_id_head_request, build_custom_named_request_id_param_grouping_request, @@ -86,6 +88,7 @@ async def custom_named_request_id( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def custom_named_request_id( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -146,6 +147,7 @@ async def custom_named_request_id_param_grouping( # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -156,8 +158,6 @@ async def custom_named_request_id_param_grouping( # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -196,6 +196,7 @@ async def custom_named_request_id_head(self, foo_client_request_id: str, **kwarg headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -206,8 +207,6 @@ async def custom_named_request_id_head(self, foo_client_request_id: str, **kwarg response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py index 711a6161e54..1ba19532d36 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._odata_operations import build_get_with_filter_request if sys.version_info >= (3, 9): @@ -89,6 +91,7 @@ async def get_with_filter( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,8 +102,6 @@ async def get_with_filter( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py index 583b0c8509a..0e7e7aaa732 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._skip_url_encoding_operations import ( build_get_method_path_valid_request, build_get_method_query_null_request, @@ -91,6 +93,7 @@ async def get_method_path_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -101,8 +104,6 @@ async def get_method_path_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -140,6 +141,7 @@ async def get_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +152,6 @@ async def get_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ async def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ async def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -235,6 +234,7 @@ async def get_method_query_valid( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -245,8 +245,6 @@ async def get_method_query_valid( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -284,6 +282,7 @@ async def get_method_query_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -294,8 +293,6 @@ async def get_method_query_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -333,6 +330,7 @@ async def get_path_query_valid( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -343,8 +341,6 @@ async def get_path_query_valid( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -379,6 +375,7 @@ async def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -389,8 +386,6 @@ async def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py index 387548354b0..218d4209d13 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._subscription_in_credentials_operations import ( build_post_method_global_not_provided_valid_request, build_post_method_global_null_request, @@ -86,6 +88,7 @@ async def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -132,6 +133,7 @@ async def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -142,8 +144,6 @@ async def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -182,6 +182,7 @@ async def post_method_global_not_provided_valid( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +193,6 @@ async def post_method_global_not_provided_valid( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -228,6 +227,7 @@ async def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +238,6 @@ async def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -274,6 +272,7 @@ async def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -284,8 +283,6 @@ async def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py index f43a5388797..362238e6721 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._subscription_in_method_operations import ( build_post_method_local_null_request, build_post_method_local_valid_request, @@ -89,6 +91,7 @@ async def post_method_local_valid( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,8 +102,6 @@ async def post_method_local_valid( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -140,6 +141,7 @@ async def post_method_local_null( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +152,6 @@ async def post_method_local_null( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -191,6 +191,7 @@ async def post_path_local_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -201,8 +202,6 @@ async def post_path_local_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -242,6 +241,7 @@ async def post_swagger_local_valid( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -252,8 +252,6 @@ async def post_swagger_local_valid( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py index a1004ee5e0e..949fd5feee5 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._xms_client_request_id_operations import build_get_request, build_param_get_request if sys.version_info >= (3, 9): @@ -78,6 +80,7 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -88,8 +91,6 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -128,6 +129,7 @@ async def param_get( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -138,8 +140,6 @@ async def param_get( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py index aa332059637..b4d6d1b7813 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -161,6 +163,7 @@ def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -171,8 +174,6 @@ def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -209,6 +210,7 @@ def get_method_global_not_provided_valid( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,8 +221,6 @@ def get_method_global_not_provided_valid( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -255,6 +255,7 @@ def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,8 +266,6 @@ def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -301,6 +300,7 @@ def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,8 +311,6 @@ def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py index 7071d39b939..cac5ebb2995 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -159,6 +161,7 @@ def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -169,8 +172,6 @@ def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -209,6 +210,7 @@ def get_method_local_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,8 +221,6 @@ def get_method_local_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -255,6 +255,7 @@ def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,8 +266,6 @@ def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -301,6 +300,7 @@ def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,8 +311,6 @@ def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py index dbf97c2a8cc..3f4da7ff52a 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -135,6 +137,7 @@ def custom_named_request_id( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ def custom_named_request_id( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -195,6 +196,7 @@ def custom_named_request_id_param_grouping( # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -205,8 +207,6 @@ def custom_named_request_id_param_grouping( # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -245,6 +245,7 @@ def custom_named_request_id_head(self, foo_client_request_id: str, **kwargs: Any headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +256,6 @@ def custom_named_request_id_head(self, foo_client_request_id: str, **kwargs: Any response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py index 40b1f802528..13a8ca41309 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -118,6 +120,7 @@ def get_with_filter( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +131,6 @@ def get_with_filter( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py index 6faf7a7a4eb..85f1ca15ff0 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -218,6 +220,7 @@ def get_method_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -228,8 +231,6 @@ def get_method_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -267,6 +268,7 @@ def get_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -277,8 +279,6 @@ def get_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -313,6 +313,7 @@ def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -323,8 +324,6 @@ def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -360,6 +359,7 @@ def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -370,8 +370,6 @@ def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -409,6 +407,7 @@ def get_method_query_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -419,8 +418,6 @@ def get_method_query_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -456,6 +453,7 @@ def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -466,8 +464,6 @@ def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -502,6 +498,7 @@ def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -512,8 +509,6 @@ def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py index 33740ae67f3..dd010c7a06a 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -199,6 +201,7 @@ def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,8 +212,6 @@ def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -245,6 +246,7 @@ def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +257,6 @@ def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -295,6 +295,7 @@ def post_method_global_not_provided_valid( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -305,8 +306,6 @@ def post_method_global_not_provided_valid( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -341,6 +340,7 @@ def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -351,8 +351,6 @@ def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -387,6 +385,7 @@ def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -397,8 +396,6 @@ def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py index 1f10df01c54..9805b798275 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -174,6 +176,7 @@ def post_method_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -184,8 +187,6 @@ def post_method_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -225,6 +226,7 @@ def post_method_local_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -235,8 +237,6 @@ def post_method_local_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -276,6 +276,7 @@ def post_path_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -286,8 +287,6 @@ def post_path_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -327,6 +326,7 @@ def post_swagger_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -337,8 +337,6 @@ def post_swagger_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py index 4c16deef6c2..21ffcb7dd60 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +106,7 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +117,6 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -154,6 +155,7 @@ def param_get( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -164,8 +166,6 @@ def param_get( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py index 7fed59ce996..9bc8bf896e1 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._paths_operations import build_get_empty_request if sys.version_info >= (3, 9): @@ -80,6 +82,7 @@ async def get_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -94,8 +97,6 @@ async def get_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py index 28f8d219ce4..470325040a6 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -96,6 +98,7 @@ def get_empty(self, account_name: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -110,8 +113,6 @@ def get_empty(self, account_name: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py index 9caa65cd62a..0e84264ad4f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py @@ -22,8 +22,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest +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 @@ -31,6 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._paging_operations import ( build_append_api_version_request, build_duplicate_params_request, @@ -115,6 +117,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -130,6 +133,7 @@ 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 @@ -151,8 +155,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -188,6 +190,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -203,6 +206,7 @@ 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 @@ -224,8 +228,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -261,6 +263,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -276,6 +279,7 @@ 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 @@ -297,8 +301,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -334,6 +336,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -349,6 +352,7 @@ 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 @@ -370,8 +374,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -416,6 +418,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -431,6 +434,7 @@ 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 @@ -452,8 +456,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -490,6 +492,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -505,6 +508,7 @@ 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 @@ -526,8 +530,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -581,6 +583,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -596,6 +599,7 @@ 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 @@ -617,8 +621,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -661,6 +663,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -670,6 +673,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -691,8 +695,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -733,6 +735,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -748,6 +751,7 @@ 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 @@ -769,8 +773,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -812,6 +814,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -827,6 +830,7 @@ 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 @@ -848,8 +852,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -903,6 +905,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -918,6 +921,7 @@ 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 @@ -939,8 +943,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -997,6 +999,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1012,6 +1015,7 @@ 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 @@ -1033,8 +1037,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1071,6 +1073,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1086,6 +1089,7 @@ 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 @@ -1107,8 +1111,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1145,6 +1147,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1160,6 +1163,7 @@ 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 @@ -1181,8 +1185,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1218,6 +1220,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1233,6 +1236,7 @@ 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 @@ -1254,8 +1258,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1291,6 +1293,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1306,6 +1309,7 @@ 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 @@ -1327,8 +1331,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1364,6 +1366,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1379,6 +1382,7 @@ 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 @@ -1400,8 +1404,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1445,6 +1447,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1456,6 +1459,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1477,8 +1481,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1525,6 +1527,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1541,6 +1544,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1562,8 +1566,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1603,6 +1605,7 @@ async def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1613,8 +1616,6 @@ async def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1674,6 +1675,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1689,6 +1691,7 @@ 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 @@ -1710,8 +1713,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1787,6 +1788,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1802,6 +1804,7 @@ 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 @@ -1823,8 +1826,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1863,6 +1864,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1878,6 +1880,7 @@ 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 @@ -1899,8 +1902,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1939,6 +1940,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1954,6 +1956,7 @@ 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 @@ -1975,8 +1978,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py index d2a05b90726..8d7a3989cc1 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py @@ -22,8 +22,9 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse +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 @@ -31,6 +32,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -576,6 +578,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -591,6 +594,7 @@ 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 @@ -612,8 +616,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -649,6 +651,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -664,6 +667,7 @@ 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 @@ -685,8 +689,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -722,6 +724,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -737,6 +740,7 @@ 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 @@ -758,8 +762,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -795,6 +797,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -810,6 +813,7 @@ 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 @@ -831,8 +835,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -877,6 +879,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -892,6 +895,7 @@ 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 @@ -913,8 +917,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -951,6 +953,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -966,6 +969,7 @@ 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 @@ -987,8 +991,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1042,6 +1044,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1057,6 +1060,7 @@ 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 @@ -1078,8 +1082,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1122,6 +1124,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1131,6 +1134,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1152,8 +1156,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1194,6 +1196,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1209,6 +1212,7 @@ 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 @@ -1230,8 +1234,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1271,6 +1273,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1286,6 +1289,7 @@ 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 @@ -1307,8 +1311,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1362,6 +1364,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1377,6 +1380,7 @@ 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 @@ -1398,8 +1402,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1456,6 +1458,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1471,6 +1474,7 @@ 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 @@ -1492,8 +1496,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1530,6 +1532,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1545,6 +1548,7 @@ 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 @@ -1566,8 +1570,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1604,6 +1606,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1619,6 +1622,7 @@ 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 @@ -1640,8 +1644,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1677,6 +1679,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1692,6 +1695,7 @@ 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 @@ -1713,8 +1717,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1750,6 +1752,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1765,6 +1768,7 @@ 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 @@ -1786,8 +1790,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1823,6 +1825,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1838,6 +1841,7 @@ 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 @@ -1859,8 +1863,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1904,6 +1906,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1915,6 +1918,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1936,8 +1940,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1984,6 +1986,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2000,6 +2003,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -2021,8 +2025,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2062,6 +2064,7 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2072,8 +2075,6 @@ def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2133,6 +2134,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2148,6 +2150,7 @@ 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 @@ -2169,8 +2172,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2246,6 +2247,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2261,6 +2263,7 @@ 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 @@ -2282,8 +2285,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2322,6 +2323,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2337,6 +2339,7 @@ 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 @@ -2358,8 +2361,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2398,6 +2399,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2413,6 +2415,7 @@ 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 @@ -2434,8 +2437,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py index 78c396239bc..71dae3aa12e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py @@ -19,10 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from ... import models as _models +from ..._vendor import _convert_request from ...operations._paging_operations import ( build_get_pages_partial_url_operation_next_request, build_get_pages_partial_url_operation_request, @@ -87,6 +89,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -95,6 +98,7 @@ def prepare_request(next_link=None): else: _request = HttpRequest("GET", next_link) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -120,8 +124,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -159,6 +161,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -172,6 +175,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -197,8 +201,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py index 89798aa5d59..bc025caaffa 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py @@ -19,12 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -136,6 +138,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -144,6 +147,7 @@ def prepare_request(next_link=None): else: _request = HttpRequest("GET", next_link) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -169,8 +173,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -208,6 +210,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -221,6 +224,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -246,8 +250,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py index cdc4be25b64..94925145ff3 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py index 7cb5cd048e4..98be09f4ec4 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py index 87892a4f668..46fbb451345 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._head_exception_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py index 16cd2e0d9f3..7f00fc61a4f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py index e1a6a5014b7..89fb466a342 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py index 512f3a613ed..62e1f00a3a3 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py index f8f583080f6..04b650bb614 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py @@ -19,14 +19,16 @@ 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 AsyncHttpResponse, HttpRequest +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._lr_os_custom_header_operations import ( build_post202_retry200_request, build_post_async_retry_succeeded_request, @@ -96,6 +98,7 @@ async def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -106,8 +109,6 @@ async def _put_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -267,6 +268,7 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -277,8 +279,6 @@ async def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -427,6 +427,7 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -437,8 +438,6 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -573,6 +572,7 @@ async def _post_async_retry_succeeded_initial( # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -583,8 +583,6 @@ async def _post_async_retry_succeeded_initial( # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py index fb0b5986cf2..c475f62b94e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py @@ -19,14 +19,16 @@ 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 AsyncHttpResponse, HttpRequest +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._lro_retrys_operations import ( build_delete202_retry200_request, build_delete_async_relative_retry_succeeded_request, @@ -99,6 +101,7 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -109,8 +112,6 @@ async def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -256,6 +257,7 @@ async def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -266,8 +268,6 @@ async def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -409,6 +409,7 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -419,8 +420,6 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -508,6 +507,7 @@ async def _delete202_retry200_initial( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -518,8 +518,6 @@ async def _delete202_retry200_initial( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -591,6 +589,7 @@ async def _delete_async_relative_retry_succeeded_initial( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -601,8 +600,6 @@ async def _delete_async_relative_retry_succeeded_initial( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -694,6 +691,7 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -704,8 +702,6 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -837,6 +833,7 @@ async def _post_async_relative_retry_succeeded_initial( # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -847,8 +844,6 @@ async def _post_async_relative_retry_succeeded_initial( # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py index 320a13257ea..74fbde0894b 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py @@ -19,14 +19,16 @@ 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 AsyncHttpResponse, HttpRequest +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._lros_operations import ( build_delete202_no_retry204_request, build_delete202_retry200_request, @@ -136,6 +138,7 @@ async def _put200_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +149,6 @@ async def _put200_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -288,6 +289,7 @@ async def _patch200_succeeded_ignore_headers_initial( # pylint: disable=name-to headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -298,8 +300,6 @@ async def _patch200_succeeded_ignore_headers_initial( # pylint: disable=name-to response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -449,6 +449,7 @@ async def _patch201_retry_with_async_header_initial( # pylint: disable=name-too headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -459,8 +460,6 @@ async def _patch201_retry_with_async_header_initial( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -608,6 +607,7 @@ async def _patch202_retry_with_async_and_location_header_initial( # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -618,8 +618,6 @@ async def _patch202_retry_with_async_and_location_header_initial( # pylint: dis response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -768,6 +766,7 @@ async def _put201_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -778,8 +777,6 @@ async def _put201_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -901,6 +898,7 @@ async def _post202_list_initial(self, **kwargs: Any) -> Optional[List[_models.Pr headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -911,8 +909,6 @@ async def _post202_list_initial(self, **kwargs: Any) -> Optional[List[_models.Pr response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1013,6 +1009,7 @@ async def _put200_succeeded_no_state_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1023,8 +1020,6 @@ async def _put200_succeeded_no_state_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1163,6 +1158,7 @@ async def _put202_retry200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1173,8 +1169,6 @@ async def _put202_retry200_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1316,6 +1310,7 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1326,8 +1321,6 @@ async def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1473,6 +1466,7 @@ async def _put200_updating_succeeded204_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1483,8 +1477,6 @@ async def _put200_updating_succeeded204_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1626,6 +1618,7 @@ async def _put201_creating_failed200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1636,8 +1629,6 @@ async def _put201_creating_failed200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1783,6 +1774,7 @@ async def _put200_acceptedcanceled200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1793,8 +1785,6 @@ async def _put200_acceptedcanceled200_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1936,6 +1926,7 @@ async def _put_no_header_in_retry_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1946,8 +1937,6 @@ async def _put_no_header_in_retry_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2093,6 +2082,7 @@ async def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2103,8 +2093,6 @@ async def _put_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2261,6 +2249,7 @@ async def _put_async_no_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2271,8 +2260,6 @@ async def _put_async_no_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2427,6 +2414,7 @@ async def _put_async_retry_failed_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2437,8 +2425,6 @@ async def _put_async_retry_failed_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2595,6 +2581,7 @@ async def _put_async_no_retrycanceled_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2605,8 +2592,6 @@ async def _put_async_no_retrycanceled_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2761,6 +2746,7 @@ async def _put_async_no_header_in_retry_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2771,8 +2757,6 @@ async def _put_async_no_header_in_retry_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2925,6 +2909,7 @@ async def _put_non_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2935,8 +2920,6 @@ async def _put_non_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3063,6 +3046,7 @@ async def _put_async_non_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3073,8 +3057,6 @@ async def _put_async_non_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3195,6 +3177,7 @@ async def _put_sub_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3205,8 +3188,6 @@ async def _put_sub_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3301,6 +3282,7 @@ async def _put_async_sub_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3311,8 +3293,6 @@ async def _put_async_sub_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3398,6 +3378,7 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3408,8 +3389,6 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3497,6 +3476,7 @@ async def _delete_provisioning202_deleting_failed200_initial( # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3507,8 +3487,6 @@ async def _delete_provisioning202_deleting_failed200_initial( # pylint: disable response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3596,6 +3574,7 @@ async def _delete_provisioning202_deletingcanceled200_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3606,8 +3585,6 @@ async def _delete_provisioning202_deletingcanceled200_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3695,6 +3672,7 @@ async def _delete204_succeeded_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3705,8 +3683,6 @@ async def _delete204_succeeded_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3771,6 +3747,7 @@ async def _delete202_retry200_initial(self, **kwargs: Any) -> Optional[_models.P headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3781,8 +3758,6 @@ async def _delete202_retry200_initial(self, **kwargs: Any) -> Optional[_models.P response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3864,6 +3839,7 @@ async def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional[_model headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3874,8 +3850,6 @@ async def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional[_model response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3959,6 +3933,7 @@ async def _delete_no_header_in_retry_initial( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3969,8 +3944,6 @@ async def _delete_no_header_in_retry_initial( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4042,6 +4015,7 @@ async def _delete_async_no_header_in_retry_initial( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4052,8 +4026,6 @@ async def _delete_async_no_header_in_retry_initial( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4125,6 +4097,7 @@ async def _delete_async_retry_succeeded_initial( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4135,8 +4108,6 @@ async def _delete_async_retry_succeeded_initial( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4211,6 +4182,7 @@ async def _delete_async_no_retry_succeeded_initial( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4221,8 +4193,6 @@ async def _delete_async_no_retry_succeeded_initial( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4297,6 +4267,7 @@ async def _delete_async_retry_failed_initial( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4307,8 +4278,6 @@ async def _delete_async_retry_failed_initial( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4383,6 +4352,7 @@ async def _delete_async_retrycanceled_initial( # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4393,8 +4363,6 @@ async def _delete_async_retrycanceled_initial( # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4467,6 +4435,7 @@ async def _post200_with_payload_initial(self, **kwargs: Any) -> _models.Sku: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4477,8 +4446,6 @@ async def _post200_with_payload_initial(self, **kwargs: Any) -> _models.Sku: response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4573,6 +4540,7 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4583,8 +4551,6 @@ async def _post202_retry200_initial( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4716,6 +4682,7 @@ async def _post202_no_retry204_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4726,8 +4693,6 @@ async def _post202_no_retry204_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4860,6 +4825,7 @@ async def _post_double_headers_final_location_get_initial( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4870,8 +4836,6 @@ async def _post_double_headers_final_location_get_initial( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4953,6 +4917,7 @@ async def _post_double_headers_final_azure_header_get_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4963,8 +4928,6 @@ async def _post_double_headers_final_azure_header_get_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5047,6 +5010,7 @@ async def _post_double_headers_final_azure_header_get_default_initial( # pylint headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5057,8 +5021,6 @@ async def _post_double_headers_final_azure_header_get_default_initial( # pylint response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5153,6 +5115,7 @@ async def _post_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5163,8 +5126,6 @@ async def _post_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5316,6 +5277,7 @@ async def _post_async_no_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5326,8 +5288,6 @@ async def _post_async_no_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5479,6 +5439,7 @@ async def _post_async_retry_failed_initial( # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5489,8 +5450,6 @@ async def _post_async_retry_failed_initial( # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5628,6 +5587,7 @@ async def _post_async_retrycanceled_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5638,8 +5598,6 @@ async def _post_async_retrycanceled_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py index 92e3f43293c..775cd7fd02e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py @@ -19,14 +19,16 @@ 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 AsyncHttpResponse, HttpRequest +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._lrosads_operations import ( build_delete202_non_retry400_request, build_delete202_retry_invalid_header_request, @@ -118,6 +120,7 @@ async def _put_non_retry400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +131,6 @@ async def _put_non_retry400_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -269,6 +270,7 @@ async def _put_non_retry201_creating400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,8 +281,6 @@ async def _put_non_retry201_creating400_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -423,6 +423,7 @@ async def _put_non_retry201_creating400_invalid_json_initial( # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,8 +434,6 @@ async def _put_non_retry201_creating400_invalid_json_initial( # pylint: disable response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -577,6 +576,7 @@ async def _put_async_relative_retry400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -587,8 +587,6 @@ async def _put_async_relative_retry400_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -727,6 +725,7 @@ async def _delete_non_retry400_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -737,8 +736,6 @@ async def _delete_non_retry400_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -809,6 +806,7 @@ async def _delete202_non_retry400_initial( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -819,8 +817,6 @@ async def _delete202_non_retry400_initial( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -891,6 +887,7 @@ async def _delete_async_relative_retry400_initial( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -901,8 +898,6 @@ async def _delete_async_relative_retry400_initial( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -992,6 +987,7 @@ async def _post_non_retry400_initial( # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1002,8 +998,6 @@ async def _post_non_retry400_initial( # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1132,6 +1126,7 @@ async def _post202_non_retry400_initial( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1142,8 +1137,6 @@ async def _post202_non_retry400_initial( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1272,6 +1265,7 @@ async def _post_async_relative_retry400_initial( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1282,8 +1276,6 @@ async def _post_async_relative_retry400_initial( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1418,6 +1410,7 @@ async def _put_error201_no_provisioning_state_payload_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1428,8 +1421,6 @@ async def _put_error201_no_provisioning_state_payload_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1569,6 +1560,7 @@ async def _put_async_relative_retry_no_status_initial( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1579,8 +1571,6 @@ async def _put_async_relative_retry_no_status_initial( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1737,6 +1727,7 @@ async def _put_async_relative_retry_no_status_payload_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1747,8 +1738,6 @@ async def _put_async_relative_retry_no_status_payload_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1890,6 +1879,7 @@ async def _delete204_succeeded_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1900,8 +1890,6 @@ async def _delete204_succeeded_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1968,6 +1956,7 @@ async def _delete_async_relative_retry_no_status_initial( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1978,8 +1967,6 @@ async def _delete_async_relative_retry_no_status_initial( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2071,6 +2058,7 @@ async def _post202_no_location_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2081,8 +2069,6 @@ async def _post202_no_location_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2214,6 +2200,7 @@ async def _post_async_relative_retry_no_payload_initial( # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2224,8 +2211,6 @@ async def _post_async_relative_retry_no_payload_initial( # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2363,6 +2348,7 @@ async def _put200_invalid_json_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2373,8 +2359,6 @@ async def _put200_invalid_json_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2515,6 +2499,7 @@ async def _put_async_relative_retry_invalid_header_initial( # pylint: disable=n headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2525,8 +2510,6 @@ async def _put_async_relative_retry_invalid_header_initial( # pylint: disable=n response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2683,6 +2666,7 @@ async def _put_async_relative_retry_invalid_json_polling_initial( # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2693,8 +2677,6 @@ async def _put_async_relative_retry_invalid_json_polling_initial( # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2836,6 +2818,7 @@ async def _delete202_retry_invalid_header_initial( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2846,8 +2829,6 @@ async def _delete202_retry_invalid_header_initial( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2919,6 +2900,7 @@ async def _delete_async_relative_retry_invalid_header_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2929,8 +2911,6 @@ async def _delete_async_relative_retry_invalid_header_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3007,6 +2987,7 @@ async def _delete_async_relative_retry_invalid_json_polling_initial( # pylint: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3017,8 +2998,6 @@ async def _delete_async_relative_retry_invalid_json_polling_initial( # pylint: response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3110,6 +3089,7 @@ async def _post202_retry_invalid_header_initial( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3120,8 +3100,6 @@ async def _post202_retry_invalid_header_initial( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3253,6 +3231,7 @@ async def _post_async_relative_retry_invalid_header_initial( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3263,8 +3242,6 @@ async def _post_async_relative_retry_invalid_header_initial( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3402,6 +3379,7 @@ async def _post_async_relative_retry_invalid_json_polling_initial( # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3412,8 +3390,6 @@ async def _post_async_relative_retry_invalid_json_polling_initial( # pylint: di response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py index 8add602861c..2dbe4d19c52 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py @@ -19,8 +19,9 @@ map_error, ) 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, HttpResponse +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 @@ -28,6 +29,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -162,6 +164,7 @@ def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +175,6 @@ def _put_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -330,6 +331,7 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -340,8 +342,6 @@ def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -487,6 +487,7 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -497,8 +498,6 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -633,6 +632,7 @@ def _post_async_retry_succeeded_initial( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -643,8 +643,6 @@ def _post_async_retry_succeeded_initial( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py index f21828b4c92..b859de72de2 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py @@ -19,8 +19,9 @@ map_error, ) 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, HttpResponse +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 @@ -28,6 +29,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -206,6 +208,7 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -216,8 +219,6 @@ def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -360,6 +361,7 @@ def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-too-lon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -370,8 +372,6 @@ def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-too-lon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -510,6 +510,7 @@ def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -520,8 +521,6 @@ def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -606,6 +605,7 @@ def _delete202_retry200_initial(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -616,8 +616,6 @@ def _delete202_retry200_initial(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -689,6 +687,7 @@ def _delete_async_relative_retry_succeeded_initial( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -699,8 +698,6 @@ def _delete_async_relative_retry_succeeded_initial( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -792,6 +789,7 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -802,8 +800,6 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -935,6 +931,7 @@ def _post_async_relative_retry_succeeded_initial( # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -945,8 +942,6 @@ def _post_async_relative_retry_succeeded_initial( # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py index 9c8af1a028b..7919b651f09 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py @@ -19,8 +19,9 @@ map_error, ) 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, HttpResponse +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 @@ -28,6 +29,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -803,6 +805,7 @@ def _put200_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -813,8 +816,6 @@ def _put200_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -952,6 +953,7 @@ def _patch200_succeeded_ignore_headers_initial( # pylint: disable=name-too-long headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -962,8 +964,6 @@ def _patch200_succeeded_ignore_headers_initial( # pylint: disable=name-too-long response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1110,6 +1110,7 @@ def _patch201_retry_with_async_header_initial( # pylint: disable=name-too-long headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1120,8 +1121,6 @@ def _patch201_retry_with_async_header_initial( # pylint: disable=name-too-long response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1265,6 +1264,7 @@ def _patch202_retry_with_async_and_location_header_initial( # pylint: disable=n headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1275,8 +1275,6 @@ def _patch202_retry_with_async_and_location_header_initial( # pylint: disable=n response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1422,6 +1420,7 @@ def _put201_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1432,8 +1431,6 @@ def _put201_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1552,6 +1549,7 @@ def _post202_list_initial(self, **kwargs: Any) -> Optional[List[_models.Product] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1562,8 +1560,6 @@ def _post202_list_initial(self, **kwargs: Any) -> Optional[List[_models.Product] response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1662,6 +1658,7 @@ def _put200_succeeded_no_state_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1672,8 +1669,6 @@ def _put200_succeeded_no_state_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1809,6 +1804,7 @@ def _put202_retry200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1819,8 +1815,6 @@ def _put202_retry200_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1959,6 +1953,7 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1969,8 +1964,6 @@ def _put201_creating_succeeded200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2113,6 +2106,7 @@ def _put200_updating_succeeded204_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2123,8 +2117,6 @@ def _put200_updating_succeeded204_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2263,6 +2255,7 @@ def _put201_creating_failed200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2273,8 +2266,6 @@ def _put201_creating_failed200_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2417,6 +2408,7 @@ def _put200_acceptedcanceled200_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2427,8 +2419,6 @@ def _put200_acceptedcanceled200_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2567,6 +2557,7 @@ def _put_no_header_in_retry_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2577,8 +2568,6 @@ def _put_no_header_in_retry_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2721,6 +2710,7 @@ def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2731,8 +2721,6 @@ def _put_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2886,6 +2874,7 @@ def _put_async_no_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2896,8 +2885,6 @@ def _put_async_no_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3049,6 +3036,7 @@ def _put_async_retry_failed_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3059,8 +3047,6 @@ def _put_async_retry_failed_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3214,6 +3200,7 @@ def _put_async_no_retrycanceled_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3224,8 +3211,6 @@ def _put_async_no_retrycanceled_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3377,6 +3362,7 @@ def _put_async_no_header_in_retry_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3387,8 +3373,6 @@ def _put_async_no_header_in_retry_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3538,6 +3522,7 @@ def _put_non_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3548,8 +3533,6 @@ def _put_non_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3674,6 +3657,7 @@ def _put_async_non_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3684,8 +3668,6 @@ def _put_async_non_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3802,6 +3784,7 @@ def _put_sub_resource_initial(self, provisioning_state: Optional[str] = None, ** headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3812,8 +3795,6 @@ def _put_sub_resource_initial(self, provisioning_state: Optional[str] = None, ** response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3907,6 +3888,7 @@ def _put_async_sub_resource_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3917,8 +3899,6 @@ def _put_async_sub_resource_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4003,6 +3983,7 @@ def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4013,8 +3994,6 @@ def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4101,6 +4080,7 @@ def _delete_provisioning202_deleting_failed200_initial( # pylint: disable=name- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4111,8 +4091,6 @@ def _delete_provisioning202_deleting_failed200_initial( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4199,6 +4177,7 @@ def _delete_provisioning202_deletingcanceled200_initial( # pylint: disable=name headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4209,8 +4188,6 @@ def _delete_provisioning202_deletingcanceled200_initial( # pylint: disable=name response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4295,6 +4272,7 @@ def _delete204_succeeded_initial(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4305,8 +4283,6 @@ def _delete204_succeeded_initial(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4371,6 +4347,7 @@ def _delete202_retry200_initial(self, **kwargs: Any) -> Optional[_models.Product headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4381,8 +4358,6 @@ def _delete202_retry200_initial(self, **kwargs: Any) -> Optional[_models.Product response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4463,6 +4438,7 @@ def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional[_models.Prod headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4473,8 +4449,6 @@ def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional[_models.Prod response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4557,6 +4531,7 @@ def _delete_no_header_in_retry_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4567,8 +4542,6 @@ def _delete_no_header_in_retry_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4640,6 +4613,7 @@ def _delete_async_no_header_in_retry_initial( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4650,8 +4624,6 @@ def _delete_async_no_header_in_retry_initial( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4723,6 +4695,7 @@ def _delete_async_retry_succeeded_initial( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4733,8 +4706,6 @@ def _delete_async_retry_succeeded_initial( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4809,6 +4780,7 @@ def _delete_async_no_retry_succeeded_initial( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4819,8 +4791,6 @@ def _delete_async_no_retry_succeeded_initial( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4895,6 +4865,7 @@ def _delete_async_retry_failed_initial( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4905,8 +4876,6 @@ def _delete_async_retry_failed_initial( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -4981,6 +4950,7 @@ def _delete_async_retrycanceled_initial( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4991,8 +4961,6 @@ def _delete_async_retrycanceled_initial( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5065,6 +5033,7 @@ def _post200_with_payload_initial(self, **kwargs: Any) -> _models.Sku: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5075,8 +5044,6 @@ def _post200_with_payload_initial(self, **kwargs: Any) -> _models.Sku: response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5169,6 +5136,7 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5179,8 +5147,6 @@ def _post202_retry200_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5312,6 +5278,7 @@ def _post202_no_retry204_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5322,8 +5289,6 @@ def _post202_no_retry204_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5453,6 +5418,7 @@ def _post_double_headers_final_location_get_initial( # pylint: disable=name-too headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5463,8 +5429,6 @@ def _post_double_headers_final_location_get_initial( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5545,6 +5509,7 @@ def _post_double_headers_final_azure_header_get_initial( # pylint: disable=name headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5555,8 +5520,6 @@ def _post_double_headers_final_azure_header_get_initial( # pylint: disable=name response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5637,6 +5600,7 @@ def _post_double_headers_final_azure_header_get_default_initial( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5647,8 +5611,6 @@ def _post_double_headers_final_azure_header_get_default_initial( # pylint: disa response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5742,6 +5704,7 @@ def _post_async_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5752,8 +5715,6 @@ def _post_async_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -5902,6 +5863,7 @@ def _post_async_no_retry_succeeded_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5912,8 +5874,6 @@ def _post_async_no_retry_succeeded_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -6062,6 +6022,7 @@ def _post_async_retry_failed_initial( # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -6072,8 +6033,6 @@ def _post_async_retry_failed_initial( # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -6211,6 +6170,7 @@ def _post_async_retrycanceled_initial( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -6221,8 +6181,6 @@ def _post_async_retrycanceled_initial( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py index bbf399e014f..b650cbd4233 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py @@ -19,8 +19,9 @@ map_error, ) 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, HttpResponse +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 @@ -28,6 +29,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -530,6 +532,7 @@ def _put_non_retry400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -540,8 +543,6 @@ def _put_non_retry400_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -678,6 +679,7 @@ def _put_non_retry201_creating400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -688,8 +690,6 @@ def _put_non_retry201_creating400_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -829,6 +829,7 @@ def _put_non_retry201_creating400_invalid_json_initial( # pylint: disable=name- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -839,8 +840,6 @@ def _put_non_retry201_creating400_invalid_json_initial( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -980,6 +979,7 @@ def _put_async_relative_retry400_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -990,8 +990,6 @@ def _put_async_relative_retry400_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1125,6 +1123,7 @@ def _delete_non_retry400_initial(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1135,8 +1134,6 @@ def _delete_non_retry400_initial(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1205,6 +1202,7 @@ def _delete202_non_retry400_initial(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1215,8 +1213,6 @@ def _delete202_non_retry400_initial(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1287,6 +1283,7 @@ def _delete_async_relative_retry400_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1297,8 +1294,6 @@ def _delete_async_relative_retry400_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1388,6 +1383,7 @@ def _post_non_retry400_initial( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1398,8 +1394,6 @@ def _post_non_retry400_initial( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1528,6 +1522,7 @@ def _post202_non_retry400_initial( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1538,8 +1533,6 @@ def _post202_non_retry400_initial( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1668,6 +1661,7 @@ def _post_async_relative_retry400_initial( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1678,8 +1672,6 @@ def _post_async_relative_retry400_initial( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1814,6 +1806,7 @@ def _put_error201_no_provisioning_state_payload_initial( # pylint: disable=name headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1824,8 +1817,6 @@ def _put_error201_no_provisioning_state_payload_initial( # pylint: disable=name response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1962,6 +1953,7 @@ def _put_async_relative_retry_no_status_initial( # pylint: disable=name-too-lon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1972,8 +1964,6 @@ def _put_async_relative_retry_no_status_initial( # pylint: disable=name-too-lon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2127,6 +2117,7 @@ def _put_async_relative_retry_no_status_payload_initial( # pylint: disable=name headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2137,8 +2128,6 @@ def _put_async_relative_retry_no_status_payload_initial( # pylint: disable=name response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2275,6 +2264,7 @@ def _delete204_succeeded_initial(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2285,8 +2275,6 @@ def _delete204_succeeded_initial(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2353,6 +2341,7 @@ def _delete_async_relative_retry_no_status_initial( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2363,8 +2352,6 @@ def _delete_async_relative_retry_no_status_initial( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2456,6 +2443,7 @@ def _post202_no_location_initial( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2466,8 +2454,6 @@ def _post202_no_location_initial( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2599,6 +2585,7 @@ def _post_async_relative_retry_no_payload_initial( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2609,8 +2596,6 @@ def _post_async_relative_retry_no_payload_initial( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2748,6 +2733,7 @@ def _put200_invalid_json_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2758,8 +2744,6 @@ def _put200_invalid_json_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2897,6 +2881,7 @@ def _put_async_relative_retry_invalid_header_initial( # pylint: disable=name-to headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2907,8 +2892,6 @@ def _put_async_relative_retry_invalid_header_initial( # pylint: disable=name-to response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3062,6 +3045,7 @@ def _put_async_relative_retry_invalid_json_polling_initial( # pylint: disable=n headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3072,8 +3056,6 @@ def _put_async_relative_retry_invalid_json_polling_initial( # pylint: disable=n response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3212,6 +3194,7 @@ def _delete202_retry_invalid_header_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3222,8 +3205,6 @@ def _delete202_retry_invalid_header_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3295,6 +3276,7 @@ def _delete_async_relative_retry_invalid_header_initial( # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3305,8 +3287,6 @@ def _delete_async_relative_retry_invalid_header_initial( # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3383,6 +3363,7 @@ def _delete_async_relative_retry_invalid_json_polling_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3393,8 +3374,6 @@ def _delete_async_relative_retry_invalid_json_polling_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3486,6 +3465,7 @@ def _post202_retry_invalid_header_initial( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3496,8 +3476,6 @@ def _post202_retry_invalid_header_initial( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3629,6 +3607,7 @@ def _post_async_relative_retry_invalid_header_initial( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3639,8 +3618,6 @@ def _post_async_relative_retry_invalid_header_initial( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -3778,6 +3755,7 @@ def _post_async_relative_retry_invalid_json_polling_initial( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3788,8 +3766,6 @@ def _post_async_relative_retry_invalid_json_polling_initial( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_vendor.py index d74e3c6d01d..defd0d956d7 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import LROWithParamaterizedEndpointsConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class LROWithParamaterizedEndpointsMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_vendor.py index 6a04cfda87e..e7b8b3d9112 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import LROWithParamaterizedEndpointsConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py index 27635622655..a6772e65ebe 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py @@ -18,12 +18,14 @@ 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.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._lro_with_paramaterized_endpoints_operations import ( build_poll_with_constant_parameterized_endpoints_request, build_poll_with_parameterized_endpoints_request, @@ -62,6 +64,7 @@ async def _poll_with_parameterized_endpoints_initial( # pylint: disable=name-to headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -76,8 +79,6 @@ async def _poll_with_parameterized_endpoints_initial( # pylint: disable=name-to response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -174,6 +175,7 @@ async def _poll_with_constant_parameterized_endpoints_initial( # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -188,8 +190,6 @@ async def _poll_with_constant_parameterized_endpoints_initial( # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py index d25c8b999e3..ac8a0616a25 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py @@ -18,15 +18,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import LROWithParamaterizedEndpointsMixinABC +from .._vendor import LROWithParamaterizedEndpointsMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -99,6 +100,7 @@ def _poll_with_parameterized_endpoints_initial( # pylint: disable=name-too-long headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -113,8 +115,6 @@ def _poll_with_parameterized_endpoints_initial( # pylint: disable=name-too-long response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -211,6 +211,7 @@ def _poll_with_constant_parameterized_endpoints_initial( # pylint: disable=name headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -225,8 +226,6 @@ def _poll_with_constant_parameterized_endpoints_initial( # pylint: disable=name response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_default_operations.py index 650cb019dfe..3f9a9d2e839 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_default_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._api_version_default_operations import ( build_get_method_global_not_provided_valid_request, build_get_method_global_valid_request, @@ -84,6 +86,7 @@ async def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -132,6 +133,7 @@ async def get_method_global_not_provided_valid( # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -142,8 +144,6 @@ async def get_method_global_not_provided_valid( # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -178,6 +178,7 @@ async def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -188,8 +189,6 @@ async def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -224,6 +223,7 @@ async def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,8 +234,6 @@ async def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_local_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_local_operations.py index cfcd7858823..2beb2f5ce0b 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_local_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_api_version_local_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._api_version_local_operations import ( build_get_method_local_null_request, build_get_method_local_valid_request, @@ -84,6 +86,7 @@ async def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -134,6 +135,7 @@ async def get_method_local_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -144,8 +146,6 @@ async def get_method_local_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -180,6 +180,7 @@ async def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +191,6 @@ async def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -226,6 +225,7 @@ async def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +236,6 @@ async def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py index 52f5b9ea966..528f936a3ae 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._header_operations import ( build_custom_named_request_id_head_request, build_custom_named_request_id_param_grouping_request, @@ -85,6 +87,7 @@ async def custom_named_request_id( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def custom_named_request_id( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -145,6 +146,7 @@ async def custom_named_request_id_param_grouping( # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,8 +157,6 @@ async def custom_named_request_id_param_grouping( # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +197,7 @@ async def custom_named_request_id_head( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +208,6 @@ async def custom_named_request_id_head( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_http_success_operations.py index b5724e8c210..2808803f711 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -76,6 +78,7 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -86,8 +89,6 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -119,6 +120,7 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -129,8 +131,6 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_odata_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_odata_operations.py index 7ddda776302..53c0cd26163 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_odata_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_odata_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._odata_operations import build_get_with_filter_request if sys.version_info >= (3, 9): @@ -88,6 +90,7 @@ async def get_with_filter( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -98,8 +101,6 @@ async def get_with_filter( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_skip_url_encoding_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_skip_url_encoding_operations.py index 26e11483186..4dcb37af03f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_skip_url_encoding_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_skip_url_encoding_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._skip_url_encoding_operations import ( build_get_method_path_valid_request, build_get_method_query_null_request, @@ -90,6 +92,7 @@ async def get_method_path_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def get_method_path_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -139,6 +140,7 @@ async def get_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -149,8 +151,6 @@ async def get_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -185,6 +185,7 @@ async def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +196,6 @@ async def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -234,6 +233,7 @@ async def get_method_query_valid( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -244,8 +244,6 @@ async def get_method_query_valid( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -283,6 +281,7 @@ async def get_method_query_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -293,8 +292,6 @@ async def get_method_query_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -332,6 +329,7 @@ async def get_path_query_valid( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -342,8 +340,6 @@ async def get_path_query_valid( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -378,6 +374,7 @@ async def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -388,8 +385,6 @@ async def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_credentials_operations.py index dfdba2c35ba..9c10b057d99 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_credentials_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._subscription_in_credentials_operations import ( build_post_method_global_not_provided_valid_request, build_post_method_global_null_request, @@ -85,6 +87,7 @@ async def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -131,6 +132,7 @@ async def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -141,8 +143,6 @@ async def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -181,6 +181,7 @@ async def post_method_global_not_provided_valid( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,8 +192,6 @@ async def post_method_global_not_provided_valid( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -227,6 +226,7 @@ async def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -237,8 +237,6 @@ async def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -273,6 +271,7 @@ async def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -283,8 +282,6 @@ async def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_method_operations.py index 6aab470b98b..7857393831f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_subscription_in_method_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._subscription_in_method_operations import ( build_post_method_local_null_request, build_post_method_local_valid_request, @@ -88,6 +90,7 @@ async def post_method_local_valid( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -98,8 +101,6 @@ async def post_method_local_valid( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -139,6 +140,7 @@ async def post_method_local_null( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -149,8 +151,6 @@ async def post_method_local_null( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -190,6 +190,7 @@ async def post_path_local_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -200,8 +201,6 @@ async def post_path_local_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -241,6 +240,7 @@ async def post_swagger_local_valid( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -251,8 +251,6 @@ async def post_swagger_local_valid( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_xms_client_request_id_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_xms_client_request_id_operations.py index e7922dc9f88..81f18ab37d4 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_xms_client_request_id_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_xms_client_request_id_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._xms_client_request_id_operations import build_get_request, build_param_get_request if sys.version_info >= (3, 9): @@ -77,6 +79,7 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -127,6 +128,7 @@ async def param_get( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -137,8 +139,6 @@ async def param_get( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py index 3e331368aa8..1d077ad1916 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -160,6 +162,7 @@ def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -170,8 +173,6 @@ def get_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -208,6 +209,7 @@ def get_method_global_not_provided_valid( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def get_method_global_not_provided_valid( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -254,6 +254,7 @@ def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,8 +265,6 @@ def get_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -300,6 +299,7 @@ def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,8 +310,6 @@ def get_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_local_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_local_operations.py index 17ef2ee09f9..54a597fa090 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_local_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_local_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -158,6 +160,7 @@ def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -168,8 +171,6 @@ def get_method_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -208,6 +209,7 @@ def get_method_local_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def get_method_local_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -254,6 +254,7 @@ def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,8 +265,6 @@ def get_path_local_valid(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -300,6 +299,7 @@ def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,8 +310,6 @@ def get_swagger_local_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py index c7b384341d5..2034a1fc6bb 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -134,6 +136,7 @@ def custom_named_request_id( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -144,8 +147,6 @@ def custom_named_request_id( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -194,6 +195,7 @@ def custom_named_request_id_param_grouping( # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -204,8 +206,6 @@ def custom_named_request_id_param_grouping( # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -246,6 +246,7 @@ def custom_named_request_id_head( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,8 +257,6 @@ def custom_named_request_id_head( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_http_success_operations.py index d287b448689..6070dfedbff 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -100,6 +102,7 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -110,8 +113,6 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -143,6 +144,7 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -153,8 +155,6 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_odata_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_odata_operations.py index afba7548ed0..da80e8d4734 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_odata_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_odata_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -117,6 +119,7 @@ def get_with_filter( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -127,8 +130,6 @@ def get_with_filter( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_skip_url_encoding_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_skip_url_encoding_operations.py index 388079ab7ab..166265cf45e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_skip_url_encoding_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_skip_url_encoding_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -217,6 +219,7 @@ def get_method_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -227,8 +230,6 @@ def get_method_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -266,6 +267,7 @@ def get_path_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -276,8 +278,6 @@ def get_path_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -312,6 +312,7 @@ def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -322,8 +323,6 @@ def get_swagger_path_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -359,6 +358,7 @@ def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -369,8 +369,6 @@ def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -408,6 +406,7 @@ def get_method_query_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -418,8 +417,6 @@ def get_method_query_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -455,6 +452,7 @@ def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -465,8 +463,6 @@ def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -501,6 +497,7 @@ def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -511,8 +508,6 @@ def get_swagger_query_valid(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py index 940ce5daf74..41712bb5cb3 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -198,6 +200,7 @@ def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -208,8 +211,6 @@ def post_method_global_valid(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -244,6 +245,7 @@ def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -254,8 +256,6 @@ def post_method_global_null(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -294,6 +294,7 @@ def post_method_global_not_provided_valid( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -304,8 +305,6 @@ def post_method_global_not_provided_valid( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -340,6 +339,7 @@ def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -350,8 +350,6 @@ def post_path_global_valid(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -386,6 +384,7 @@ def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -396,8 +395,6 @@ def post_swagger_global_valid(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py index 225d4c4196d..b22920040f2 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -173,6 +175,7 @@ def post_method_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -183,8 +186,6 @@ def post_method_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -224,6 +225,7 @@ def post_method_local_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,8 +236,6 @@ def post_method_local_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -275,6 +275,7 @@ def post_path_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -285,8 +286,6 @@ def post_path_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -326,6 +325,7 @@ def post_swagger_local_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -336,8 +336,6 @@ def post_swagger_local_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_xms_client_request_id_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_xms_client_request_id_operations.py index 069f4f906e3..5df3f7f5ef3 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_xms_client_request_id_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_xms_client_request_id_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +105,7 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +116,6 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -153,6 +154,7 @@ def param_get( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -163,8 +165,6 @@ def param_get( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/aio/operations/_http_success_operations.py index 858feb968fc..e03dacc816a 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/operations/_http_success_operations.py index 1efa73c0ab5..9fbfa6fa61d 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py index 180b982fed2..cd3af171811 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py @@ -20,8 +20,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -29,6 +30,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._paging_operations import ( build_append_api_version_request, build_duplicate_params_request, @@ -113,6 +115,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,6 +131,7 @@ 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 @@ -149,8 +153,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +188,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -201,6 +204,7 @@ 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 @@ -222,8 +226,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -259,6 +261,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -274,6 +277,7 @@ 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 @@ -295,8 +299,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -332,6 +334,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -347,6 +350,7 @@ 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 @@ -368,8 +372,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -414,6 +416,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -429,6 +432,7 @@ 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 @@ -450,8 +454,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -488,6 +490,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -503,6 +506,7 @@ 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 @@ -524,8 +528,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -579,6 +581,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -594,6 +597,7 @@ 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 @@ -615,8 +619,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -659,6 +661,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -668,6 +671,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -689,8 +693,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -731,6 +733,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -746,6 +749,7 @@ 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 @@ -767,8 +771,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -810,6 +812,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -825,6 +828,7 @@ 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 @@ -846,8 +850,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -901,6 +903,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -916,6 +919,7 @@ 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 @@ -937,8 +941,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -995,6 +997,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1010,6 +1013,7 @@ 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 @@ -1031,8 +1035,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1069,6 +1071,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1084,6 +1087,7 @@ 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 @@ -1105,8 +1109,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1143,6 +1145,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1158,6 +1161,7 @@ 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 @@ -1179,8 +1183,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1216,6 +1218,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1231,6 +1234,7 @@ 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 @@ -1252,8 +1256,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1289,6 +1291,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1304,6 +1307,7 @@ 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 @@ -1325,8 +1329,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1362,6 +1364,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1377,6 +1380,7 @@ 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 @@ -1398,8 +1402,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1443,6 +1445,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1454,6 +1457,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1475,8 +1479,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1523,6 +1525,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1539,6 +1542,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1560,8 +1564,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1601,6 +1603,7 @@ async def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1611,8 +1614,6 @@ async def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1672,6 +1673,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1687,6 +1689,7 @@ 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 @@ -1708,8 +1711,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1785,6 +1786,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1800,6 +1802,7 @@ 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 @@ -1821,8 +1824,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1861,6 +1862,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1876,6 +1878,7 @@ 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 @@ -1897,8 +1900,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1937,6 +1938,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1952,6 +1954,7 @@ 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 @@ -1973,8 +1976,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/operations/_paging_operations.py index 2b2166d9307..35da9c7b5e8 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/operations/_paging_operations.py @@ -20,8 +20,9 @@ ) 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, HttpResponse +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 @@ -29,6 +30,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -574,6 +576,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -589,6 +592,7 @@ 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 @@ -610,8 +614,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -647,6 +649,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -662,6 +665,7 @@ 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 @@ -683,8 +687,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -720,6 +722,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -735,6 +738,7 @@ 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 @@ -756,8 +760,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -793,6 +795,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -808,6 +811,7 @@ 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 @@ -829,8 +833,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -875,6 +877,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -890,6 +893,7 @@ 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 @@ -911,8 +915,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -949,6 +951,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -964,6 +967,7 @@ 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 @@ -985,8 +989,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1040,6 +1042,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1055,6 +1058,7 @@ 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 @@ -1076,8 +1080,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1120,6 +1122,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1129,6 +1132,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1150,8 +1154,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1192,6 +1194,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1207,6 +1210,7 @@ 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 @@ -1228,8 +1232,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1269,6 +1271,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1284,6 +1287,7 @@ 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 @@ -1305,8 +1309,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1360,6 +1362,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1375,6 +1378,7 @@ 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 @@ -1396,8 +1400,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1454,6 +1456,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1469,6 +1472,7 @@ 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 @@ -1490,8 +1494,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1528,6 +1530,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1543,6 +1546,7 @@ 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 @@ -1564,8 +1568,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1602,6 +1604,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1617,6 +1620,7 @@ 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 @@ -1638,8 +1642,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1675,6 +1677,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1690,6 +1693,7 @@ 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 @@ -1711,8 +1715,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1748,6 +1750,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1763,6 +1766,7 @@ 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 @@ -1784,8 +1788,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1821,6 +1823,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1836,6 +1839,7 @@ 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 @@ -1857,8 +1861,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1902,6 +1904,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1913,6 +1916,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1934,8 +1938,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1982,6 +1984,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1998,6 +2001,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -2019,8 +2023,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2060,6 +2062,7 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2070,8 +2073,6 @@ def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2131,6 +2132,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2146,6 +2148,7 @@ 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 @@ -2167,8 +2170,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2244,6 +2245,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2259,6 +2261,7 @@ 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 @@ -2280,8 +2283,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2320,6 +2321,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2335,6 +2337,7 @@ 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 @@ -2356,8 +2359,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2396,6 +2397,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2411,6 +2413,7 @@ 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 @@ -2432,8 +2435,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/aio/operations/_http_success_operations.py index e319d944cd6..3a7ef30639c 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/operations/_http_success_operations.py index 8a83d55bb32..0b647071971 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/aio/operations/_http_success_operations.py index 72528972de3..ea673e144aa 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/operations/_http_success_operations.py index 430bfc761dd..7b831170305 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/aio/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/aio/operations/_http_success_operations.py index 7d44cd4b3d7..7345730f265 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/aio/operations/_http_success_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._http_success_operations import build_head200_request, build_head204_request, build_head404_request if sys.version_info >= (3, 9): @@ -74,6 +76,7 @@ async def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -84,8 +87,6 @@ async def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -118,6 +119,7 @@ async def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,8 +130,6 @@ async def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -162,6 +162,7 @@ async def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +173,6 @@ async def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/operations/_http_success_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/operations/_http_success_operations.py index ce58cbbcd02..4d659f5cbfc 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/operations/_http_success_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,6 +100,7 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,8 +111,6 @@ def head200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -142,6 +143,7 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ def head204(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def head404(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py index b499a081164..e8585ae3b2e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py @@ -20,14 +20,16 @@ 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.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._paging_operations import ( build_append_api_version_request, build_duplicate_params_request, @@ -112,6 +114,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,6 +130,7 @@ 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 @@ -148,8 +152,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -185,6 +187,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -200,6 +203,7 @@ 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 @@ -221,8 +225,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -258,6 +260,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -273,6 +276,7 @@ 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 @@ -294,8 +298,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -331,6 +333,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -346,6 +349,7 @@ 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 @@ -367,8 +371,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -413,6 +415,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -428,6 +431,7 @@ 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 @@ -449,8 +453,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -487,6 +489,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -502,6 +505,7 @@ 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 @@ -523,8 +527,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -577,6 +579,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -592,6 +595,7 @@ 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 @@ -613,8 +617,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -657,6 +659,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -666,6 +669,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -687,8 +691,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -729,6 +731,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -744,6 +747,7 @@ 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 @@ -765,8 +769,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -808,6 +810,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -823,6 +826,7 @@ 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 @@ -844,8 +848,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -899,6 +901,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -914,6 +917,7 @@ 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 @@ -935,8 +939,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -993,6 +995,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1008,6 +1011,7 @@ 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 @@ -1029,8 +1033,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1067,6 +1069,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1082,6 +1085,7 @@ 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 @@ -1103,8 +1107,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1141,6 +1143,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1156,6 +1159,7 @@ 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 @@ -1177,8 +1181,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1214,6 +1216,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1229,6 +1232,7 @@ 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 @@ -1250,8 +1254,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1287,6 +1289,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1302,6 +1305,7 @@ 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 @@ -1323,8 +1327,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1360,6 +1362,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1375,6 +1378,7 @@ 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 @@ -1396,8 +1400,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1441,6 +1443,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1452,6 +1455,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1473,8 +1477,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1521,6 +1523,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1537,6 +1540,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1558,8 +1562,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1599,6 +1601,7 @@ async def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1609,8 +1612,6 @@ async def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1669,6 +1670,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1684,6 +1686,7 @@ 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 @@ -1705,8 +1708,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1782,6 +1783,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1797,6 +1799,7 @@ 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 @@ -1818,8 +1821,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1858,6 +1859,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1873,6 +1875,7 @@ 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 @@ -1894,8 +1897,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1934,6 +1935,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1949,6 +1951,7 @@ 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 @@ -1970,8 +1973,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py index 021eae876d5..c8ff50015b0 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py @@ -20,14 +20,16 @@ ) 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.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -573,6 +575,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -588,6 +591,7 @@ 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 @@ -609,8 +613,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -646,6 +648,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -661,6 +664,7 @@ 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 @@ -682,8 +686,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -719,6 +721,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -734,6 +737,7 @@ 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 @@ -755,8 +759,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -792,6 +794,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -807,6 +810,7 @@ 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 @@ -828,8 +832,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -874,6 +876,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -889,6 +892,7 @@ 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 @@ -910,8 +914,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -948,6 +950,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -963,6 +966,7 @@ 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 @@ -984,8 +988,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1038,6 +1040,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1053,6 +1056,7 @@ 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 @@ -1074,8 +1078,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1118,6 +1120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1127,6 +1130,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1148,8 +1152,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1190,6 +1192,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1205,6 +1208,7 @@ 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 @@ -1226,8 +1230,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1267,6 +1269,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1282,6 +1285,7 @@ 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 @@ -1303,8 +1307,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1358,6 +1360,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1373,6 +1376,7 @@ 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 @@ -1394,8 +1398,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1452,6 +1454,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1467,6 +1470,7 @@ 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 @@ -1488,8 +1492,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1526,6 +1528,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1541,6 +1544,7 @@ 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 @@ -1562,8 +1566,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1600,6 +1602,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1615,6 +1618,7 @@ 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 @@ -1636,8 +1640,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1673,6 +1675,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1688,6 +1691,7 @@ 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 @@ -1709,8 +1713,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1746,6 +1748,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1761,6 +1764,7 @@ 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 @@ -1782,8 +1786,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1819,6 +1821,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1834,6 +1837,7 @@ 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 @@ -1855,8 +1859,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1900,6 +1902,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1911,6 +1914,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1932,8 +1936,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1980,6 +1982,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1996,6 +1999,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -2017,8 +2021,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2058,6 +2060,7 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2068,8 +2071,6 @@ def _get_multiple_pages_lro_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2127,6 +2128,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2142,6 +2144,7 @@ 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 @@ -2163,8 +2166,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2240,6 +2241,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2255,6 +2257,7 @@ 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 @@ -2276,8 +2279,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2316,6 +2317,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2331,6 +2333,7 @@ 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 @@ -2352,8 +2355,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2392,6 +2393,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2407,6 +2409,7 @@ 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 @@ -2428,8 +2431,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py index 307a2440f73..7fdee8b3dfe 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutorestSecurityAadMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py index 8e6e310bac2..8925dce2632 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py index 16f438cd590..0e761341e0e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._autorest_security_aad_operations import build_head_request from .._vendor import AutorestSecurityAadMixinABC @@ -60,6 +62,7 @@ async def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -70,8 +73,6 @@ async def head(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py index 00b66763231..a8b67573972 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer -from .._vendor import AutorestSecurityAadMixinABC +from .._vendor import AutorestSecurityAadMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,6 +71,7 @@ def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -80,8 +82,6 @@ def head(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py index 9fb96a324c5..c8a5025a2fb 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutorestSecurityKeyMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py index 7b331844629..b2d14534fb2 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py index d8052e1d1d1..eae8aacf726 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._vendor import _convert_request from ...operations._autorest_security_key_operations import build_head_request from .._vendor import AutorestSecurityKeyMixinABC @@ -60,6 +62,7 @@ async def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -70,8 +73,6 @@ async def head(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py index e6b6851da3a..8d594b99314 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer -from .._vendor import AutorestSecurityKeyMixinABC +from .._vendor import AutorestSecurityKeyMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,6 +71,7 @@ def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -80,8 +82,6 @@ def head(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py index eb7e90020aa..4b3b57c7890 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._storage_accounts_operations import ( build_check_name_availability_request, build_create_request, @@ -156,6 +158,7 @@ async def check_name_availability( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -166,8 +169,6 @@ async def check_name_availability( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -219,6 +220,7 @@ async def _create_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,8 +231,6 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -422,6 +422,7 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -432,8 +433,6 @@ async def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -481,6 +480,7 @@ async def get_properties( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +491,6 @@ async def get_properties( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -640,6 +638,7 @@ async def update( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -650,8 +649,6 @@ async def update( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -697,6 +694,7 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -707,8 +705,6 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -751,6 +747,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -766,6 +763,7 @@ 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 @@ -787,8 +785,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -834,6 +830,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -849,6 +846,7 @@ 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 @@ -870,8 +868,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -930,6 +926,7 @@ async def regenerate_key( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -940,8 +937,6 @@ async def regenerate_key( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py index cefe34447e3..986b796cd9e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request if sys.version_info >= (3, 9): @@ -81,6 +83,7 @@ async def list(self, **kwargs: Any) -> _models.UsageListResult: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def list(self, **kwargs: Any) -> _models.UsageListResult: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py index 66bd28eb2ce..466733ac72b 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,6 +31,7 @@ from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -418,6 +420,7 @@ def check_name_availability( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -428,8 +431,6 @@ def check_name_availability( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -481,6 +482,7 @@ def _create_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +493,6 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -684,6 +684,7 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -694,8 +695,6 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -741,6 +740,7 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -751,8 +751,6 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -900,6 +898,7 @@ def update( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -910,8 +909,6 @@ def update( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -957,6 +954,7 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -967,8 +965,6 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1011,6 +1007,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1026,6 +1023,7 @@ 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 @@ -1047,8 +1045,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1092,6 +1088,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1107,6 +1104,7 @@ 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 @@ -1128,8 +1126,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1188,6 +1184,7 @@ def regenerate_key( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1198,8 +1195,6 @@ def regenerate_key( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py index 49cfd3b47aa..68e1a8cc7b7 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py @@ -18,13 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +110,7 @@ def list(self, **kwargs: Any) -> _models.UsageListResult: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +121,6 @@ def list(self, **kwargs: Any) -> _models.UsageListResult: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_vendor.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py index 274b9699ec7..e533d6035a9 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._group_operations import build_get_sample_resource_group_request if sys.version_info >= (3, 9): @@ -84,6 +86,7 @@ async def get_sample_resource_group(self, resource_group_name: str, **kwargs: An headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_sample_resource_group(self, resource_group_name: str, **kwargs: An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py index d7595eb9bce..5648a2b2d1a 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py @@ -18,13 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -114,6 +116,7 @@ def get_sample_resource_group(self, resource_group_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -124,8 +127,6 @@ def get_sample_resource_group(self, resource_group_name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py index 3ce39b9aaaa..5bc31690d4d 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request if sys.version_info >= (3, 9): @@ -81,6 +83,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py index d520fe189e5..d68184a3893 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py @@ -18,13 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py index 901366de5b4..1072d2c37f2 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -90,6 +92,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -144,6 +145,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -291,6 +291,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,8 +302,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -361,6 +360,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -376,6 +376,7 @@ 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 @@ -397,8 +398,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -477,6 +476,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,8 +487,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py index ecb3b5bd56b..d091d89086f 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -82,6 +84,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,8 +95,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py index 66cffbf2621..52fdeab10df 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,6 +169,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -222,6 +222,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +233,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -436,6 +434,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,6 +450,7 @@ 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 @@ -472,8 +472,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -552,6 +550,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -562,8 +561,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py index 4f7696475b0..9e4c7aa9d09 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py index fe0d0d63b59..7e9a2481aab 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -77,6 +79,7 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -137,6 +138,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,8 +149,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py index e3f04a0d83a..d52dad91367 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -185,6 +186,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +197,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py index 4c83170266a..b56ceb3f3d8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -87,6 +89,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py index 44066bc09b2..7c0d921e97f 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,6 +127,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py index b25deb21953..07f77dc295a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -229,6 +229,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py index 7d7257f5451..2a5ccbd4a31 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +109,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +120,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py index 20346552a27..49ffba0daf7 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,13 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -76,6 +78,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -91,6 +94,7 @@ 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 @@ -112,8 +116,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -165,6 +167,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +178,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py index 7230a950fe9..f9c7cfd3931 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -90,6 +92,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,6 +108,7 @@ 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 @@ -126,8 +130,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -218,6 +220,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -228,8 +231,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py index b2d617a4bc5..4ed262f8a20 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -136,6 +138,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +149,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -182,6 +183,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +194,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py index 14648ca6628..c0606063c12 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py @@ -20,14 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,6 +120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -134,6 +136,7 @@ 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 @@ -155,8 +158,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py index 90fd8a17424..72a3e8e6ca8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,6 +142,7 @@ 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 @@ -161,8 +164,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -253,6 +254,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,8 +265,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py index 316e6a1c5a6..db36404219b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,6 +181,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +192,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -226,6 +226,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +237,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py index aa9ab529632..1c5045af84a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -90,6 +92,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -144,6 +145,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -291,6 +291,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,8 +302,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -362,6 +361,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,6 +377,7 @@ 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 @@ -398,8 +399,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -478,6 +477,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -488,8 +488,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py index 6db37ef56d1..2c7b51cbd16 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -82,6 +84,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,8 +95,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py index 3e0bb0f1a93..453d1e9a701 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,6 +169,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -222,6 +222,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +233,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -437,6 +435,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -452,6 +451,7 @@ 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 @@ -473,8 +473,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -553,6 +551,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -563,8 +562,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py index 0841b347342..dd30113fffc 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py index d19e97f871c..185a63cd51e 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -77,6 +79,7 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -137,6 +138,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,8 +149,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py index 1a74574ddfc..e69e20bee2a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -185,6 +186,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +197,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py index a64f0455077..8de23e0ad26 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -87,6 +89,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py index 1767db8ec68..59900fc2413 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,6 +127,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py index 2257eb5d77d..f684a4a1fde 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -229,6 +229,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py index 8553ff59e8d..e1f1adb7a03 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +109,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +120,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py index 3bc8bf90a28..31ec5724871 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,13 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -77,6 +79,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -92,6 +95,7 @@ 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 @@ -113,8 +117,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -166,6 +168,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -176,8 +179,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py index f843108bd4a..3feab7cebb8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -91,6 +93,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -106,6 +109,7 @@ 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 @@ -127,8 +131,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -219,6 +221,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,8 +232,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py index 7d7e6fccd94..dde3040ce50 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -136,6 +138,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +149,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -182,6 +183,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +194,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py index c33d9b3e554..e3f947ceef7 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py @@ -20,14 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,6 +120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -134,6 +136,7 @@ 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 @@ -155,8 +158,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py index 7f473c831f5..b5d51c45e71 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,6 +142,7 @@ 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 @@ -161,8 +164,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -253,6 +254,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,8 +265,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py index b785c33e1d0..9a2c801c161 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,6 +181,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +192,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -226,6 +226,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +237,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_vendor.py index e1d4f2b44df..f0a0ec64e8c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiCustomBaseUrlServiceClientMixinABC(ABC): # pylint: disable=name-too-long """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_vendor.py index 9bfd415353f..5837d37a93c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py index 670e2970625..5da1edaade7 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_custom_base_url_service_client_operations import build_test_request from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC @@ -74,6 +76,7 @@ async def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -87,8 +90,6 @@ async def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py index 78030eb6522..1156b1266d8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC +from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -97,6 +98,7 @@ def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -110,8 +112,6 @@ def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_vendor.py index e1d4f2b44df..f0a0ec64e8c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiCustomBaseUrlServiceClientMixinABC(ABC): # pylint: disable=name-too-long """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_vendor.py index 9bfd415353f..5837d37a93c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py index 9d75db26558..ed43663199d 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_custom_base_url_service_client_operations import build_test_request from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC @@ -74,6 +76,7 @@ async def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -87,8 +90,6 @@ async def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py index 89682526e61..e6d93c9a4a2 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC +from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -97,6 +98,7 @@ def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -110,8 +112,6 @@ def test(self, id: int, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py index afd19250228..6c0778f461a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,14 +21,16 @@ 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.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -89,6 +91,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,8 +102,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -143,6 +144,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -153,8 +155,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -290,6 +290,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -300,8 +301,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -360,6 +359,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -375,6 +375,7 @@ 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 @@ -396,8 +397,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -476,6 +475,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -486,8 +486,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py index 35cf7ac23a5..bf66c2887bc 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -81,6 +83,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py index f91bf72f402..04aba94b57c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py @@ -21,15 +21,16 @@ ) 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.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -167,6 +168,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -221,6 +221,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,8 +232,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -365,6 +364,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -375,8 +375,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -435,6 +433,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,6 +449,7 @@ 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 @@ -471,8 +471,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -551,6 +549,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -561,8 +560,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py index 40df8333152..4345de484fb 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +104,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +115,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py index c703955f430..e7a5a3dd74b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -76,6 +78,7 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -86,8 +89,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -136,6 +137,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +148,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py index b424ad4b509..9ff1afd2622 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -134,6 +136,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -144,8 +147,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +185,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +196,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py index 13dacc29a09..62a704394e2 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -86,6 +88,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py index d74dd04dcae..f03d6739e97 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -135,8 +137,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -185,6 +185,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +196,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py index 8f65bc6605e..80e4554b0b8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -178,6 +179,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -188,8 +190,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -228,6 +228,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +239,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py index 207ae5c0efe..d0b3d469960 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -107,6 +108,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -117,8 +119,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py index 616c854958c..51e4f058d06 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -75,6 +77,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -90,6 +93,7 @@ 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 @@ -111,8 +115,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -164,6 +166,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -174,8 +177,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py index 08ea870f44d..6bec77d0dee 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py @@ -21,12 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -89,6 +91,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,6 +107,7 @@ 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 @@ -125,8 +129,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -217,6 +219,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -227,8 +230,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py index 1083bcd3a3d..6ae64795ada 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -181,6 +182,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,8 +193,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py index 4e8bc6fb90f..4532a04d5a0 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py @@ -20,13 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -118,6 +119,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -133,6 +135,7 @@ 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 @@ -154,8 +157,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -207,6 +208,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,8 +219,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py index 10a119e545b..0e198d2b0ef 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py @@ -21,13 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -124,6 +125,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -139,6 +141,7 @@ 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 @@ -160,8 +163,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -252,6 +253,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,8 +264,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py index 83756a46c38..d208240aa57 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -225,6 +225,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -235,8 +236,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py index e01b59cc860..0219bdc3dbf 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,14 +21,16 @@ 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.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -89,6 +91,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,8 +102,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -143,6 +144,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -153,8 +155,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -291,6 +291,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,8 +302,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -362,6 +361,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,6 +377,7 @@ 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 @@ -398,8 +399,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -478,6 +477,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -488,8 +488,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_operation_group_one_operations.py index 1eeb7920156..f8c13fe1c79 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_operation_group_one_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -81,6 +83,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_multiapi_service_client_operations.py index 5bf152f0c9b..1667d4c8f50 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_multiapi_service_client_operations.py @@ -21,15 +21,16 @@ ) 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.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -167,6 +168,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -221,6 +221,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,8 +232,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -437,6 +435,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -452,6 +451,7 @@ 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 @@ -473,8 +473,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -553,6 +551,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -563,8 +562,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_operation_group_one_operations.py index 05491c08710..c8f6aca5678 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/operations/_operation_group_one_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +104,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +115,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py index 695ac8a6d18..005dac84f0b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -76,6 +78,7 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -86,8 +89,6 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -136,6 +137,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +148,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_one_operations.py index 8f8597d3c39..cee63f303da 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_one_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -134,6 +136,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -144,8 +147,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +185,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +196,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_two_operations.py index e9d1514c5de..5a2e682d5f5 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_operation_group_two_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -86,6 +88,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_multiapi_service_client_operations.py index 4b0d4fcc39d..2042ca97598 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_multiapi_service_client_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -135,8 +137,6 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -185,6 +185,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +196,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_one_operations.py index 491217429ea..2877ae1fdfb 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_one_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -178,6 +179,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -188,8 +190,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -228,6 +228,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +239,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_two_operations.py index 37a125c1521..bc32eac6aa7 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/operations/_operation_group_two_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,6 +110,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -119,8 +121,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py index 97703a13ce4..0f6f6abb0f1 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -75,6 +77,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -90,6 +93,7 @@ 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 @@ -111,8 +115,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -165,6 +167,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +178,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_one_operations.py index 316a1ce46e2..8d47a2f0f05 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_one_operations.py @@ -21,12 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -89,6 +91,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,6 +107,7 @@ 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 @@ -125,8 +129,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -217,6 +219,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -227,8 +230,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_two_operations.py index f83a76df385..8ef944418fc 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_operation_group_two_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -181,6 +182,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,8 +193,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_multiapi_service_client_operations.py index d28ff56b4b9..4936107a744 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_multiapi_service_client_operations.py @@ -20,13 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -118,6 +119,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -133,6 +135,7 @@ 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 @@ -154,8 +157,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_one_operations.py index 1b2000a42a3..bb41543f524 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_one_operations.py @@ -21,13 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -124,6 +125,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -139,6 +141,7 @@ 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 @@ -160,8 +163,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -252,6 +253,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,8 +264,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_two_operations.py index 83083d43add..25bd3ef9121 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/operations/_operation_group_two_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -225,6 +225,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -235,8 +236,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py index 10da17381b7..356b1537d1b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,6 +169,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -222,6 +222,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +233,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -436,6 +434,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,6 +450,7 @@ 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 @@ -472,8 +472,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -552,6 +550,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -562,8 +561,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py index 402f73f56a3..c5aa4bca4e5 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py index eae9af664e5..bdebed04763 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,6 +127,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py index f64ded1d62f..43eb0f6d90b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -229,6 +229,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py index 71e20b73c23..0985856792e 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +109,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +120,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py index 9450b403895..8e6ccb2ba82 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py @@ -20,14 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,6 +120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -134,6 +136,7 @@ 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 @@ -155,8 +158,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py index b50e412ea44..3b540720eeb 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,6 +142,7 @@ 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 @@ -161,8 +164,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -253,6 +254,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,8 +265,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py index a1d74190199..d31b1fee492 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,6 +181,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +192,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -226,6 +226,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +237,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/aio/operations/_operation_group_one_operations.py index e88a42149fa..3335c32db1b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/aio/operations/_operation_group_one_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request if sys.version_info >= (3, 9): @@ -80,6 +82,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -90,8 +93,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/operations/_operation_group_one_operations.py index 5d9e895f7c3..775e0d70b2d 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -102,6 +104,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -112,8 +115,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py index d44697709d3..139cedcc01b 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,14 +21,16 @@ 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.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -89,6 +91,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,8 +102,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -143,6 +144,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -153,8 +155,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -290,6 +290,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -300,8 +301,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -360,6 +359,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -375,6 +375,7 @@ 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 @@ -396,8 +397,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -476,6 +475,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -486,8 +486,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_operation_group_one_operations.py index 42f5a57c152..772795102c0 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_operation_group_one_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -81,6 +83,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_multiapi_service_client_operations.py index 7c16cacc768..4b4b7787829 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_multiapi_service_client_operations.py @@ -21,15 +21,16 @@ ) 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.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -167,6 +168,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -221,6 +221,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,8 +232,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -365,6 +364,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -375,8 +375,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -435,6 +433,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,6 +449,7 @@ 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 @@ -471,8 +471,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -551,6 +549,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -561,8 +560,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_operation_group_one_operations.py index abf523f4020..d3642d91846 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/operations/_operation_group_one_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +104,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +115,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py index 2fb93a9da09..a1cf4362317 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_lro_and_paging_request, @@ -90,6 +92,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -144,6 +145,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -291,6 +291,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,8 +302,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -362,6 +361,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,6 +377,7 @@ 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 @@ -398,8 +399,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -478,6 +477,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -488,8 +488,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py index 45282e90abe..6b909c30028 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -82,6 +84,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,8 +95,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py index 9bda7201a81..151140b66b0 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,6 +169,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -222,6 +222,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +233,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -366,6 +365,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,8 +376,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -437,6 +435,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -452,6 +451,7 @@ 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 @@ -473,8 +473,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -553,6 +551,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -563,8 +562,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py index 40a3699fcdf..bd12c2d936c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,6 +105,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +116,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py index c323405e9e5..1eae7eead17 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import build_test_different_calls_request, build_test_one_request from .._vendor import MultiapiServiceClientMixinABC @@ -77,6 +79,7 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -137,6 +138,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,8 +149,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py index b0b5a2c98ad..2acfcc6d071 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import build_test_three_request, build_test_two_request from .._vendor import MultiapiServiceClientMixinABC @@ -135,6 +137,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +148,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -185,6 +186,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +197,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py index ff3aebc3161..af533360a28 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -87,6 +89,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py index 9e92ff499eb..75ee72e7d0d 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,6 +127,7 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any) -> _mo response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -186,6 +186,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py index b353783becc..405800b440c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,6 +180,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +191,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -229,6 +229,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +240,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py index 8e759e32863..8cac92a5466 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py @@ -18,14 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,6 +109,7 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,8 +120,6 @@ def test_four(self, parameter_one: bool, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py index 37fe9d2d6a3..d5032cfec97 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py @@ -20,13 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._multiapi_service_client_operations import ( build_test_different_calls_request, build_test_paging_request, @@ -77,6 +79,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -92,6 +95,7 @@ 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 @@ -113,8 +117,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -166,6 +168,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -176,8 +179,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py index f0f75989d75..859e77d95f8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_one_operations import ( build_test_operation_group_paging_request, build_test_two_request, @@ -91,6 +93,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -106,6 +109,7 @@ 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 @@ -127,8 +131,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -219,6 +221,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,8 +232,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py index 087333854cc..968205204e9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operation_group_two_operations import build_test_five_request, build_test_four_request from .._vendor import MultiapiServiceClientMixinABC @@ -136,6 +138,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +149,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -182,6 +183,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +194,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py index 1656e87ea52..518e11df628 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py @@ -20,14 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,6 +120,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -134,6 +136,7 @@ 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 @@ -155,8 +158,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -208,6 +209,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,8 +220,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py index 13be57028df..0cd9fdc8ae0 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,6 +126,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,6 +142,7 @@ 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 @@ -161,8 +164,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -253,6 +254,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,8 +265,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py index 5833bd4deae..da144e12350 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,6 +181,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,8 +192,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -226,6 +226,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +237,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/operations/_operations.py index 41597d9d2c7..b6af7d542e3 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/aio/operations/_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operations import ( build_multiapi_service_test_different_calls_request, build_multiapi_service_test_paging_request, @@ -129,6 +131,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -139,8 +142,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -183,6 +184,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -193,8 +195,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -234,6 +234,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -249,6 +250,7 @@ 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 @@ -270,8 +272,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -353,6 +353,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -363,8 +364,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -403,6 +402,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,8 +413,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -460,6 +458,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -470,8 +469,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -518,6 +515,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -528,8 +526,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -656,6 +652,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -671,6 +668,7 @@ 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 @@ -692,8 +690,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -790,6 +786,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -800,8 +797,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -848,6 +843,7 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -858,8 +854,6 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -903,6 +897,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -918,6 +913,7 @@ 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 @@ -939,8 +935,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/operations/_operations.py index 36db0ffe42c..451d8b0f8fd 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/operations/_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from .._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -174,6 +175,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -184,8 +186,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -228,6 +228,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +239,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -279,6 +278,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -294,6 +294,7 @@ 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 @@ -315,8 +316,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -437,6 +436,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -447,8 +447,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -487,6 +485,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -497,8 +496,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -644,6 +641,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -654,8 +652,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -702,6 +698,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -712,8 +709,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -839,6 +834,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -854,6 +850,7 @@ 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 @@ -875,8 +872,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -973,6 +968,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -983,8 +979,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1031,6 +1025,7 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1041,8 +1036,6 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1086,6 +1079,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1101,6 +1095,7 @@ 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 @@ -1122,8 +1117,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/operations/_operations.py index fd4ae202bd7..5487c50e713 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/aio/operations/_operations.py @@ -21,8 +21,9 @@ 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 AsyncHttpResponse, HttpRequest +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 @@ -30,6 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request from ...operations._operations import ( build_multiapi_service_test_different_calls_request, build_multiapi_service_test_lro_and_paging_request, @@ -91,6 +93,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -101,8 +104,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -145,6 +146,7 @@ async def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,8 +157,6 @@ async def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -293,6 +293,7 @@ async def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -303,8 +304,6 @@ async def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -364,6 +363,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -379,6 +379,7 @@ 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 @@ -400,8 +401,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -480,6 +479,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -490,8 +490,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -547,6 +545,7 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,8 +556,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/operations/_operations.py index 0c20c8c7cc0..9f24dd704da 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v1/operations/_operations.py @@ -21,8 +21,9 @@ ) 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, HttpResponse +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 @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -189,6 +190,7 @@ def test_one( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -199,8 +201,6 @@ def test_one( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -243,6 +243,7 @@ def _test_lro_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,8 +254,6 @@ def _test_lro_initial( response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -388,6 +387,7 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +398,6 @@ def _test_lro_and_paging_initial( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -459,6 +457,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -474,6 +473,7 @@ 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 @@ -495,8 +495,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -575,6 +573,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -585,8 +584,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -642,6 +639,7 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -652,8 +650,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/operations/_operations.py index f3c973a626a..b491366faeb 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/aio/operations/_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request from ...operations._operations import ( build_multiapi_service_test_different_calls_request, build_multiapi_service_test_one_request, @@ -84,6 +86,7 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -144,6 +145,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -263,6 +263,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -273,8 +274,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -313,6 +312,7 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -323,8 +323,6 @@ async def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -385,6 +383,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -395,8 +394,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/operations/_operations.py index a98bf3ab7b6..a0d13f2b3dc 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v2/operations/_operations.py @@ -19,14 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -190,6 +191,7 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -200,8 +202,6 @@ def test_one(self, *, id: int, message: Optional[str] = None, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -250,6 +250,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -260,8 +261,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -369,6 +368,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -379,8 +379,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -419,6 +417,7 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -429,8 +428,6 @@ def test_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -491,6 +488,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -501,8 +499,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/_vendor.py index 62c06452bbc..e4f41f72ec9 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from .._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultiapiServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/_vendor.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/_vendor.py index f5ac980a7cb..26b7d931df4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/_vendor.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/operations/_operations.py index 244f67b1af2..8e89514af11 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/aio/operations/_operations.py @@ -21,13 +21,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models +from ..._vendor import _convert_request from ...operations._operations import ( build_multiapi_service_test_different_calls_request, build_multiapi_service_test_paging_request, @@ -81,6 +83,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -96,6 +99,7 @@ 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 @@ -117,8 +121,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -171,6 +173,7 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -181,8 +184,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -239,6 +240,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -254,6 +256,7 @@ 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 @@ -275,8 +278,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -367,6 +368,7 @@ async def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -377,8 +379,6 @@ async def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -491,6 +491,7 @@ async def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -501,8 +502,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -537,6 +536,7 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -547,8 +547,6 @@ async def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/operations/_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/operations/_operations.py index beb8ca726c4..480e7b1e9f0 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/operations/_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/multiapicombiner/multiapicombiner/v3/operations/_operations.py @@ -21,14 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC +from .._vendor import MultiapiServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -199,6 +200,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -214,6 +216,7 @@ 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 @@ -235,8 +238,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -289,6 +290,7 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +301,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -357,6 +357,7 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -372,6 +373,7 @@ 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 @@ -393,8 +395,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -485,6 +485,7 @@ def test_two( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -495,8 +496,6 @@ def test_two( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -609,6 +608,7 @@ def test_four( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -619,8 +619,6 @@ def test_four( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -655,6 +653,7 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -665,8 +664,6 @@ def test_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py index a104b3f3b1d..fcdb13e4ce3 100644 --- a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py +++ b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py @@ -122,7 +122,7 @@ async def test_string(self, client, value_header): response = await client.header.response_string("null", cls=value_header) assert response == "null" # TODO This should be None response = await client.header.response_string("empty", cls=value_header) - assert response is None + assert response == "" @pytest.mark.asyncio async def test_enum(self, client, value_header): @@ -139,7 +139,7 @@ async def test_enum(self, client, value_header): # Here we now return empty string without failin **on purpose** # with pytest.raises(DeserializationError): response = await client.header.response_enum("null", cls=value_header) - assert response is None + assert response == "" @pytest.mark.asyncio async def test_date(self, client, value_header): diff --git a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_hooks.py b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_hooks.py index dbb78e096b7..5c6450501ad 100644 --- a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_hooks.py +++ b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_hooks.py @@ -35,7 +35,7 @@ def is_rest(obj): @pytest.mark.asyncio async def test_raw_request_hook(): def _callback(request): - assert is_rest(request.http_request) + assert not is_rest(request.http_request) assert hasattr(request.http_request, "set_multipart_mixed") raise ValueError("I entered the callback!") @@ -49,7 +49,7 @@ def _callback(request): @pytest.mark.asyncio async def test_raw_response_hook(): def _callback(response): - assert is_rest(response.http_response) + assert not is_rest(response.http_response) assert hasattr(response.http_response, "parts") raise ValueError("I entered the callback!") diff --git a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py index ed6c80edfef..b21e98d27de 100644 --- a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py +++ b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py @@ -26,7 +26,7 @@ import io import json -from azure.core.rest import HttpRequest +from azure.core.pipeline.transport import HttpRequest from os.path import dirname, pardir, join, realpath import pytest diff --git a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_hooks.py b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_hooks.py index 5ee10a42e87..28835c798e9 100644 --- a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_hooks.py +++ b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_hooks.py @@ -34,7 +34,7 @@ def is_rest(obj): def test_raw_request_hook(): def _callback(request): - assert is_rest(request.http_request) + assert not is_rest(request.http_request) assert hasattr(request.http_request, "set_multipart_mixed") raise ValueError("I entered the callback!") @@ -47,7 +47,7 @@ def _callback(request): def test_raw_response_hook(): def _callback(response): - assert is_rest(response.http_response) + assert not is_rest(response.http_response) assert hasattr(response.http_response, "parts") raise ValueError("I entered the callback!") diff --git a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_send_request.py b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_send_request.py index 3eb8d09f157..5b4e79e5b88 100644 --- a/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_send_request.py +++ b/packages/autorest.python/test/vanilla/legacy/AcceptanceTests/test_send_request.py @@ -26,7 +26,7 @@ import io import json -from azure.core.rest import HttpRequest +from azure.core.pipeline.transport import HttpRequest from os.path import dirname, pardir, join, realpath import pytest diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py index a3f2273eec8..cb47773374c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._pets_operations import ( build_create_ap_in_properties_request, build_create_ap_in_properties_with_ap_string_request, @@ -133,6 +135,7 @@ async def create_ap_true( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -143,8 +146,6 @@ async def create_ap_true( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -229,6 +230,7 @@ async def create_cat_ap_true( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -239,8 +241,6 @@ async def create_cat_ap_true( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -325,6 +325,7 @@ async def create_ap_object( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -335,8 +336,6 @@ async def create_ap_object( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -421,6 +420,7 @@ async def create_ap_string( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -431,8 +431,6 @@ async def create_ap_string( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -517,6 +515,7 @@ async def create_ap_in_properties( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -527,8 +526,6 @@ async def create_ap_in_properties( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -619,6 +616,7 @@ async def create_ap_in_properties_with_ap_string( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -629,8 +627,6 @@ async def create_ap_in_properties_with_ap_string( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py index 078ff62ba64..2e964d7390a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -231,6 +233,7 @@ def create_ap_true( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,8 +244,6 @@ def create_ap_true( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -327,6 +328,7 @@ def create_cat_ap_true( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -337,8 +339,6 @@ def create_cat_ap_true( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -423,6 +423,7 @@ def create_ap_object( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,8 +434,6 @@ def create_ap_object( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -519,6 +518,7 @@ def create_ap_string( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -529,8 +529,6 @@ def create_ap_string( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -615,6 +613,7 @@ def create_ap_in_properties( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -625,8 +624,6 @@ def create_ap_in_properties( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -717,6 +714,7 @@ def create_ap_in_properties_with_ap_string( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -727,8 +725,6 @@ def create_ap_in_properties_with_ap_string( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_vendor.py index dc910ddc7e5..d756d07f319 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AnythingClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_vendor.py index 29d65bdd121..2007e9f7a76 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py index f2671ee3f00..c6d091f4a40 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict +from ..._vendor import _convert_request from ...operations._anything_client_operations import ( build_get_array_request, build_get_object_request, @@ -68,6 +70,7 @@ async def get_object(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -78,8 +81,6 @@ async def get_object(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -123,6 +124,7 @@ async def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -133,8 +135,6 @@ async def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -166,6 +166,7 @@ async def get_string(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -176,8 +177,6 @@ async def get_string(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -221,6 +220,7 @@ async def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,8 +231,6 @@ async def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -264,6 +262,7 @@ async def get_array(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -274,8 +273,6 @@ async def get_array(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -319,6 +316,7 @@ async def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -329,8 +327,6 @@ async def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py index 16b288c25d8..5e68127ea9c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import AnythingClientMixinABC +from .._vendor import AnythingClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -148,6 +149,7 @@ def get_object(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -158,8 +160,6 @@ def get_object(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -203,6 +203,7 @@ def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -213,8 +214,6 @@ def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -246,6 +245,7 @@ def get_string(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,8 +256,6 @@ def get_string(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -301,6 +299,7 @@ def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,8 +310,6 @@ def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -344,6 +341,7 @@ def get_array(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -354,8 +352,6 @@ def get_array(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -399,6 +395,7 @@ def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -409,8 +406,6 @@ def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py index 4c30b70a174..e923f96ffe5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._array_operations import ( build_get_array_empty_request, build_get_array_item_empty_request, @@ -149,6 +151,7 @@ async def get_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -159,8 +162,6 @@ async def get_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +198,7 @@ async def get_invalid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +209,6 @@ async def get_invalid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -245,6 +245,7 @@ async def get_empty(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +256,6 @@ async def get_empty(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -341,6 +340,7 @@ async def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -351,8 +351,6 @@ async def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -385,6 +383,7 @@ async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -395,8 +394,6 @@ async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -481,6 +478,7 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +489,6 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -525,6 +521,7 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,8 +532,6 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -573,6 +568,7 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -583,8 +579,6 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -621,6 +615,7 @@ async def get_integer_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -631,8 +626,6 @@ async def get_integer_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -717,6 +710,7 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -727,8 +721,6 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -761,6 +753,7 @@ async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -771,8 +764,6 @@ async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -809,6 +800,7 @@ async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -819,8 +811,6 @@ async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -857,6 +847,7 @@ async def get_long_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -867,8 +858,6 @@ async def get_long_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -953,6 +942,7 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -963,8 +953,6 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -997,6 +985,7 @@ async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1007,8 +996,6 @@ async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1045,6 +1032,7 @@ async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1055,8 +1043,6 @@ async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1093,6 +1079,7 @@ async def get_float_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1103,8 +1090,6 @@ async def get_float_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1189,6 +1174,7 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1199,8 +1185,6 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1233,6 +1217,7 @@ async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1243,8 +1228,6 @@ async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1281,6 +1264,7 @@ async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1291,8 +1275,6 @@ async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1329,6 +1311,7 @@ async def get_double_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1339,8 +1322,6 @@ async def get_double_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1425,6 +1406,7 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1435,8 +1417,6 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1469,6 +1449,7 @@ async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1479,8 +1460,6 @@ async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1517,6 +1496,7 @@ async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1527,8 +1507,6 @@ async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1565,6 +1543,7 @@ async def get_string_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1575,8 +1554,6 @@ async def get_string_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1661,6 +1638,7 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1671,8 +1649,6 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1705,6 +1681,7 @@ async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1715,8 +1692,6 @@ async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1802,6 +1777,7 @@ async def put_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1812,8 +1788,6 @@ async def put_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1846,6 +1820,7 @@ async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models. headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1856,8 +1831,6 @@ async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models. response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1943,6 +1916,7 @@ async def put_string_enum_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1953,8 +1927,6 @@ async def put_string_enum_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1987,6 +1959,7 @@ async def get_string_with_null(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1997,8 +1970,6 @@ async def get_string_with_null(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2035,6 +2006,7 @@ async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2045,8 +2017,6 @@ async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2084,6 +2054,7 @@ async def get_uuid_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2094,8 +2065,6 @@ async def get_uuid_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2183,6 +2152,7 @@ async def put_uuid_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2193,8 +2163,6 @@ async def put_uuid_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2227,6 +2195,7 @@ async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2237,8 +2206,6 @@ async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2275,6 +2242,7 @@ async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2285,8 +2253,6 @@ async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2371,6 +2337,7 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2381,8 +2348,6 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2415,6 +2380,7 @@ async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2425,8 +2391,6 @@ async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2463,6 +2427,7 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2473,8 +2438,6 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2512,6 +2475,7 @@ async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2522,8 +2486,6 @@ async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2611,6 +2573,7 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2621,8 +2584,6 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2655,6 +2616,7 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2665,8 +2627,6 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2703,6 +2663,7 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.date headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2713,8 +2674,6 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.date response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2752,6 +2711,7 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.date headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2762,8 +2722,6 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.date response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2851,6 +2809,7 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2861,8 +2820,6 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2895,6 +2852,7 @@ async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2905,8 +2863,6 @@ async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2991,6 +2947,7 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3001,8 +2958,6 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3036,6 +2991,7 @@ async def get_byte_valid(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3046,8 +3002,6 @@ async def get_byte_valid(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3135,6 +3089,7 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3145,8 +3100,6 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3179,6 +3132,7 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3189,8 +3143,6 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3228,6 +3180,7 @@ async def get_base64_url(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3238,8 +3191,6 @@ async def get_base64_url(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3276,6 +3227,7 @@ async def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3286,8 +3238,6 @@ async def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3324,6 +3274,7 @@ async def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3334,8 +3285,6 @@ async def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3373,6 +3322,7 @@ async def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3383,8 +3333,6 @@ async def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3422,6 +3370,7 @@ async def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3432,8 +3381,6 @@ async def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3471,6 +3418,7 @@ async def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3481,8 +3429,6 @@ async def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3570,6 +3516,7 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3580,8 +3527,6 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3614,6 +3559,7 @@ async def get_array_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3624,8 +3570,6 @@ async def get_array_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3662,6 +3606,7 @@ async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3672,8 +3617,6 @@ async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3710,6 +3653,7 @@ async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3720,8 +3664,6 @@ async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3758,6 +3700,7 @@ async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3768,8 +3711,6 @@ async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3806,6 +3747,7 @@ async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3816,8 +3758,6 @@ async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3902,6 +3842,7 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3912,8 +3853,6 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3946,6 +3885,7 @@ async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3956,8 +3896,6 @@ async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3994,6 +3932,7 @@ async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4004,8 +3943,6 @@ async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4043,6 +3980,7 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4053,8 +3991,6 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4092,6 +4028,7 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4102,8 +4039,6 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4141,6 +4076,7 @@ async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4151,8 +4087,6 @@ async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4240,6 +4174,7 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4250,8 +4185,6 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py index fbc69cb7f08..3fb751cd1ed 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -1102,6 +1104,7 @@ def get_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1112,8 +1115,6 @@ def get_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1150,6 +1151,7 @@ def get_invalid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1160,8 +1162,6 @@ def get_invalid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1198,6 +1198,7 @@ def get_empty(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1208,8 +1209,6 @@ def get_empty(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1294,6 +1293,7 @@ def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1304,8 +1304,6 @@ def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1338,6 +1336,7 @@ def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1348,8 +1347,6 @@ def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1434,6 +1431,7 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1444,8 +1442,6 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1478,6 +1474,7 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1488,8 +1485,6 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1526,6 +1521,7 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1536,8 +1532,6 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1574,6 +1568,7 @@ def get_integer_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1584,8 +1579,6 @@ def get_integer_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1670,6 +1663,7 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1680,8 +1674,6 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1714,6 +1706,7 @@ def get_int_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1724,8 +1717,6 @@ def get_int_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1762,6 +1753,7 @@ def get_int_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1772,8 +1764,6 @@ def get_int_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1810,6 +1800,7 @@ def get_long_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1820,8 +1811,6 @@ def get_long_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1906,6 +1895,7 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1916,8 +1906,6 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1950,6 +1938,7 @@ def get_long_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1960,8 +1949,6 @@ def get_long_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1998,6 +1985,7 @@ def get_long_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2008,8 +1996,6 @@ def get_long_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2046,6 +2032,7 @@ def get_float_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2056,8 +2043,6 @@ def get_float_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2142,6 +2127,7 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2152,8 +2138,6 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2186,6 +2170,7 @@ def get_float_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2196,8 +2181,6 @@ def get_float_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2234,6 +2217,7 @@ def get_float_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2244,8 +2228,6 @@ def get_float_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2282,6 +2264,7 @@ def get_double_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2292,8 +2275,6 @@ def get_double_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2378,6 +2359,7 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2388,8 +2370,6 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2422,6 +2402,7 @@ def get_double_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2432,8 +2413,6 @@ def get_double_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2470,6 +2449,7 @@ def get_double_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2480,8 +2460,6 @@ def get_double_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2518,6 +2496,7 @@ def get_string_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2528,8 +2507,6 @@ def get_string_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2614,6 +2591,7 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2624,8 +2602,6 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2658,6 +2634,7 @@ def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2668,8 +2645,6 @@ def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2755,6 +2730,7 @@ def put_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2765,8 +2741,6 @@ def put_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2799,6 +2773,7 @@ def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.Enum0] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2809,8 +2784,6 @@ def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.Enum0] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2896,6 +2869,7 @@ def put_string_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2906,8 +2880,6 @@ def put_string_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2940,6 +2912,7 @@ def get_string_with_null(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2950,8 +2923,6 @@ def get_string_with_null(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2988,6 +2959,7 @@ def get_string_with_invalid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2998,8 +2970,6 @@ def get_string_with_invalid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3037,6 +3007,7 @@ def get_uuid_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3047,8 +3018,6 @@ def get_uuid_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3136,6 +3105,7 @@ def put_uuid_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3146,8 +3116,6 @@ def put_uuid_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3180,6 +3148,7 @@ def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3190,8 +3159,6 @@ def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3228,6 +3195,7 @@ def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3238,8 +3206,6 @@ def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3324,6 +3290,7 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3334,8 +3301,6 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3368,6 +3333,7 @@ def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3378,8 +3344,6 @@ def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3416,6 +3380,7 @@ def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3426,8 +3391,6 @@ def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3465,6 +3428,7 @@ def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3475,8 +3439,6 @@ def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3564,6 +3526,7 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3574,8 +3537,6 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3608,6 +3569,7 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3618,8 +3580,6 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3656,6 +3616,7 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3666,8 +3627,6 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3705,6 +3664,7 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3715,8 +3675,6 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3804,6 +3762,7 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3814,8 +3773,6 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3848,6 +3805,7 @@ def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3858,8 +3816,6 @@ def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3944,6 +3900,7 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3954,8 +3911,6 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3989,6 +3944,7 @@ def get_byte_valid(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3999,8 +3955,6 @@ def get_byte_valid(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4088,6 +4042,7 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4098,8 +4053,6 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4132,6 +4085,7 @@ def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4142,8 +4096,6 @@ def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4181,6 +4133,7 @@ def get_base64_url(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4191,8 +4144,6 @@ def get_base64_url(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4229,6 +4180,7 @@ def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4239,8 +4191,6 @@ def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4277,6 +4227,7 @@ def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4287,8 +4238,6 @@ def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4326,6 +4275,7 @@ def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4336,8 +4286,6 @@ def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4375,6 +4323,7 @@ def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4385,8 +4334,6 @@ def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4424,6 +4371,7 @@ def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4434,8 +4382,6 @@ def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4523,6 +4469,7 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4533,8 +4480,6 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4567,6 +4512,7 @@ def get_array_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4577,8 +4523,6 @@ def get_array_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4615,6 +4559,7 @@ def get_array_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4625,8 +4570,6 @@ def get_array_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4663,6 +4606,7 @@ def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4673,8 +4617,6 @@ def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4711,6 +4653,7 @@ def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4721,8 +4664,6 @@ def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4759,6 +4700,7 @@ def get_array_valid(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4769,8 +4711,6 @@ def get_array_valid(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4855,6 +4795,7 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4865,8 +4806,6 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4899,6 +4838,7 @@ def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4909,8 +4849,6 @@ def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4947,6 +4885,7 @@ def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4957,8 +4896,6 @@ def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4996,6 +4933,7 @@ def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5006,8 +4944,6 @@ def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5045,6 +4981,7 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5055,8 +4992,6 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5094,6 +5029,7 @@ def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5104,8 +5040,6 @@ def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5193,6 +5127,7 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5203,8 +5138,6 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py index 30d742e8ccf..a8c57560ecb 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._array_operations import ( build_get_array_empty_request, build_get_array_item_empty_request, @@ -149,6 +151,7 @@ async def get_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -159,8 +162,6 @@ async def get_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +198,7 @@ async def get_invalid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +209,6 @@ async def get_invalid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -245,6 +245,7 @@ async def get_empty(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +256,6 @@ async def get_empty(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -341,6 +340,7 @@ async def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -351,8 +351,6 @@ async def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -385,6 +383,7 @@ async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -395,8 +394,6 @@ async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -481,6 +478,7 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +489,6 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -525,6 +521,7 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,8 +532,6 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -573,6 +568,7 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -583,8 +579,6 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -621,6 +615,7 @@ async def get_integer_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -631,8 +626,6 @@ async def get_integer_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -717,6 +710,7 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -727,8 +721,6 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -761,6 +753,7 @@ async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -771,8 +764,6 @@ async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -809,6 +800,7 @@ async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -819,8 +811,6 @@ async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -857,6 +847,7 @@ async def get_long_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -867,8 +858,6 @@ async def get_long_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -953,6 +942,7 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -963,8 +953,6 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -997,6 +985,7 @@ async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1007,8 +996,6 @@ async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1045,6 +1032,7 @@ async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1055,8 +1043,6 @@ async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1093,6 +1079,7 @@ async def get_float_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1103,8 +1090,6 @@ async def get_float_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1189,6 +1174,7 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1199,8 +1185,6 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1233,6 +1217,7 @@ async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1243,8 +1228,6 @@ async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1281,6 +1264,7 @@ async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1291,8 +1275,6 @@ async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1329,6 +1311,7 @@ async def get_double_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1339,8 +1322,6 @@ async def get_double_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1425,6 +1406,7 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1435,8 +1417,6 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1469,6 +1449,7 @@ async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1479,8 +1460,6 @@ async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1517,6 +1496,7 @@ async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1527,8 +1507,6 @@ async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1565,6 +1543,7 @@ async def get_string_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1575,8 +1554,6 @@ async def get_string_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1661,6 +1638,7 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1671,8 +1649,6 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1705,6 +1681,7 @@ async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1715,8 +1692,6 @@ async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1802,6 +1777,7 @@ async def put_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1812,8 +1788,6 @@ async def put_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1846,6 +1820,7 @@ async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models. headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1856,8 +1831,6 @@ async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models. response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1943,6 +1916,7 @@ async def put_string_enum_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1953,8 +1927,6 @@ async def put_string_enum_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1987,6 +1959,7 @@ async def get_string_with_null(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1997,8 +1970,6 @@ async def get_string_with_null(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2035,6 +2006,7 @@ async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2045,8 +2017,6 @@ async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2084,6 +2054,7 @@ async def get_uuid_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2094,8 +2065,6 @@ async def get_uuid_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2183,6 +2152,7 @@ async def put_uuid_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2193,8 +2163,6 @@ async def put_uuid_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2227,6 +2195,7 @@ async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2237,8 +2206,6 @@ async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2275,6 +2242,7 @@ async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2285,8 +2253,6 @@ async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2371,6 +2337,7 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2381,8 +2348,6 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2415,6 +2380,7 @@ async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2425,8 +2391,6 @@ async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2463,6 +2427,7 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2473,8 +2438,6 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2512,6 +2475,7 @@ async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2522,8 +2486,6 @@ async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2611,6 +2573,7 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2621,8 +2584,6 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2655,6 +2616,7 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2665,8 +2627,6 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2703,6 +2663,7 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.date headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2713,8 +2674,6 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.date response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2752,6 +2711,7 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.date headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2762,8 +2722,6 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.date response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2851,6 +2809,7 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2861,8 +2820,6 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2895,6 +2852,7 @@ async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2905,8 +2863,6 @@ async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2991,6 +2947,7 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3001,8 +2958,6 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3036,6 +2991,7 @@ async def get_byte_valid(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3046,8 +3002,6 @@ async def get_byte_valid(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3135,6 +3089,7 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3145,8 +3100,6 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3179,6 +3132,7 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3189,8 +3143,6 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3228,6 +3180,7 @@ async def get_base64_url(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3238,8 +3191,6 @@ async def get_base64_url(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3276,6 +3227,7 @@ async def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3286,8 +3238,6 @@ async def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3324,6 +3274,7 @@ async def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3334,8 +3285,6 @@ async def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3373,6 +3322,7 @@ async def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3383,8 +3333,6 @@ async def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3422,6 +3370,7 @@ async def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3432,8 +3381,6 @@ async def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3471,6 +3418,7 @@ async def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3481,8 +3429,6 @@ async def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3570,6 +3516,7 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3580,8 +3527,6 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3614,6 +3559,7 @@ async def get_array_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3624,8 +3570,6 @@ async def get_array_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3662,6 +3606,7 @@ async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3672,8 +3617,6 @@ async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3710,6 +3653,7 @@ async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3720,8 +3664,6 @@ async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3758,6 +3700,7 @@ async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3768,8 +3711,6 @@ async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3806,6 +3747,7 @@ async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3816,8 +3758,6 @@ async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3902,6 +3842,7 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3912,8 +3853,6 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3946,6 +3885,7 @@ async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3956,8 +3896,6 @@ async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3994,6 +3932,7 @@ async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4004,8 +3943,6 @@ async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4043,6 +3980,7 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4053,8 +3991,6 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4092,6 +4028,7 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4102,8 +4039,6 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4141,6 +4076,7 @@ async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4151,8 +4087,6 @@ async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4240,6 +4174,7 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4250,8 +4185,6 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py index 65ece63c583..9b087ca2058 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -1102,6 +1104,7 @@ def get_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1112,8 +1115,6 @@ def get_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1150,6 +1151,7 @@ def get_invalid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1160,8 +1162,6 @@ def get_invalid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1198,6 +1198,7 @@ def get_empty(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1208,8 +1209,6 @@ def get_empty(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1294,6 +1293,7 @@ def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1304,8 +1304,6 @@ def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1338,6 +1336,7 @@ def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1348,8 +1347,6 @@ def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1434,6 +1431,7 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1444,8 +1442,6 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1478,6 +1474,7 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1488,8 +1485,6 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1526,6 +1521,7 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1536,8 +1532,6 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1574,6 +1568,7 @@ def get_integer_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1584,8 +1579,6 @@ def get_integer_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1670,6 +1663,7 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1680,8 +1674,6 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1714,6 +1706,7 @@ def get_int_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1724,8 +1717,6 @@ def get_int_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1762,6 +1753,7 @@ def get_int_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1772,8 +1764,6 @@ def get_int_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1810,6 +1800,7 @@ def get_long_valid(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1820,8 +1811,6 @@ def get_long_valid(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1906,6 +1895,7 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1916,8 +1906,6 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1950,6 +1938,7 @@ def get_long_invalid_null(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1960,8 +1949,6 @@ def get_long_invalid_null(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1998,6 +1985,7 @@ def get_long_invalid_string(self, **kwargs: Any) -> List[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2008,8 +1996,6 @@ def get_long_invalid_string(self, **kwargs: Any) -> List[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2046,6 +2032,7 @@ def get_float_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2056,8 +2043,6 @@ def get_float_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2142,6 +2127,7 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2152,8 +2138,6 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2186,6 +2170,7 @@ def get_float_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2196,8 +2181,6 @@ def get_float_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2234,6 +2217,7 @@ def get_float_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2244,8 +2228,6 @@ def get_float_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2282,6 +2264,7 @@ def get_double_valid(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2292,8 +2275,6 @@ def get_double_valid(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2378,6 +2359,7 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2388,8 +2370,6 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2422,6 +2402,7 @@ def get_double_invalid_null(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2432,8 +2413,6 @@ def get_double_invalid_null(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2470,6 +2449,7 @@ def get_double_invalid_string(self, **kwargs: Any) -> List[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2480,8 +2460,6 @@ def get_double_invalid_string(self, **kwargs: Any) -> List[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2518,6 +2496,7 @@ def get_string_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2528,8 +2507,6 @@ def get_string_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2614,6 +2591,7 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2624,8 +2602,6 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2658,6 +2634,7 @@ def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2668,8 +2645,6 @@ def get_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.FooEnum]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2755,6 +2730,7 @@ def put_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2765,8 +2741,6 @@ def put_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2799,6 +2773,7 @@ def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.Enum0] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2809,8 +2784,6 @@ def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, _models.Enum0] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2896,6 +2869,7 @@ def put_string_enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2906,8 +2880,6 @@ def put_string_enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2940,6 +2912,7 @@ def get_string_with_null(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2950,8 +2923,6 @@ def get_string_with_null(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2988,6 +2959,7 @@ def get_string_with_invalid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2998,8 +2970,6 @@ def get_string_with_invalid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3037,6 +3007,7 @@ def get_uuid_valid(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3047,8 +3018,6 @@ def get_uuid_valid(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3136,6 +3105,7 @@ def put_uuid_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3146,8 +3116,6 @@ def put_uuid_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3180,6 +3148,7 @@ def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3190,8 +3159,6 @@ def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3228,6 +3195,7 @@ def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3238,8 +3206,6 @@ def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3324,6 +3290,7 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3334,8 +3301,6 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3368,6 +3333,7 @@ def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3378,8 +3344,6 @@ def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3416,6 +3380,7 @@ def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3426,8 +3391,6 @@ def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3465,6 +3428,7 @@ def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3475,8 +3439,6 @@ def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3564,6 +3526,7 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3574,8 +3537,6 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3608,6 +3569,7 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3618,8 +3580,6 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3656,6 +3616,7 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3666,8 +3627,6 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3705,6 +3664,7 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3715,8 +3675,6 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3804,6 +3762,7 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3814,8 +3773,6 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3848,6 +3805,7 @@ def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3858,8 +3816,6 @@ def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3944,6 +3900,7 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3954,8 +3911,6 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3989,6 +3944,7 @@ def get_byte_valid(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3999,8 +3955,6 @@ def get_byte_valid(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4088,6 +4042,7 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4098,8 +4053,6 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4132,6 +4085,7 @@ def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4142,8 +4096,6 @@ def get_byte_invalid_null(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4181,6 +4133,7 @@ def get_base64_url(self, **kwargs: Any) -> List[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4191,8 +4144,6 @@ def get_base64_url(self, **kwargs: Any) -> List[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4229,6 +4180,7 @@ def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4239,8 +4191,6 @@ def get_complex_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4277,6 +4227,7 @@ def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4287,8 +4238,6 @@ def get_complex_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4326,6 +4275,7 @@ def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4336,8 +4286,6 @@ def get_complex_item_null(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4375,6 +4323,7 @@ def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4385,8 +4334,6 @@ def get_complex_item_empty(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4424,6 +4371,7 @@ def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4434,8 +4382,6 @@ def get_complex_valid(self, **kwargs: Any) -> List[_models.Product]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4523,6 +4469,7 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4533,8 +4480,6 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4567,6 +4512,7 @@ def get_array_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4577,8 +4523,6 @@ def get_array_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4615,6 +4559,7 @@ def get_array_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4625,8 +4570,6 @@ def get_array_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4663,6 +4606,7 @@ def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4673,8 +4617,6 @@ def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4711,6 +4653,7 @@ def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4721,8 +4664,6 @@ def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4759,6 +4700,7 @@ def get_array_valid(self, **kwargs: Any) -> List[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4769,8 +4711,6 @@ def get_array_valid(self, **kwargs: Any) -> List[List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4855,6 +4795,7 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4865,8 +4806,6 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4899,6 +4838,7 @@ def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4909,8 +4849,6 @@ def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4947,6 +4885,7 @@ def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4957,8 +4896,6 @@ def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4996,6 +4933,7 @@ def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5006,8 +4944,6 @@ def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5045,6 +4981,7 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5055,8 +4992,6 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5094,6 +5029,7 @@ def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5104,8 +5040,6 @@ def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -5193,6 +5127,7 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5203,8 +5138,6 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_download_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_download_operations.py index c3e8fd4212c..b216f6ab6b5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_download_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_download_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._download_operations import build_error_stream_request if sys.version_info >= (3, 9): @@ -76,6 +78,7 @@ async def error_stream(self, **kwargs: Any) -> AsyncIterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -86,8 +89,6 @@ async def error_stream(self, **kwargs: Any) -> AsyncIterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_upload_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_upload_operations.py index 6e254733009..089728539de 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_upload_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/aio/operations/_upload_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._upload_operations import build_binary_request, build_file_request if sys.version_info >= (3, 9): @@ -86,6 +88,7 @@ async def file( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def file( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -138,6 +139,7 @@ async def binary( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,8 +150,6 @@ async def binary( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_download_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_download_operations.py index 46b6e1fc78e..be598b602d7 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_download_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_download_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -94,6 +96,7 @@ def error_stream(self, **kwargs: Any) -> Iterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -104,8 +107,6 @@ def error_stream(self, **kwargs: Any) -> Iterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_upload_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_upload_operations.py index 1ce2a01cd3b..f8b0ff9e181 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_upload_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/operations/_upload_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -115,6 +117,7 @@ def file(self, file_param: IO[bytes], **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -125,8 +128,6 @@ def file(self, file_param: IO[bytes], **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -165,6 +166,7 @@ def binary(self, file_param: IO[bytes], **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +177,6 @@ def binary(self, file_param: IO[bytes], **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py index 89b0b7acb14..98dd0493957 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._bool_operations import ( build_get_false_request, build_get_invalid_request, @@ -84,6 +86,7 @@ async def get_true(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_true(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -138,6 +139,7 @@ async def put_true(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,8 +150,6 @@ async def put_true(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -182,6 +182,7 @@ async def get_false(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +193,6 @@ async def get_false(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -236,6 +235,7 @@ async def put_false(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -246,8 +246,6 @@ async def put_false(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -280,6 +278,7 @@ async def get_null(self, **kwargs: Any) -> Optional[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -290,8 +289,6 @@ async def get_null(self, **kwargs: Any) -> Optional[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -328,6 +325,7 @@ async def get_invalid(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -338,8 +336,6 @@ async def get_invalid(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py index 7d4cd9e0f28..601c4a091f9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -172,6 +174,7 @@ def get_true(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -182,8 +185,6 @@ def get_true(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -226,6 +227,7 @@ def put_true(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,8 +238,6 @@ def put_true(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -270,6 +270,7 @@ def get_false(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -280,8 +281,6 @@ def get_false(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -324,6 +323,7 @@ def put_false(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -334,8 +334,6 @@ def put_false(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -368,6 +366,7 @@ def get_null(self, **kwargs: Any) -> Optional[bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -378,8 +377,6 @@ def get_null(self, **kwargs: Any) -> Optional[bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -416,6 +413,7 @@ def get_invalid(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -426,8 +424,6 @@ def get_invalid(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py index b3123f27d88..bc083defa5a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._byte_operations import ( build_get_empty_request, build_get_invalid_request, @@ -83,6 +85,7 @@ async def get_null(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -93,8 +96,6 @@ async def get_null(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -131,6 +132,7 @@ async def get_empty(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -141,8 +143,6 @@ async def get_empty(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -179,6 +179,7 @@ async def get_non_ascii(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +190,6 @@ async def get_non_ascii(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -237,6 +236,7 @@ async def put_non_ascii( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,8 +247,6 @@ async def put_non_ascii( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -281,6 +279,7 @@ async def get_invalid(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,8 +290,6 @@ async def get_invalid(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py index bfab437ebfb..8bc2a8b282b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -153,6 +155,7 @@ def get_null(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -163,8 +166,6 @@ def get_null(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -201,6 +202,7 @@ def get_empty(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -211,8 +213,6 @@ def get_empty(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -249,6 +249,7 @@ def get_non_ascii(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,8 +260,6 @@ def get_non_ascii(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -305,6 +304,7 @@ def put_non_ascii(self, byte_body: bytes, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,8 +315,6 @@ def put_non_ascii(self, byte_body: bytes, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -349,6 +347,7 @@ def get_invalid(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -359,8 +358,6 @@ def get_invalid(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py index 2d095c3a299..cb57ae50e81 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._byte_operations import ( build_get_empty_request, build_get_invalid_request, @@ -83,6 +85,7 @@ async def get_null(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -93,8 +96,6 @@ async def get_null(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -131,6 +132,7 @@ async def get_empty(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -141,8 +143,6 @@ async def get_empty(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -179,6 +179,7 @@ async def get_non_ascii(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,8 +190,6 @@ async def get_non_ascii(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -237,6 +236,7 @@ async def put_non_ascii( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,8 +247,6 @@ async def put_non_ascii( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -281,6 +279,7 @@ async def get_invalid(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,8 +290,6 @@ async def get_invalid(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py index 11ba7173c5a..6265e6f9eb6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -153,6 +155,7 @@ def get_null(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -163,8 +166,6 @@ def get_null(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -201,6 +202,7 @@ def get_empty(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -211,8 +213,6 @@ def get_empty(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -249,6 +249,7 @@ def get_non_ascii(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,8 +260,6 @@ def get_non_ascii(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -305,6 +304,7 @@ def put_non_ascii(self, byte_body: bytes, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,8 +315,6 @@ def put_non_ascii(self, byte_body: bytes, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -349,6 +347,7 @@ def get_invalid(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -359,8 +358,6 @@ def get_invalid(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py index c676fa1cc28..04f754b7055 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._array_operations import ( build_get_empty_request, build_get_not_provided_request, @@ -83,6 +85,7 @@ async def get_valid(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -93,8 +96,6 @@ async def get_valid(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -141,6 +142,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -151,8 +153,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -185,6 +185,7 @@ async def get_empty(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,8 +196,6 @@ async def get_empty(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -243,6 +242,7 @@ async def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,8 +253,6 @@ async def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -287,6 +285,7 @@ async def get_not_provided(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -297,8 +296,6 @@ async def get_not_provided(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py index 05517577252..c082f2ab325 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._basic_operations import ( build_get_empty_request, build_get_invalid_request, @@ -85,6 +87,7 @@ async def get_valid(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def get_valid(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +185,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +196,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -228,6 +228,7 @@ async def get_invalid(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +239,6 @@ async def get_invalid(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -276,6 +275,7 @@ async def get_empty(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -286,8 +286,6 @@ async def get_empty(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -324,6 +322,7 @@ async def get_null(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -334,8 +333,6 @@ async def get_null(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -372,6 +369,7 @@ async def get_not_provided(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -382,8 +380,6 @@ async def get_not_provided(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py index b5b49f73f9e..f456ddd90ea 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._dictionary_operations import ( build_get_empty_request, build_get_not_provided_request, @@ -84,6 +86,7 @@ async def get_valid(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_valid(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -142,6 +143,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -186,6 +186,7 @@ async def get_empty(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ async def get_empty(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -244,6 +243,7 @@ async def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -254,8 +254,6 @@ async def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -288,6 +286,7 @@ async def get_null(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -298,8 +297,6 @@ async def get_null(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -336,6 +333,7 @@ async def get_not_provided(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -346,8 +344,6 @@ async def get_not_provided(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py index d40e26e319c..7e7386e10dd 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._flattencomplex_operations import build_get_valid_request if sys.version_info >= (3, 9): @@ -76,6 +78,7 @@ async def get_valid(self, **kwargs: Any) -> _models.MyBaseType: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -86,8 +89,6 @@ async def get_valid(self, **kwargs: Any) -> _models.MyBaseType: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py index 71192ed5a77..20e03b97f05 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._inheritance_operations import build_get_valid_request, build_put_valid_request if sys.version_info >= (3, 9): @@ -78,6 +80,7 @@ async def get_valid(self, **kwargs: Any) -> _models.Siamese: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -88,8 +91,6 @@ async def get_valid(self, **kwargs: Any) -> _models.Siamese: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -181,6 +182,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,8 +193,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py index bc3ec5c2a19..7b2d91b5d2c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._polymorphicrecursive_operations import build_get_valid_request, build_put_valid_request if sys.version_info >= (3, 9): @@ -78,6 +80,7 @@ async def get_valid(self, **kwargs: Any) -> _models.Fish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -88,8 +91,6 @@ async def get_valid(self, **kwargs: Any) -> _models.Fish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -330,6 +331,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -340,8 +342,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py index 6baddadf8b4..0612fdcc65a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._polymorphism_operations import ( build_get_complicated_request, build_get_composed_with_discriminator_request, @@ -88,6 +90,7 @@ async def get_valid(self, **kwargs: Any) -> _models.Fish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -98,8 +101,6 @@ async def get_valid(self, **kwargs: Any) -> _models.Fish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -280,6 +281,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -290,8 +292,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -324,6 +324,7 @@ async def get_dot_syntax(self, **kwargs: Any) -> _models.DotFish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -334,8 +335,6 @@ async def get_dot_syntax(self, **kwargs: Any) -> _models.DotFish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -374,6 +373,7 @@ async def get_composed_with_discriminator(self, **kwargs: Any) -> _models.DotFis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -384,8 +384,6 @@ async def get_composed_with_discriminator(self, **kwargs: Any) -> _models.DotFis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -424,6 +422,7 @@ async def get_composed_without_discriminator(self, **kwargs: Any) -> _models.Dot headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -434,8 +433,6 @@ async def get_composed_without_discriminator(self, **kwargs: Any) -> _models.Dot response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -473,6 +470,7 @@ async def get_complicated(self, **kwargs: Any) -> _models.Salmon: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -483,8 +481,6 @@ async def get_complicated(self, **kwargs: Any) -> _models.Salmon: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -572,6 +568,7 @@ async def put_complicated( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -582,8 +579,6 @@ async def put_complicated( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -664,6 +659,7 @@ async def put_missing_discriminator( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -674,8 +670,6 @@ async def put_missing_discriminator( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -841,6 +835,7 @@ async def put_valid_missing_required( # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -851,8 +846,6 @@ async def put_valid_missing_required( # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py index 68257f54a30..96e9660f005 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._primitive_operations import ( build_get_bool_request, build_get_byte_request, @@ -102,6 +104,7 @@ async def get_int(self, **kwargs: Any) -> _models.IntWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -112,8 +115,6 @@ async def get_int(self, **kwargs: Any) -> _models.IntWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -199,6 +200,7 @@ async def put_int( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,8 +211,6 @@ async def put_int( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -243,6 +243,7 @@ async def get_long(self, **kwargs: Any) -> _models.LongWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,8 +254,6 @@ async def get_long(self, **kwargs: Any) -> _models.LongWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -340,6 +339,7 @@ async def put_long( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -350,8 +350,6 @@ async def put_long( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -384,6 +382,7 @@ async def get_float(self, **kwargs: Any) -> _models.FloatWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -394,8 +393,6 @@ async def get_float(self, **kwargs: Any) -> _models.FloatWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -481,6 +478,7 @@ async def put_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +489,6 @@ async def put_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -525,6 +521,7 @@ async def get_double(self, **kwargs: Any) -> _models.DoubleWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,8 +532,6 @@ async def get_double(self, **kwargs: Any) -> _models.DoubleWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -625,6 +620,7 @@ async def put_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -635,8 +631,6 @@ async def put_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -669,6 +663,7 @@ async def get_bool(self, **kwargs: Any) -> _models.BooleanWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -679,8 +674,6 @@ async def get_bool(self, **kwargs: Any) -> _models.BooleanWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -766,6 +759,7 @@ async def put_bool( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -776,8 +770,6 @@ async def put_bool( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -810,6 +802,7 @@ async def get_string(self, **kwargs: Any) -> _models.StringWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -820,8 +813,6 @@ async def get_string(self, **kwargs: Any) -> _models.StringWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -907,6 +898,7 @@ async def put_string( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -917,8 +909,6 @@ async def put_string( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -951,6 +941,7 @@ async def get_date(self, **kwargs: Any) -> _models.DateWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -961,8 +952,6 @@ async def get_date(self, **kwargs: Any) -> _models.DateWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1048,6 +1037,7 @@ async def put_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1058,8 +1048,6 @@ async def put_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1092,6 +1080,7 @@ async def get_date_time(self, **kwargs: Any) -> _models.DatetimeWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1102,8 +1091,6 @@ async def get_date_time(self, **kwargs: Any) -> _models.DatetimeWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1191,6 +1178,7 @@ async def put_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1201,8 +1189,6 @@ async def put_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1235,6 +1221,7 @@ async def get_date_time_rfc1123(self, **kwargs: Any) -> _models.Datetimerfc1123W headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1245,8 +1232,6 @@ async def get_date_time_rfc1123(self, **kwargs: Any) -> _models.Datetimerfc1123W response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1334,6 +1319,7 @@ async def put_date_time_rfc1123( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1344,8 +1330,6 @@ async def put_date_time_rfc1123( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1378,6 +1362,7 @@ async def get_duration(self, **kwargs: Any) -> _models.DurationWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1388,8 +1373,6 @@ async def get_duration(self, **kwargs: Any) -> _models.DurationWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1436,6 +1419,7 @@ async def put_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1446,8 +1430,6 @@ async def put_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1480,6 +1462,7 @@ async def get_byte(self, **kwargs: Any) -> _models.ByteWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1490,8 +1473,6 @@ async def get_byte(self, **kwargs: Any) -> _models.ByteWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1538,6 +1519,7 @@ async def put_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1548,8 +1530,6 @@ async def put_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py index 82cc08fd447..2005b225849 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._readonlyproperty_operations import build_get_valid_request, build_put_valid_request if sys.version_info >= (3, 9): @@ -77,6 +79,7 @@ async def get_valid(self, **kwargs: Any) -> _models.ReadonlyObj: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +90,6 @@ async def get_valid(self, **kwargs: Any) -> _models.ReadonlyObj: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -135,6 +136,7 @@ async def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +147,6 @@ async def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py index 2f5f9d11f10..fcc616dc728 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -156,6 +158,7 @@ def get_valid(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -166,8 +169,6 @@ def get_valid(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -214,6 +215,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -224,8 +226,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -258,6 +258,7 @@ def get_empty(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -268,8 +269,6 @@ def get_empty(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -316,6 +315,7 @@ def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -326,8 +326,6 @@ def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -360,6 +358,7 @@ def get_not_provided(self, **kwargs: Any) -> _models.ArrayWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -370,8 +369,6 @@ def get_not_provided(self, **kwargs: Any) -> _models.ArrayWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py index b27efa9cecb..42e8c69f3d7 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -173,6 +175,7 @@ def get_valid(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -183,8 +186,6 @@ def get_valid(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -272,6 +273,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -282,8 +284,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -316,6 +316,7 @@ def get_invalid(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -326,8 +327,6 @@ def get_invalid(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -364,6 +363,7 @@ def get_empty(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -374,8 +374,6 @@ def get_empty(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -412,6 +410,7 @@ def get_null(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -422,8 +421,6 @@ def get_null(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -460,6 +457,7 @@ def get_not_provided(self, **kwargs: Any) -> _models.Basic: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -470,8 +468,6 @@ def get_not_provided(self, **kwargs: Any) -> _models.Basic: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py index 85d629f25da..cb46112d994 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -170,6 +172,7 @@ def get_valid(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -180,8 +183,6 @@ def get_valid(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -228,6 +229,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,8 +240,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -272,6 +272,7 @@ def get_empty(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -282,8 +283,6 @@ def get_empty(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -330,6 +329,7 @@ def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -340,8 +340,6 @@ def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -374,6 +372,7 @@ def get_null(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -384,8 +383,6 @@ def get_null(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -422,6 +419,7 @@ def get_not_provided(self, **kwargs: Any) -> _models.DictionaryWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -432,8 +430,6 @@ def get_not_provided(self, **kwargs: Any) -> _models.DictionaryWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py index 77420e0ad98..648dc9a8b59 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -94,6 +96,7 @@ def get_valid(self, **kwargs: Any) -> _models.MyBaseType: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -104,8 +107,6 @@ def get_valid(self, **kwargs: Any) -> _models.MyBaseType: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py index 2336b5861b6..f2db021b368 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,6 +114,7 @@ def get_valid(self, **kwargs: Any) -> _models.Siamese: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,8 +125,6 @@ def get_valid(self, **kwargs: Any) -> _models.Siamese: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -215,6 +216,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -225,8 +227,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py index 6506a0da506..c7a5caf3309 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,6 +114,7 @@ def get_valid(self, **kwargs: Any) -> _models.Fish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,8 +125,6 @@ def get_valid(self, **kwargs: Any) -> _models.Fish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -364,6 +365,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -374,8 +376,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py index 7867c48a5b5..1efe26ad282 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -219,6 +221,7 @@ def get_valid(self, **kwargs: Any) -> _models.Fish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,8 +232,6 @@ def get_valid(self, **kwargs: Any) -> _models.Fish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -411,6 +412,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -421,8 +423,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -455,6 +455,7 @@ def get_dot_syntax(self, **kwargs: Any) -> _models.DotFish: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -465,8 +466,6 @@ def get_dot_syntax(self, **kwargs: Any) -> _models.DotFish: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -505,6 +504,7 @@ def get_composed_with_discriminator(self, **kwargs: Any) -> _models.DotFishMarke headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -515,8 +515,6 @@ def get_composed_with_discriminator(self, **kwargs: Any) -> _models.DotFishMarke response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -555,6 +553,7 @@ def get_composed_without_discriminator(self, **kwargs: Any) -> _models.DotFishMa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -565,8 +564,6 @@ def get_composed_without_discriminator(self, **kwargs: Any) -> _models.DotFishMa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -604,6 +601,7 @@ def get_complicated(self, **kwargs: Any) -> _models.Salmon: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -614,8 +612,6 @@ def get_complicated(self, **kwargs: Any) -> _models.Salmon: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -703,6 +699,7 @@ def put_complicated( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -713,8 +710,6 @@ def put_complicated( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -795,6 +790,7 @@ def put_missing_discriminator( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -805,8 +801,6 @@ def put_missing_discriminator( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -972,6 +966,7 @@ def put_valid_missing_required( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -982,8 +977,6 @@ def put_valid_missing_required( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py index 822e714a098..aed81de0250 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py @@ -22,11 +22,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -423,6 +425,7 @@ def get_int(self, **kwargs: Any) -> _models.IntWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,8 +436,6 @@ def get_int(self, **kwargs: Any) -> _models.IntWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -520,6 +521,7 @@ def put_int( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -530,8 +532,6 @@ def put_int( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -564,6 +564,7 @@ def get_long(self, **kwargs: Any) -> _models.LongWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -574,8 +575,6 @@ def get_long(self, **kwargs: Any) -> _models.LongWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -661,6 +660,7 @@ def put_long( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -671,8 +671,6 @@ def put_long( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -705,6 +703,7 @@ def get_float(self, **kwargs: Any) -> _models.FloatWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -715,8 +714,6 @@ def get_float(self, **kwargs: Any) -> _models.FloatWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -802,6 +799,7 @@ def put_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -812,8 +810,6 @@ def put_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -846,6 +842,7 @@ def get_double(self, **kwargs: Any) -> _models.DoubleWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -856,8 +853,6 @@ def get_double(self, **kwargs: Any) -> _models.DoubleWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -946,6 +941,7 @@ def put_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -956,8 +952,6 @@ def put_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -990,6 +984,7 @@ def get_bool(self, **kwargs: Any) -> _models.BooleanWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1000,8 +995,6 @@ def get_bool(self, **kwargs: Any) -> _models.BooleanWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1087,6 +1080,7 @@ def put_bool( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1097,8 +1091,6 @@ def put_bool( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1131,6 +1123,7 @@ def get_string(self, **kwargs: Any) -> _models.StringWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1141,8 +1134,6 @@ def get_string(self, **kwargs: Any) -> _models.StringWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1228,6 +1219,7 @@ def put_string( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1238,8 +1230,6 @@ def put_string( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1272,6 +1262,7 @@ def get_date(self, **kwargs: Any) -> _models.DateWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1282,8 +1273,6 @@ def get_date(self, **kwargs: Any) -> _models.DateWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1369,6 +1358,7 @@ def put_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1379,8 +1369,6 @@ def put_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1413,6 +1401,7 @@ def get_date_time(self, **kwargs: Any) -> _models.DatetimeWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1423,8 +1412,6 @@ def get_date_time(self, **kwargs: Any) -> _models.DatetimeWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1512,6 +1499,7 @@ def put_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1522,8 +1510,6 @@ def put_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1556,6 +1542,7 @@ def get_date_time_rfc1123(self, **kwargs: Any) -> _models.Datetimerfc1123Wrapper headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1566,8 +1553,6 @@ def get_date_time_rfc1123(self, **kwargs: Any) -> _models.Datetimerfc1123Wrapper response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1655,6 +1640,7 @@ def put_date_time_rfc1123( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1665,8 +1651,6 @@ def put_date_time_rfc1123( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1699,6 +1683,7 @@ def get_duration(self, **kwargs: Any) -> _models.DurationWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1709,8 +1694,6 @@ def get_duration(self, **kwargs: Any) -> _models.DurationWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1757,6 +1740,7 @@ def put_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1767,8 +1751,6 @@ def put_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1801,6 +1783,7 @@ def get_byte(self, **kwargs: Any) -> _models.ByteWrapper: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1811,8 +1794,6 @@ def get_byte(self, **kwargs: Any) -> _models.ByteWrapper: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1859,6 +1840,7 @@ def put_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1869,8 +1851,6 @@ def put_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py index e47d0a87044..8e8cd27c698 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -111,6 +113,7 @@ def get_valid(self, **kwargs: Any) -> _models.ReadonlyObj: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -121,8 +124,6 @@ def get_valid(self, **kwargs: Any) -> _models.ReadonlyObj: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -169,6 +170,7 @@ def put_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -179,8 +181,6 @@ def put_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py index e0d6dc379e5..effe32974c4 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._date_operations import ( build_get_invalid_date_request, build_get_max_date_request, @@ -87,6 +89,7 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -135,6 +136,7 @@ async def get_invalid_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +147,6 @@ async def get_invalid_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -183,6 +183,7 @@ async def get_overflow_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -193,8 +194,6 @@ async def get_overflow_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -231,6 +230,7 @@ async def get_underflow_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,8 +241,6 @@ async def get_underflow_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -288,6 +286,7 @@ async def put_max_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -298,8 +297,6 @@ async def put_max_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -332,6 +329,7 @@ async def get_max_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -342,8 +340,6 @@ async def get_max_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -389,6 +385,7 @@ async def put_min_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -399,8 +396,6 @@ async def put_min_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -433,6 +428,7 @@ async def get_min_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -443,8 +439,6 @@ async def get_min_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py index 57e62492a8d..e99808def7e 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -199,6 +201,7 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,8 +212,6 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -247,6 +248,7 @@ def get_invalid_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -257,8 +259,6 @@ def get_invalid_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -295,6 +295,7 @@ def get_overflow_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -305,8 +306,6 @@ def get_overflow_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -343,6 +342,7 @@ def get_underflow_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -353,8 +353,6 @@ def get_underflow_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -400,6 +398,7 @@ def put_max_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -410,8 +409,6 @@ def put_max_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -444,6 +441,7 @@ def get_max_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -454,8 +452,6 @@ def get_max_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -501,6 +497,7 @@ def put_min_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -511,8 +508,6 @@ def put_min_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -545,6 +540,7 @@ def get_min_date(self, **kwargs: Any) -> datetime.date: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -555,8 +551,6 @@ def get_min_date(self, **kwargs: Any) -> datetime.date: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py index 9b0458a06e1..35c96e90bcc 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._datetime_operations import ( build_get_invalid_request, build_get_local_negative_offset_lowercase_max_date_time_request, @@ -101,6 +103,7 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,8 +114,6 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -149,6 +150,7 @@ async def get_invalid(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -159,8 +161,6 @@ async def get_invalid(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +197,7 @@ async def get_overflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +208,6 @@ async def get_overflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -245,6 +244,7 @@ async def get_underflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +255,6 @@ async def get_underflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -302,6 +300,7 @@ async def put_utc_max_date_time( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -312,8 +311,6 @@ async def put_utc_max_date_time( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -358,6 +355,7 @@ async def put_utc_max_date_time7_digits( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -368,8 +366,6 @@ async def put_utc_max_date_time7_digits( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -402,6 +398,7 @@ async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -412,8 +409,6 @@ async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -450,6 +445,7 @@ async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,8 +456,6 @@ async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -501,6 +495,7 @@ async def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> dateti headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -511,8 +506,6 @@ async def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> dateti response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -558,6 +551,7 @@ async def put_local_positive_offset_max_date_time( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -568,8 +562,6 @@ async def put_local_positive_offset_max_date_time( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -604,6 +596,7 @@ async def get_local_positive_offset_lowercase_max_date_time( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -614,8 +607,6 @@ async def get_local_positive_offset_lowercase_max_date_time( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -654,6 +645,7 @@ async def get_local_positive_offset_uppercase_max_date_time( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -664,8 +656,6 @@ async def get_local_positive_offset_uppercase_max_date_time( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -711,6 +701,7 @@ async def put_local_negative_offset_max_date_time( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -721,8 +712,6 @@ async def put_local_negative_offset_max_date_time( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -757,6 +746,7 @@ async def get_local_negative_offset_uppercase_max_date_time( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -767,8 +757,6 @@ async def get_local_negative_offset_uppercase_max_date_time( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -807,6 +795,7 @@ async def get_local_negative_offset_lowercase_max_date_time( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -817,8 +806,6 @@ async def get_local_negative_offset_lowercase_max_date_time( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -864,6 +851,7 @@ async def put_utc_min_date_time( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -874,8 +862,6 @@ async def put_utc_min_date_time( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -908,6 +894,7 @@ async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -918,8 +905,6 @@ async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -965,6 +950,7 @@ async def put_local_positive_offset_min_date_time( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -975,8 +961,6 @@ async def put_local_positive_offset_min_date_time( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1009,6 +993,7 @@ async def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> dateti headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1019,8 +1004,6 @@ async def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> dateti response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1066,6 +1049,7 @@ async def put_local_negative_offset_min_date_time( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1076,8 +1060,6 @@ async def put_local_negative_offset_min_date_time( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1110,6 +1092,7 @@ async def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> dateti headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1120,8 +1103,6 @@ async def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> dateti response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1158,6 +1139,7 @@ async def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.dat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1168,8 +1150,6 @@ async def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.dat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py index 57a7e7f3aeb..9bf539d2da6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -434,6 +436,7 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,8 +447,6 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -482,6 +483,7 @@ def get_invalid(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -492,8 +494,6 @@ def get_invalid(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -530,6 +530,7 @@ def get_overflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -540,8 +541,6 @@ def get_overflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -578,6 +577,7 @@ def get_underflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -588,8 +588,6 @@ def get_underflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -635,6 +633,7 @@ def put_utc_max_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -645,8 +644,6 @@ def put_utc_max_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -691,6 +688,7 @@ def put_utc_max_date_time7_digits( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -701,8 +699,6 @@ def put_utc_max_date_time7_digits( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -735,6 +731,7 @@ def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -745,8 +742,6 @@ def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -783,6 +778,7 @@ def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -793,8 +789,6 @@ def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -834,6 +828,7 @@ def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> datetime.dat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -844,8 +839,6 @@ def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> datetime.dat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -891,6 +884,7 @@ def put_local_positive_offset_max_date_time( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -901,8 +895,6 @@ def put_local_positive_offset_max_date_time( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -937,6 +929,7 @@ def get_local_positive_offset_lowercase_max_date_time( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -947,8 +940,6 @@ def get_local_positive_offset_lowercase_max_date_time( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -987,6 +978,7 @@ def get_local_positive_offset_uppercase_max_date_time( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -997,8 +989,6 @@ def get_local_positive_offset_uppercase_max_date_time( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1044,6 +1034,7 @@ def put_local_negative_offset_max_date_time( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1054,8 +1045,6 @@ def put_local_negative_offset_max_date_time( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1090,6 +1079,7 @@ def get_local_negative_offset_uppercase_max_date_time( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1100,8 +1090,6 @@ def get_local_negative_offset_uppercase_max_date_time( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1140,6 +1128,7 @@ def get_local_negative_offset_lowercase_max_date_time( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1150,8 +1139,6 @@ def get_local_negative_offset_lowercase_max_date_time( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1197,6 +1184,7 @@ def put_utc_min_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1207,8 +1195,6 @@ def put_utc_min_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1241,6 +1227,7 @@ def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1251,8 +1238,6 @@ def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1298,6 +1283,7 @@ def put_local_positive_offset_min_date_time( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1308,8 +1294,6 @@ def put_local_positive_offset_min_date_time( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1342,6 +1326,7 @@ def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> datetime.dat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1352,8 +1337,6 @@ def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> datetime.dat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1399,6 +1382,7 @@ def put_local_negative_offset_min_date_time( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1409,8 +1393,6 @@ def put_local_negative_offset_min_date_time( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1443,6 +1425,7 @@ def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> datetime.dat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1453,8 +1436,6 @@ def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> datetime.dat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1491,6 +1472,7 @@ def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1501,8 +1483,6 @@ def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py index f5df9992088..b18050032ff 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._datetimerfc1123_operations import ( build_get_invalid_request, build_get_null_request, @@ -88,6 +90,7 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -98,8 +101,6 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -136,6 +137,7 @@ async def get_invalid(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,8 +148,6 @@ async def get_invalid(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +184,7 @@ async def get_overflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +195,6 @@ async def get_overflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -232,6 +231,7 @@ async def get_underflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -242,8 +242,6 @@ async def get_underflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -289,6 +287,7 @@ async def put_utc_max_date_time( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +298,6 @@ async def put_utc_max_date_time( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -333,6 +330,7 @@ async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -343,8 +341,6 @@ async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -381,6 +377,7 @@ async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -391,8 +388,6 @@ async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -438,6 +433,7 @@ async def put_utc_min_date_time( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -448,8 +444,6 @@ async def put_utc_min_date_time( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -482,6 +476,7 @@ async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -492,8 +487,6 @@ async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py index 9c8fa352edf..cad7162b770 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -213,6 +215,7 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -223,8 +226,6 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -261,6 +262,7 @@ def get_invalid(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -271,8 +273,6 @@ def get_invalid(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -309,6 +309,7 @@ def get_overflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -319,8 +320,6 @@ def get_overflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -357,6 +356,7 @@ def get_underflow(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -367,8 +367,6 @@ def get_underflow(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -414,6 +412,7 @@ def put_utc_max_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -424,8 +423,6 @@ def put_utc_max_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -458,6 +455,7 @@ def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -468,8 +466,6 @@ def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -506,6 +502,7 @@ def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -516,8 +513,6 @@ def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -563,6 +558,7 @@ def put_utc_min_date_time( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -573,8 +569,6 @@ def put_utc_min_date_time( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -607,6 +601,7 @@ def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,8 +612,6 @@ def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py index 5d6b4260523..bffd52227b3 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._dictionary_operations import ( build_get_array_empty_request, build_get_array_item_empty_request, @@ -145,6 +147,7 @@ async def get_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,8 +158,6 @@ async def get_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -193,6 +194,7 @@ async def get_empty(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -203,8 +205,6 @@ async def get_empty(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -289,6 +289,7 @@ async def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +300,6 @@ async def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -333,6 +332,7 @@ async def get_null_value(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -343,8 +343,6 @@ async def get_null_value(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -381,6 +379,7 @@ async def get_null_key(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -391,8 +390,6 @@ async def get_null_key(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -429,6 +426,7 @@ async def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -439,8 +437,6 @@ async def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -477,6 +473,7 @@ async def get_invalid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,8 +484,6 @@ async def get_invalid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -525,6 +520,7 @@ async def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,8 +531,6 @@ async def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -621,6 +615,7 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -631,8 +626,6 @@ async def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -665,6 +658,7 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -675,8 +669,6 @@ async def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -713,6 +705,7 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -723,8 +716,6 @@ async def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -761,6 +752,7 @@ async def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -771,8 +763,6 @@ async def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -857,6 +847,7 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -867,8 +858,6 @@ async def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -901,6 +890,7 @@ async def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -911,8 +901,6 @@ async def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -949,6 +937,7 @@ async def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -959,8 +948,6 @@ async def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -997,6 +984,7 @@ async def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1007,8 +995,6 @@ async def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1093,6 +1079,7 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1103,8 +1090,6 @@ async def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1137,6 +1122,7 @@ async def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1147,8 +1133,6 @@ async def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1185,6 +1169,7 @@ async def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1195,8 +1180,6 @@ async def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1233,6 +1216,7 @@ async def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1243,8 +1227,6 @@ async def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1329,6 +1311,7 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1339,8 +1322,6 @@ async def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1373,6 +1354,7 @@ async def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1383,8 +1365,6 @@ async def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1421,6 +1401,7 @@ async def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1431,8 +1412,6 @@ async def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1469,6 +1448,7 @@ async def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1479,8 +1459,6 @@ async def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1565,6 +1543,7 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1575,8 +1554,6 @@ async def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1609,6 +1586,7 @@ async def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1619,8 +1597,6 @@ async def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1657,6 +1633,7 @@ async def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1667,8 +1644,6 @@ async def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1705,6 +1680,7 @@ async def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1715,8 +1691,6 @@ async def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1801,6 +1775,7 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1811,8 +1786,6 @@ async def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1845,6 +1818,7 @@ async def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1855,8 +1829,6 @@ async def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1893,6 +1865,7 @@ async def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1903,8 +1876,6 @@ async def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1941,6 +1912,7 @@ async def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1951,8 +1923,6 @@ async def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2037,6 +2007,7 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2047,8 +2018,6 @@ async def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2081,6 +2050,7 @@ async def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2091,8 +2061,6 @@ async def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2129,6 +2097,7 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2139,8 +2108,6 @@ async def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2178,6 +2145,7 @@ async def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetim headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2188,8 +2156,6 @@ async def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetim response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2277,6 +2243,7 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2287,8 +2254,6 @@ async def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2321,6 +2286,7 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime. headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2331,8 +2297,6 @@ async def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime. response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2369,6 +2333,7 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2379,8 +2344,6 @@ async def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2418,6 +2381,7 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2428,8 +2392,6 @@ async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2517,6 +2479,7 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2527,8 +2490,6 @@ async def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2561,6 +2522,7 @@ async def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelt headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2571,8 +2533,6 @@ async def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelt response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2657,6 +2617,7 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2667,8 +2628,6 @@ async def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2702,6 +2661,7 @@ async def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2712,8 +2672,6 @@ async def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2801,6 +2759,7 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2811,8 +2770,6 @@ async def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2846,6 +2803,7 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2856,8 +2814,6 @@ async def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2895,6 +2851,7 @@ async def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2905,8 +2862,6 @@ async def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2943,6 +2898,7 @@ async def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, _models.Wi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2953,8 +2909,6 @@ async def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, _models.Wi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2991,6 +2945,7 @@ async def get_complex_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3001,8 +2956,6 @@ async def get_complex_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3040,6 +2993,7 @@ async def get_complex_item_null(self, **kwargs: Any) -> Dict[str, _models.Widget headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3050,8 +3004,6 @@ async def get_complex_item_null(self, **kwargs: Any) -> Dict[str, _models.Widget response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3089,6 +3041,7 @@ async def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, _models.Widge headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3099,8 +3052,6 @@ async def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, _models.Widge response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3138,6 +3089,7 @@ async def get_complex_valid(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3148,8 +3100,6 @@ async def get_complex_valid(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3237,6 +3187,7 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3247,8 +3198,6 @@ async def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3281,6 +3230,7 @@ async def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3291,8 +3241,6 @@ async def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3329,6 +3277,7 @@ async def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3339,8 +3288,6 @@ async def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3377,6 +3324,7 @@ async def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3387,8 +3335,6 @@ async def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3425,6 +3371,7 @@ async def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3435,8 +3382,6 @@ async def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3474,6 +3419,7 @@ async def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3484,8 +3430,6 @@ async def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3573,6 +3517,7 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3583,8 +3528,6 @@ async def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3617,6 +3560,7 @@ async def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3627,8 +3571,6 @@ async def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3665,6 +3607,7 @@ async def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3675,8 +3618,6 @@ async def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3714,6 +3655,7 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3724,8 +3666,6 @@ async def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3763,6 +3703,7 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3773,8 +3714,6 @@ async def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3813,6 +3752,7 @@ async def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3823,8 +3763,6 @@ async def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3915,6 +3853,7 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3925,8 +3864,6 @@ async def put_dictionary_valid( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py index 9fc0ae1098a..6279400fe82 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py @@ -20,12 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -1037,6 +1039,7 @@ def get_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1047,8 +1050,6 @@ def get_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1085,6 +1086,7 @@ def get_empty(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1095,8 +1097,6 @@ def get_empty(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1181,6 +1181,7 @@ def put_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1191,8 +1192,6 @@ def put_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1225,6 +1224,7 @@ def get_null_value(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1235,8 +1235,6 @@ def get_null_value(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1273,6 +1271,7 @@ def get_null_key(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1283,8 +1282,6 @@ def get_null_key(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1321,6 +1318,7 @@ def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1331,8 +1329,6 @@ def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1369,6 +1365,7 @@ def get_invalid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1379,8 +1376,6 @@ def get_invalid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1417,6 +1412,7 @@ def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1427,8 +1423,6 @@ def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1513,6 +1507,7 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1523,8 +1518,6 @@ def put_boolean_tfft( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1557,6 +1550,7 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1567,8 +1561,6 @@ def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1605,6 +1597,7 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1615,8 +1608,6 @@ def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1653,6 +1644,7 @@ def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1663,8 +1655,6 @@ def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1749,6 +1739,7 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1759,8 +1750,6 @@ def put_integer_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1793,6 +1782,7 @@ def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1803,8 +1793,6 @@ def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1841,6 +1829,7 @@ def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1851,8 +1840,6 @@ def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1889,6 +1876,7 @@ def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1899,8 +1887,6 @@ def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1985,6 +1971,7 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1995,8 +1982,6 @@ def put_long_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2029,6 +2014,7 @@ def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2039,8 +2025,6 @@ def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2077,6 +2061,7 @@ def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2087,8 +2072,6 @@ def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2125,6 +2108,7 @@ def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2135,8 +2119,6 @@ def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2221,6 +2203,7 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2231,8 +2214,6 @@ def put_float_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2265,6 +2246,7 @@ def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2275,8 +2257,6 @@ def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2313,6 +2293,7 @@ def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2323,8 +2304,6 @@ def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2361,6 +2340,7 @@ def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2371,8 +2351,6 @@ def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2457,6 +2435,7 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2467,8 +2446,6 @@ def put_double_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2501,6 +2478,7 @@ def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2511,8 +2489,6 @@ def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2549,6 +2525,7 @@ def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2559,8 +2536,6 @@ def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2597,6 +2572,7 @@ def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2607,8 +2583,6 @@ def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2693,6 +2667,7 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2703,8 +2678,6 @@ def put_string_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2737,6 +2710,7 @@ def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2747,8 +2721,6 @@ def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2785,6 +2757,7 @@ def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2795,8 +2768,6 @@ def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2833,6 +2804,7 @@ def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2843,8 +2815,6 @@ def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2929,6 +2899,7 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2939,8 +2910,6 @@ def put_date_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2973,6 +2942,7 @@ def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2983,8 +2953,6 @@ def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3021,6 +2989,7 @@ def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3031,8 +3000,6 @@ def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3070,6 +3037,7 @@ def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3080,8 +3048,6 @@ def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3169,6 +3135,7 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3179,8 +3146,6 @@ def put_date_time_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3213,6 +3178,7 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.dateti headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3223,8 +3189,6 @@ def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.dateti response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3261,6 +3225,7 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3271,8 +3236,6 @@ def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3310,6 +3273,7 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime.datet headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3320,8 +3284,6 @@ def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime.datet response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3409,6 +3371,7 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3419,8 +3382,6 @@ def put_date_time_rfc1123_valid( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3453,6 +3414,7 @@ def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3463,8 +3425,6 @@ def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3549,6 +3509,7 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3559,8 +3520,6 @@ def put_duration_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3594,6 +3553,7 @@ def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3604,8 +3564,6 @@ def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3693,6 +3651,7 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3703,8 +3662,6 @@ def put_byte_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3738,6 +3695,7 @@ def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3748,8 +3706,6 @@ def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3787,6 +3743,7 @@ def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3797,8 +3754,6 @@ def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3835,6 +3790,7 @@ def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, _models.Widget]] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3845,8 +3801,6 @@ def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, _models.Widget]] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3883,6 +3837,7 @@ def get_complex_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3893,8 +3848,6 @@ def get_complex_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3932,6 +3885,7 @@ def get_complex_item_null(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3942,8 +3896,6 @@ def get_complex_item_null(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -3981,6 +3933,7 @@ def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3991,8 +3944,6 @@ def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4030,6 +3981,7 @@ def get_complex_valid(self, **kwargs: Any) -> Dict[str, _models.Widget]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4040,8 +3992,6 @@ def get_complex_valid(self, **kwargs: Any) -> Dict[str, _models.Widget]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4129,6 +4079,7 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4139,8 +4090,6 @@ def put_complex_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4173,6 +4122,7 @@ def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4183,8 +4133,6 @@ def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4221,6 +4169,7 @@ def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4231,8 +4180,6 @@ def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4269,6 +4216,7 @@ def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4279,8 +4227,6 @@ def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4317,6 +4263,7 @@ def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4327,8 +4274,6 @@ def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4366,6 +4311,7 @@ def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4376,8 +4322,6 @@ def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4465,6 +4409,7 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4475,8 +4420,6 @@ def put_array_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4509,6 +4452,7 @@ def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4519,8 +4463,6 @@ def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4557,6 +4499,7 @@ def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4567,8 +4510,6 @@ def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4606,6 +4547,7 @@ def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4616,8 +4558,6 @@ def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4655,6 +4595,7 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4665,8 +4606,6 @@ def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4705,6 +4644,7 @@ def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4715,8 +4655,6 @@ def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -4807,6 +4745,7 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4817,8 +4756,6 @@ def put_dictionary_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py index 62d89fee002..5a6fdc953fd 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._duration_operations import ( build_get_invalid_request, build_get_null_request, @@ -83,6 +85,7 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -93,8 +96,6 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -140,6 +141,7 @@ async def put_positive_duration( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +152,6 @@ async def put_positive_duration( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -184,6 +184,7 @@ async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +195,6 @@ async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -232,6 +231,7 @@ async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -242,8 +242,6 @@ async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py index 5888447d655..97fec1d0745 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -140,6 +142,7 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +153,6 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -197,6 +198,7 @@ def put_positive_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,8 +209,6 @@ def put_positive_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -241,6 +241,7 @@ def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -251,8 +252,6 @@ def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -289,6 +288,7 @@ def get_invalid(self, **kwargs: Any) -> datetime.timedelta: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +299,6 @@ def get_invalid(self, **kwargs: Any) -> datetime.timedelta: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py index 85b78369763..c270ce7e214 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._files_operations import ( build_get_empty_file_request, build_get_file_large_request, @@ -80,6 +82,7 @@ async def get_file(self, **kwargs: Any) -> AsyncIterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -90,8 +93,6 @@ async def get_file(self, **kwargs: Any) -> AsyncIterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -128,6 +129,7 @@ async def get_file_large(self, **kwargs: Any) -> AsyncIterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -138,8 +140,6 @@ async def get_file_large(self, **kwargs: Any) -> AsyncIterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -176,6 +176,7 @@ async def get_empty_file(self, **kwargs: Any) -> AsyncIterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -186,8 +187,6 @@ async def get_empty_file(self, **kwargs: Any) -> AsyncIterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py index 0dd22995979..4bd2c99d2be 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -122,6 +124,7 @@ def get_file(self, **kwargs: Any) -> Iterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -132,8 +135,6 @@ def get_file(self, **kwargs: Any) -> Iterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -170,6 +171,7 @@ def get_file_large(self, **kwargs: Any) -> Iterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -180,8 +182,6 @@ def get_file_large(self, **kwargs: Any) -> Iterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -218,6 +218,7 @@ def get_empty_file(self, **kwargs: Any) -> Iterator[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -228,8 +229,6 @@ def get_empty_file(self, **kwargs: Any) -> Iterator[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_vendor.py index 0af9b28f660..0dafe0e287f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_vendor.py @@ -4,3 +4,13 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py index 68c6ce7ba01..89347b894c9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._formdata_operations import ( build_upload_file_request, build_upload_file_via_body_request, @@ -95,6 +97,7 @@ async def upload_file(self, file_content: IO[bytes], file_name: str, **kwargs: A headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = True @@ -105,8 +108,6 @@ async def upload_file(self, file_content: IO[bytes], file_name: str, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -150,6 +151,7 @@ async def upload_file_via_body(self, file_content: IO[bytes], **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -160,8 +162,6 @@ async def upload_file_via_body(self, file_content: IO[bytes], **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -208,6 +208,7 @@ async def upload_files(self, file_content: List[IO[bytes]], **kwargs: Any) -> As headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = True @@ -218,8 +219,6 @@ async def upload_files(self, file_content: List[IO[bytes]], **kwargs: Any) -> As response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py index 3fac400ff64..78b62c77516 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -141,6 +143,7 @@ def upload_file(self, file_content: IO[bytes], file_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = True @@ -151,8 +154,6 @@ def upload_file(self, file_content: IO[bytes], file_name: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -196,6 +197,7 @@ def upload_file_via_body(self, file_content: IO[bytes], **kwargs: Any) -> Iterat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = True @@ -206,8 +208,6 @@ def upload_file_via_body(self, file_content: IO[bytes], **kwargs: Any) -> Iterat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -254,6 +254,7 @@ def upload_files(self, file_content: List[IO[bytes]], **kwargs: Any) -> Iterator headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = True @@ -264,8 +265,6 @@ def upload_files(self, file_content: List[IO[bytes]], **kwargs: Any) -> Iterator response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py index 0af9b28f660..0dafe0e287f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py @@ -4,3 +4,13 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py index 11e3cf50f1a..992d73a395e 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._formdataurlencoded_operations import ( build_partial_constant_body_request, build_update_pet_with_form_request, @@ -120,6 +122,7 @@ async def update_pet_with_form( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -130,8 +133,6 @@ async def update_pet_with_form( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200, 405]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -184,6 +185,7 @@ async def partial_constant_body( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -194,8 +196,6 @@ async def partial_constant_body( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py index 049ca2b8a70..87ab98c293b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -145,6 +147,7 @@ def update_pet_with_form( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,8 +158,6 @@ def update_pet_with_form( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 405]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -209,6 +210,7 @@ def partial_constant_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,8 +221,6 @@ def partial_constant_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations_operations.py index 52536259aa1..37829f7ab55 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._int_operations_operations import ( build_get_invalid_request, build_get_invalid_unix_time_request, @@ -93,6 +95,7 @@ async def get_null(self, **kwargs: Any) -> Optional[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -103,8 +106,6 @@ async def get_null(self, **kwargs: Any) -> Optional[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -141,6 +142,7 @@ async def get_invalid(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -151,8 +153,6 @@ async def get_invalid(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -189,6 +189,7 @@ async def get_overflow_int32(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -199,8 +200,6 @@ async def get_overflow_int32(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -237,6 +236,7 @@ async def get_underflow_int32(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,8 +247,6 @@ async def get_underflow_int32(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -285,6 +283,7 @@ async def get_overflow_int64(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -295,8 +294,6 @@ async def get_overflow_int64(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -333,6 +330,7 @@ async def get_underflow_int64(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -343,8 +341,6 @@ async def get_underflow_int64(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -388,6 +384,7 @@ async def put_max32(self, int_body: int, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +395,6 @@ async def put_max32(self, int_body: int, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -439,6 +434,7 @@ async def put_max64(self, int_body: int, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -449,8 +445,6 @@ async def put_max64(self, int_body: int, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -490,6 +484,7 @@ async def put_min32(self, int_body: int, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -500,8 +495,6 @@ async def put_min32(self, int_body: int, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -541,6 +534,7 @@ async def put_min64(self, int_body: int, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -551,8 +545,6 @@ async def put_min64(self, int_body: int, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -585,6 +577,7 @@ async def get_unix_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -595,8 +588,6 @@ async def get_unix_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -642,6 +633,7 @@ async def put_unix_time_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -652,8 +644,6 @@ async def put_unix_time_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -686,6 +676,7 @@ async def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -696,8 +687,6 @@ async def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -734,6 +723,7 @@ async def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -744,8 +734,6 @@ async def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations_operations.py index 32241086848..ad9efa9e143 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -292,6 +294,7 @@ def get_null(self, **kwargs: Any) -> Optional[int]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -302,8 +305,6 @@ def get_null(self, **kwargs: Any) -> Optional[int]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -340,6 +341,7 @@ def get_invalid(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -350,8 +352,6 @@ def get_invalid(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -388,6 +388,7 @@ def get_overflow_int32(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +399,6 @@ def get_overflow_int32(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -436,6 +435,7 @@ def get_underflow_int32(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -446,8 +446,6 @@ def get_underflow_int32(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -484,6 +482,7 @@ def get_overflow_int64(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -494,8 +493,6 @@ def get_overflow_int64(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -532,6 +529,7 @@ def get_underflow_int64(self, **kwargs: Any) -> int: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -542,8 +540,6 @@ def get_underflow_int64(self, **kwargs: Any) -> int: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -587,6 +583,7 @@ def put_max32(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -597,8 +594,6 @@ def put_max32(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -638,6 +633,7 @@ def put_max64(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -648,8 +644,6 @@ def put_max64(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -689,6 +683,7 @@ def put_min32(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -699,8 +694,6 @@ def put_min32(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -740,6 +733,7 @@ def put_min64(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -750,8 +744,6 @@ def put_min64(self, int_body: int, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -784,6 +776,7 @@ def get_unix_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -794,8 +787,6 @@ def get_unix_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -841,6 +832,7 @@ def put_unix_time_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -851,8 +843,6 @@ def put_unix_time_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -885,6 +875,7 @@ def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -895,8 +886,6 @@ def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -933,6 +922,7 @@ def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -943,8 +933,6 @@ def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py index 0e269688dbe..1c9d563dc9c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._number_operations import ( build_get_big_decimal_negative_decimal_request, build_get_big_decimal_positive_decimal_request, @@ -102,6 +104,7 @@ async def get_null(self, **kwargs: Any) -> Optional[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -112,8 +115,6 @@ async def get_null(self, **kwargs: Any) -> Optional[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -150,6 +151,7 @@ async def get_invalid_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -160,8 +162,6 @@ async def get_invalid_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -198,6 +198,7 @@ async def get_invalid_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -208,8 +209,6 @@ async def get_invalid_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -246,6 +245,7 @@ async def get_invalid_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,8 +256,6 @@ async def get_invalid_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -303,6 +301,7 @@ async def put_big_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -313,8 +312,6 @@ async def put_big_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -347,6 +344,7 @@ async def get_big_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -357,8 +355,6 @@ async def get_big_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -404,6 +400,7 @@ async def put_big_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -414,8 +411,6 @@ async def put_big_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -448,6 +443,7 @@ async def get_big_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -458,8 +454,6 @@ async def get_big_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -504,6 +498,7 @@ async def put_big_double_positive_decimal( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -514,8 +509,6 @@ async def put_big_double_positive_decimal( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -548,6 +541,7 @@ async def get_big_double_positive_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -558,8 +552,6 @@ async def get_big_double_positive_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -604,6 +596,7 @@ async def put_big_double_negative_decimal( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -614,8 +607,6 @@ async def put_big_double_negative_decimal( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -648,6 +639,7 @@ async def get_big_double_negative_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -658,8 +650,6 @@ async def get_big_double_negative_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -705,6 +695,7 @@ async def put_big_decimal( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -715,8 +706,6 @@ async def put_big_decimal( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -749,6 +738,7 @@ async def get_big_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -759,8 +749,6 @@ async def get_big_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -805,6 +793,7 @@ async def put_big_decimal_positive_decimal( # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -815,8 +804,6 @@ async def put_big_decimal_positive_decimal( # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -849,6 +836,7 @@ async def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -859,8 +847,6 @@ async def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -905,6 +891,7 @@ async def put_big_decimal_negative_decimal( # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -915,8 +902,6 @@ async def put_big_decimal_negative_decimal( # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -949,6 +934,7 @@ async def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -959,8 +945,6 @@ async def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1006,6 +990,7 @@ async def put_small_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1016,8 +1001,6 @@ async def put_small_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1050,6 +1033,7 @@ async def get_small_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1060,8 +1044,6 @@ async def get_small_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1107,6 +1089,7 @@ async def put_small_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1117,8 +1100,6 @@ async def put_small_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1151,6 +1132,7 @@ async def get_small_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1161,8 +1143,6 @@ async def get_small_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1208,6 +1188,7 @@ async def put_small_decimal( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1218,8 +1199,6 @@ async def put_small_decimal( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1252,6 +1231,7 @@ async def get_small_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1262,8 +1242,6 @@ async def get_small_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py index a31c509c8ce..439a2b0755b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -450,6 +452,7 @@ def get_null(self, **kwargs: Any) -> Optional[float]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,8 +463,6 @@ def get_null(self, **kwargs: Any) -> Optional[float]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -498,6 +499,7 @@ def get_invalid_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -508,8 +510,6 @@ def get_invalid_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -546,6 +546,7 @@ def get_invalid_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -556,8 +557,6 @@ def get_invalid_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -594,6 +593,7 @@ def get_invalid_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -604,8 +604,6 @@ def get_invalid_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -651,6 +649,7 @@ def put_big_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -661,8 +660,6 @@ def put_big_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -695,6 +692,7 @@ def get_big_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -705,8 +703,6 @@ def get_big_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -752,6 +748,7 @@ def put_big_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -762,8 +759,6 @@ def put_big_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -796,6 +791,7 @@ def get_big_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -806,8 +802,6 @@ def get_big_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -850,6 +844,7 @@ def put_big_double_positive_decimal(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -860,8 +855,6 @@ def put_big_double_positive_decimal(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -894,6 +887,7 @@ def get_big_double_positive_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -904,8 +898,6 @@ def get_big_double_positive_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -948,6 +940,7 @@ def put_big_double_negative_decimal(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -958,8 +951,6 @@ def put_big_double_negative_decimal(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -992,6 +983,7 @@ def get_big_double_negative_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1002,8 +994,6 @@ def get_big_double_negative_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1049,6 +1039,7 @@ def put_big_decimal( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1059,8 +1050,6 @@ def put_big_decimal( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1093,6 +1082,7 @@ def get_big_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1103,8 +1093,6 @@ def get_big_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1147,6 +1135,7 @@ def put_big_decimal_positive_decimal(self, **kwargs: Any) -> None: # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1157,8 +1146,6 @@ def put_big_decimal_positive_decimal(self, **kwargs: Any) -> None: # pylint: di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1191,6 +1178,7 @@ def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1201,8 +1189,6 @@ def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1245,6 +1231,7 @@ def put_big_decimal_negative_decimal(self, **kwargs: Any) -> None: # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1255,8 +1242,6 @@ def put_big_decimal_negative_decimal(self, **kwargs: Any) -> None: # pylint: di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1289,6 +1274,7 @@ def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1299,8 +1285,6 @@ def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1346,6 +1330,7 @@ def put_small_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1356,8 +1341,6 @@ def put_small_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1390,6 +1373,7 @@ def get_small_float(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1400,8 +1384,6 @@ def get_small_float(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1447,6 +1429,7 @@ def put_small_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1457,8 +1440,6 @@ def put_small_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1491,6 +1472,7 @@ def get_small_double(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1501,8 +1483,6 @@ def get_small_double(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1548,6 +1528,7 @@ def put_small_decimal( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1558,8 +1539,6 @@ def put_small_decimal( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1592,6 +1571,7 @@ def get_small_decimal(self, **kwargs: Any) -> float: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1602,8 +1582,6 @@ def get_small_decimal(self, **kwargs: Any) -> float: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py index d339184a3dc..4d4a8e2758a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._enum_operations import ( build_get_not_expandable_request, build_get_referenced_constant_request, @@ -84,6 +86,7 @@ async def get_not_expandable(self, **kwargs: Any) -> Union[str, _models.Colors]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -94,8 +97,6 @@ async def get_not_expandable(self, **kwargs: Any) -> Union[str, _models.Colors]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -142,6 +143,7 @@ async def put_not_expandable( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ async def put_not_expandable( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -186,6 +186,7 @@ async def get_referenced(self, **kwargs: Any) -> Union[str, _models.Colors]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ async def get_referenced(self, **kwargs: Any) -> Union[str, _models.Colors]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -244,6 +243,7 @@ async def put_referenced( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -254,8 +254,6 @@ async def put_referenced( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -288,6 +286,7 @@ async def get_referenced_constant(self, **kwargs: Any) -> _models.RefColorConsta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -298,8 +297,6 @@ async def get_referenced_constant(self, **kwargs: Any) -> _models.RefColorConsta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -347,6 +344,7 @@ async def put_referenced_constant( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -357,8 +355,6 @@ async def put_referenced_constant( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py index a052691d45c..ba7fa3a2fa3 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._string_operations import ( build_get_base64_encoded_request, build_get_base64_url_encoded_request, @@ -91,6 +93,7 @@ async def get_null(self, **kwargs: Any) -> Optional[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -101,8 +104,6 @@ async def get_null(self, **kwargs: Any) -> Optional[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -151,6 +152,7 @@ async def put_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -161,8 +163,6 @@ async def put_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -195,6 +195,7 @@ async def get_empty(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -205,8 +206,6 @@ async def get_empty(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -249,6 +248,7 @@ async def put_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,8 +259,6 @@ async def put_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -293,6 +291,7 @@ async def get_mbcs(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -303,8 +302,6 @@ async def get_mbcs(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -352,6 +349,7 @@ async def put_mbcs(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -362,8 +360,6 @@ async def put_mbcs(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -398,6 +394,7 @@ async def get_whitespace(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -408,8 +405,6 @@ async def get_whitespace(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -456,6 +451,7 @@ async def put_whitespace(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -466,8 +462,6 @@ async def put_whitespace(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -500,6 +494,7 @@ async def get_not_provided(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -510,8 +505,6 @@ async def get_not_provided(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -548,6 +541,7 @@ async def get_base64_encoded(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -558,8 +552,6 @@ async def get_base64_encoded(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -596,6 +588,7 @@ async def get_base64_url_encoded(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -606,8 +599,6 @@ async def get_base64_url_encoded(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -653,6 +644,7 @@ async def put_base64_url_encoded( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -663,8 +655,6 @@ async def put_base64_url_encoded( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -697,6 +687,7 @@ async def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -707,8 +698,6 @@ async def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py index 5739eae424b..64d22f7a987 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -174,6 +176,7 @@ def get_not_expandable(self, **kwargs: Any) -> Union[str, _models.Colors]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -184,8 +187,6 @@ def get_not_expandable(self, **kwargs: Any) -> Union[str, _models.Colors]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -232,6 +233,7 @@ def put_not_expandable( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -242,8 +244,6 @@ def put_not_expandable( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -276,6 +276,7 @@ def get_referenced(self, **kwargs: Any) -> Union[str, _models.Colors]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -286,8 +287,6 @@ def get_referenced(self, **kwargs: Any) -> Union[str, _models.Colors]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -334,6 +333,7 @@ def put_referenced( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -344,8 +344,6 @@ def put_referenced( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -378,6 +376,7 @@ def get_referenced_constant(self, **kwargs: Any) -> _models.RefColorConstant: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -388,8 +387,6 @@ def get_referenced_constant(self, **kwargs: Any) -> _models.RefColorConstant: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -437,6 +434,7 @@ def put_referenced_constant( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -447,8 +445,6 @@ def put_referenced_constant( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py index f9117e22e4d..1ca23dcb839 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -287,6 +289,7 @@ def get_null(self, **kwargs: Any) -> Optional[str]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -297,8 +300,6 @@ def get_null(self, **kwargs: Any) -> Optional[str]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -347,6 +348,7 @@ def put_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -357,8 +359,6 @@ def put_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -391,6 +391,7 @@ def get_empty(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -401,8 +402,6 @@ def get_empty(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -445,6 +444,7 @@ def put_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -455,8 +455,6 @@ def put_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -489,6 +487,7 @@ def get_mbcs(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -499,8 +498,6 @@ def get_mbcs(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -548,6 +545,7 @@ def put_mbcs(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -558,8 +556,6 @@ def put_mbcs(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -594,6 +590,7 @@ def get_whitespace(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -604,8 +601,6 @@ def get_whitespace(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -652,6 +647,7 @@ def put_whitespace(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -662,8 +658,6 @@ def put_whitespace(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -696,6 +690,7 @@ def get_not_provided(self, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -706,8 +701,6 @@ def get_not_provided(self, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -744,6 +737,7 @@ def get_base64_encoded(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -754,8 +748,6 @@ def get_base64_encoded(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -792,6 +784,7 @@ def get_base64_url_encoded(self, **kwargs: Any) -> bytes: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -802,8 +795,6 @@ def get_base64_url_encoded(self, **kwargs: Any) -> bytes: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -849,6 +840,7 @@ def put_base64_url_encoded( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -859,8 +851,6 @@ def put_base64_url_encoded( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -893,6 +883,7 @@ def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -903,8 +894,6 @@ def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py index 4352f07df19..447e5daedd2 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._time_operations import build_get_request, build_put_request if sys.version_info >= (3, 9): @@ -78,6 +80,7 @@ async def get(self, **kwargs: Any) -> datetime.time: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -88,8 +91,6 @@ async def get(self, **kwargs: Any) -> datetime.time: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -133,6 +134,7 @@ async def put(self, time_body: datetime.time, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -143,8 +145,6 @@ async def put(self, time_body: datetime.time, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py index 898db499262..2aa93fd9b29 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,6 +114,7 @@ def get(self, **kwargs: Any) -> datetime.time: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,8 +125,6 @@ def get(self, **kwargs: Any) -> datetime.time: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -167,6 +168,7 @@ def put(self, time_body: datetime.time, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def put(self, time_body: datetime.time, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_vendor.py index 3f1c320adb9..3b000a3b496 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ClientWithEnumConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class ClientWithEnumMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/_vendor.py index 031c576fdb5..391df2f9b34 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ClientWithEnumConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py index f57ad26a2b1..028edb8ca39 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._client_with_enum_operations import build_head_request from .._vendor import ClientWithEnumMixinABC @@ -60,6 +62,7 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -70,8 +73,6 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/operations/_client_with_enum_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/operations/_client_with_enum_operations.py index 13860fb368d..de8ca6d04f7 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/operations/_client_with_enum_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/operations/_client_with_enum_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import ClientWithEnumMixinABC +from .._vendor import ClientWithEnumMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -77,6 +78,7 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -87,8 +89,6 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py index 7981f1108ad..db3d8099d93 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._contants_operations import ( build_put_client_constants_request, build_put_model_as_string_no_required_one_value_default_request, @@ -104,6 +106,7 @@ async def put_no_model_as_string_no_required_two_value_no_default( # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +117,6 @@ async def put_no_model_as_string_no_required_two_value_no_default( # pylint: di response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -154,6 +155,7 @@ async def put_no_model_as_string_no_required_two_value_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -164,8 +166,6 @@ async def put_no_model_as_string_no_required_two_value_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -204,6 +204,7 @@ async def put_no_model_as_string_no_required_one_value_no_default( # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -214,8 +215,6 @@ async def put_no_model_as_string_no_required_one_value_no_default( # pylint: di response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -254,6 +253,7 @@ async def put_no_model_as_string_no_required_one_value_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,8 +264,6 @@ async def put_no_model_as_string_no_required_one_value_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -304,6 +302,7 @@ async def put_no_model_as_string_required_two_value_no_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -314,8 +313,6 @@ async def put_no_model_as_string_required_two_value_no_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -354,6 +351,7 @@ async def put_no_model_as_string_required_two_value_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -364,8 +362,6 @@ async def put_no_model_as_string_required_two_value_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -403,6 +399,7 @@ async def put_no_model_as_string_required_one_value_no_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,8 +410,6 @@ async def put_no_model_as_string_required_one_value_no_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -452,6 +447,7 @@ async def put_no_model_as_string_required_one_value_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -462,8 +458,6 @@ async def put_no_model_as_string_required_one_value_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -502,6 +496,7 @@ async def put_model_as_string_no_required_two_value_no_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -512,8 +507,6 @@ async def put_model_as_string_no_required_two_value_no_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -552,6 +545,7 @@ async def put_model_as_string_no_required_two_value_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -562,8 +556,6 @@ async def put_model_as_string_no_required_two_value_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -602,6 +594,7 @@ async def put_model_as_string_no_required_one_value_no_default( # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -612,8 +605,6 @@ async def put_model_as_string_no_required_one_value_no_default( # pylint: disab response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -652,6 +643,7 @@ async def put_model_as_string_no_required_one_value_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -662,8 +654,6 @@ async def put_model_as_string_no_required_one_value_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -702,6 +692,7 @@ async def put_model_as_string_required_two_value_no_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -712,8 +703,6 @@ async def put_model_as_string_required_two_value_no_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -752,6 +741,7 @@ async def put_model_as_string_required_two_value_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -762,8 +752,6 @@ async def put_model_as_string_required_two_value_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -802,6 +790,7 @@ async def put_model_as_string_required_one_value_no_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -812,8 +801,6 @@ async def put_model_as_string_required_one_value_no_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -852,6 +839,7 @@ async def put_model_as_string_required_one_value_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -862,8 +850,6 @@ async def put_model_as_string_required_one_value_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -899,6 +885,7 @@ async def put_client_constants(self, **kwargs: Any) -> None: # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -909,8 +896,6 @@ async def put_client_constants(self, **kwargs: Any) -> None: # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py index 278091de20e..8e59a3e773a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -347,6 +349,7 @@ def put_no_model_as_string_no_required_two_value_no_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -357,8 +360,6 @@ def put_no_model_as_string_no_required_two_value_no_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -397,6 +398,7 @@ def put_no_model_as_string_no_required_two_value_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -407,8 +409,6 @@ def put_no_model_as_string_no_required_two_value_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -447,6 +447,7 @@ def put_no_model_as_string_no_required_one_value_no_default( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -457,8 +458,6 @@ def put_no_model_as_string_no_required_one_value_no_default( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -497,6 +496,7 @@ def put_no_model_as_string_no_required_one_value_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -507,8 +507,6 @@ def put_no_model_as_string_no_required_one_value_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -547,6 +545,7 @@ def put_no_model_as_string_required_two_value_no_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,8 +556,6 @@ def put_no_model_as_string_required_two_value_no_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -597,6 +594,7 @@ def put_no_model_as_string_required_two_value_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -607,8 +605,6 @@ def put_no_model_as_string_required_two_value_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -646,6 +642,7 @@ def put_no_model_as_string_required_one_value_no_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -656,8 +653,6 @@ def put_no_model_as_string_required_one_value_no_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -695,6 +690,7 @@ def put_no_model_as_string_required_one_value_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -705,8 +701,6 @@ def put_no_model_as_string_required_one_value_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -745,6 +739,7 @@ def put_model_as_string_no_required_two_value_no_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -755,8 +750,6 @@ def put_model_as_string_no_required_two_value_no_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -795,6 +788,7 @@ def put_model_as_string_no_required_two_value_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -805,8 +799,6 @@ def put_model_as_string_no_required_two_value_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -845,6 +837,7 @@ def put_model_as_string_no_required_one_value_no_default( # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -855,8 +848,6 @@ def put_model_as_string_no_required_one_value_no_default( # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -895,6 +886,7 @@ def put_model_as_string_no_required_one_value_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -905,8 +897,6 @@ def put_model_as_string_no_required_one_value_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -945,6 +935,7 @@ def put_model_as_string_required_two_value_no_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -955,8 +946,6 @@ def put_model_as_string_required_two_value_no_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -995,6 +984,7 @@ def put_model_as_string_required_two_value_default( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1005,8 +995,6 @@ def put_model_as_string_required_two_value_default( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1045,6 +1033,7 @@ def put_model_as_string_required_one_value_no_default( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1055,8 +1044,6 @@ def put_model_as_string_required_one_value_no_default( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1095,6 +1082,7 @@ def put_model_as_string_required_one_value_default( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1105,8 +1093,6 @@ def put_model_as_string_required_one_value_default( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1142,6 +1128,7 @@ def put_client_constants(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1152,8 +1139,6 @@ def put_client_constants(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py index 7fed59ce996..9bc8bf896e1 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._paths_operations import build_get_empty_request if sys.version_info >= (3, 9): @@ -80,6 +82,7 @@ async def get_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -94,8 +97,6 @@ async def get_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py index 28f8d219ce4..470325040a6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -96,6 +98,7 @@ def get_empty(self, account_name: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), @@ -110,8 +113,6 @@ def get_empty(self, account_name: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py index ccf8951d94d..21239a0c989 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._paths_operations import build_get_empty_request if sys.version_info >= (3, 9): @@ -89,6 +91,7 @@ async def get_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "vault": self._serialize.url("vault", vault, "str", skip_quote=True), "secret": self._serialize.url("secret", secret, "str", skip_quote=True), @@ -106,8 +109,6 @@ async def get_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py index 5672fc7b3c8..846b2c27f14 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,6 +122,7 @@ def get_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "vault": self._serialize.url("vault", vault, "str", skip_quote=True), "secret": self._serialize.url("secret", secret, "str", skip_quote=True), @@ -137,8 +140,6 @@ def get_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_vendor.py index 57b8012132b..104755de7de 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ErrorWithSecretsConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class ErrorWithSecretsMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/_vendor.py index 004d69077c2..a650431e341 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ErrorWithSecretsConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py index 6297f0367a6..d7d7dded9c4 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._error_with_secrets_operations import ( build_create_secret_request, build_get_error_with_secrets_request, @@ -63,6 +65,7 @@ async def create_secret(self, **kwargs: Any) -> _models.SecretResponse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -73,8 +76,6 @@ async def create_secret(self, **kwargs: Any) -> _models.SecretResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket 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) @@ -111,6 +112,7 @@ async def get_error_with_secrets(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -121,8 +123,6 @@ async def get_error_with_secrets(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket 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) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/operations/_error_with_secrets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/operations/_error_with_secrets_operations.py index 087aa8cbc29..8319fda66c5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/operations/_error_with_secrets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/operations/_error_with_secrets_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import ErrorWithSecretsMixinABC +from .._vendor import ErrorWithSecretsMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -92,6 +93,7 @@ def create_secret(self, **kwargs: Any) -> _models.SecretResponse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -102,8 +104,6 @@ def create_secret(self, **kwargs: Any) -> _models.SecretResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket 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) @@ -140,6 +140,7 @@ def get_error_with_secrets(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +151,6 @@ def get_error_with_secrets(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket 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) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py index abd980486e9..fc4893d2244 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._pet_operations import build_add_pet_request, build_get_by_pet_id_request if sys.version_info >= (3, 9): @@ -81,6 +83,7 @@ async def get_by_pet_id(self, pet_id: str, **kwargs: Any) -> _models.Pet: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def get_by_pet_id(self, pet_id: str, **kwargs: Any) -> _models.Pet: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -177,6 +178,7 @@ async def add_pet(self, pet_param: Optional[Union[_models.Pet, IO[bytes]]] = Non headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -187,8 +189,6 @@ async def add_pet(self, pet_param: Optional[Union[_models.Pet, IO[bytes]]] = Non response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py index cd41de2ac68..b76d3d93158 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,6 +122,7 @@ def get_by_pet_id(self, pet_id: str, **kwargs: Any) -> _models.Pet: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -130,8 +133,6 @@ def get_by_pet_id(self, pet_id: str, **kwargs: Any) -> _models.Pet: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -216,6 +217,7 @@ def add_pet(self, pet_param: Optional[Union[_models.Pet, IO[bytes]]] = None, **k headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,8 +228,6 @@ def add_pet(self, pet_param: Optional[Union[_models.Pet, IO[bytes]]] = None, **k response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py index 9c4a3617bce..0e05aea8dd6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py @@ -19,10 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._header_operations import ( build_custom_request_id_request, build_param_bool_request, @@ -113,6 +115,7 @@ async def param_existing_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -123,8 +126,6 @@ async def param_existing_key( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -157,6 +158,7 @@ async def response_existing_key(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -167,8 +169,6 @@ async def response_existing_key(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -206,6 +206,7 @@ async def param_protected_key(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -216,8 +217,6 @@ async def param_protected_key(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -250,6 +249,7 @@ async def response_protected_key(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -260,8 +260,6 @@ async def response_protected_key(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -307,6 +305,7 @@ async def param_integer( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -317,8 +316,6 @@ async def param_integer( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -357,6 +354,7 @@ async def response_integer( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -367,8 +365,6 @@ async def response_integer( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -414,6 +410,7 @@ async def param_long( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -424,8 +421,6 @@ async def param_long( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -464,6 +459,7 @@ async def response_long( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,8 +470,6 @@ async def response_long( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -521,6 +515,7 @@ async def param_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -531,8 +526,6 @@ async def param_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -571,6 +564,7 @@ async def response_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -581,8 +575,6 @@ async def response_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -628,6 +620,7 @@ async def param_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -638,8 +631,6 @@ async def param_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -678,6 +669,7 @@ async def response_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -688,8 +680,6 @@ async def response_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -735,6 +725,7 @@ async def param_bool( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -745,8 +736,6 @@ async def param_bool( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -785,6 +774,7 @@ async def response_bool( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -795,8 +785,6 @@ async def response_bool( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -843,6 +831,7 @@ async def param_string( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -853,8 +842,6 @@ async def param_string( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -893,6 +880,7 @@ async def response_string( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -903,8 +891,6 @@ async def response_string( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -949,6 +935,7 @@ async def param_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -959,8 +946,6 @@ async def param_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -998,6 +983,7 @@ async def response_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1008,8 +994,6 @@ async def response_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1055,6 +1039,7 @@ async def param_datetime( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1065,8 +1050,6 @@ async def param_datetime( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1104,6 +1087,7 @@ async def response_datetime( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1114,8 +1098,6 @@ async def response_datetime( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1161,6 +1143,7 @@ async def param_datetime_rfc1123( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1171,8 +1154,6 @@ async def param_datetime_rfc1123( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1211,6 +1192,7 @@ async def response_datetime_rfc1123( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1221,8 +1203,6 @@ async def response_datetime_rfc1123( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1266,6 +1246,7 @@ async def param_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1276,8 +1257,6 @@ async def param_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1315,6 +1294,7 @@ async def response_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1325,8 +1305,6 @@ async def response_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1370,6 +1348,7 @@ async def param_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1380,8 +1359,6 @@ async def param_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1419,6 +1396,7 @@ async def response_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1429,8 +1407,6 @@ async def response_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1477,6 +1453,7 @@ async def param_enum( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1487,8 +1464,6 @@ async def param_enum( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1527,6 +1502,7 @@ async def response_enum( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1537,8 +1513,6 @@ async def response_enum( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1575,6 +1549,7 @@ async def custom_request_id(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1585,8 +1560,6 @@ async def custom_request_id(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py index c7eaec9f653..2b4adc3891b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py @@ -19,12 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -539,6 +541,7 @@ def param_existing_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -549,8 +552,6 @@ def param_existing_key( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -583,6 +584,7 @@ def response_existing_key(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -593,8 +595,6 @@ def response_existing_key(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -632,6 +632,7 @@ def param_protected_key(self, **kwargs: Any) -> None: # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -642,8 +643,6 @@ def param_protected_key(self, **kwargs: Any) -> None: # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -676,6 +675,7 @@ def response_protected_key(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -686,8 +686,6 @@ def response_protected_key(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -733,6 +731,7 @@ def param_integer( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -743,8 +742,6 @@ def param_integer( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -781,6 +778,7 @@ def response_integer(self, scenario: str, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -791,8 +789,6 @@ def response_integer(self, scenario: str, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -838,6 +834,7 @@ def param_long( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -848,8 +845,6 @@ def param_long( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -886,6 +881,7 @@ def response_long(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -896,8 +892,6 @@ def response_long(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -943,6 +937,7 @@ def param_float( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -953,8 +948,6 @@ def param_float( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -991,6 +984,7 @@ def response_float(self, scenario: str, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1001,8 +995,6 @@ def response_float(self, scenario: str, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1048,6 +1040,7 @@ def param_double( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1058,8 +1051,6 @@ def param_double( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1096,6 +1087,7 @@ def response_double(self, scenario: str, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1106,8 +1098,6 @@ def response_double(self, scenario: str, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1153,6 +1143,7 @@ def param_bool( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1163,8 +1154,6 @@ def param_bool( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1201,6 +1190,7 @@ def response_bool(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1211,8 +1201,6 @@ def response_bool(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1259,6 +1247,7 @@ def param_string( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1269,8 +1258,6 @@ def param_string( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1307,6 +1294,7 @@ def response_string(self, scenario: str, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1317,8 +1305,6 @@ def response_string(self, scenario: str, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1363,6 +1349,7 @@ def param_date( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1373,8 +1360,6 @@ def param_date( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1410,6 +1395,7 @@ def response_date(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1420,8 +1406,6 @@ def response_date(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1467,6 +1451,7 @@ def param_datetime( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1477,8 +1462,6 @@ def param_datetime( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1514,6 +1497,7 @@ def response_datetime(self, scenario: str, **kwargs: Any) -> None: # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1524,8 +1508,6 @@ def response_datetime(self, scenario: str, **kwargs: Any) -> None: # pylint: di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1571,6 +1553,7 @@ def param_datetime_rfc1123( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1581,8 +1564,6 @@ def param_datetime_rfc1123( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1621,6 +1602,7 @@ def response_datetime_rfc1123( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1631,8 +1613,6 @@ def response_datetime_rfc1123( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1676,6 +1656,7 @@ def param_duration( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1686,8 +1667,6 @@ def param_duration( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1723,6 +1702,7 @@ def response_duration(self, scenario: str, **kwargs: Any) -> None: # pylint: di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1733,8 +1713,6 @@ def response_duration(self, scenario: str, **kwargs: Any) -> None: # pylint: di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1778,6 +1756,7 @@ def param_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1788,8 +1767,6 @@ def param_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1825,6 +1802,7 @@ def response_byte(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1835,8 +1813,6 @@ def response_byte(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1883,6 +1859,7 @@ def param_enum( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1893,8 +1870,6 @@ def param_enum( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1931,6 +1906,7 @@ def response_enum(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1941,8 +1917,6 @@ def response_enum(self, scenario: str, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1979,6 +1953,7 @@ def custom_request_id(self, **kwargs: Any) -> None: # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1989,8 +1964,6 @@ def custom_request_id(self, **kwargs: Any) -> None: # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py index d2e8805a4ea..47592529acf 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_client_failure_operations import ( build_delete400_request, build_delete407_request, @@ -104,6 +106,7 @@ async def head400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,8 +117,6 @@ async def head400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -148,6 +149,7 @@ async def get400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -158,8 +160,6 @@ async def get400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -192,6 +192,7 @@ async def options400(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -202,8 +203,6 @@ async def options400(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -249,6 +248,7 @@ async def put400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,8 +259,6 @@ async def put400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -306,6 +304,7 @@ async def patch400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -316,8 +315,6 @@ async def patch400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -363,6 +360,7 @@ async def post400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -373,8 +371,6 @@ async def post400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -420,6 +416,7 @@ async def delete400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -430,8 +427,6 @@ async def delete400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -464,6 +459,7 @@ async def head401(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,8 +470,6 @@ async def head401(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -508,6 +502,7 @@ async def get402(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -518,8 +513,6 @@ async def get402(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -552,6 +545,7 @@ async def options403(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -562,8 +556,6 @@ async def options403(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -596,6 +588,7 @@ async def get403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -606,8 +599,6 @@ async def get403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -653,6 +644,7 @@ async def put404( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -663,8 +655,6 @@ async def put404( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -710,6 +700,7 @@ async def patch405( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -720,8 +711,6 @@ async def patch405( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -767,6 +756,7 @@ async def post406( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -777,8 +767,6 @@ async def post406( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -824,6 +812,7 @@ async def delete407( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -834,8 +823,6 @@ async def delete407( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -881,6 +868,7 @@ async def put409( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -891,8 +879,6 @@ async def put409( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -925,6 +911,7 @@ async def head410(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -935,8 +922,6 @@ async def head410(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -969,6 +954,7 @@ async def get411(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -979,8 +965,6 @@ async def get411(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1013,6 +997,7 @@ async def options412(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1023,8 +1008,6 @@ async def options412(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1057,6 +1040,7 @@ async def get412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1067,8 +1051,6 @@ async def get412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1114,6 +1096,7 @@ async def put413( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1124,8 +1107,6 @@ async def put413( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1171,6 +1152,7 @@ async def patch414( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1181,8 +1163,6 @@ async def patch414( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1228,6 +1208,7 @@ async def post415( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1238,8 +1219,6 @@ async def post415( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1272,6 +1251,7 @@ async def get416(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1282,8 +1262,6 @@ async def get416(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1329,6 +1307,7 @@ async def delete417( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1339,8 +1318,6 @@ async def delete417( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1373,6 +1350,7 @@ async def head429(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1383,8 +1361,6 @@ async def head429(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py index 2015360f1ed..7477da622c9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_failure_operations import ( build_get_empty_error_request, build_get_no_model_empty_request, @@ -80,6 +82,7 @@ async def get_empty_error(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -90,8 +93,6 @@ async def get_empty_error(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -128,6 +129,7 @@ async def get_no_model_error(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -138,8 +140,6 @@ async def get_no_model_error(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -175,6 +175,7 @@ async def get_no_model_empty(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -185,8 +186,6 @@ async def get_no_model_empty(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py index e9cee30b9db..db535692f02 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_redirects_operations import ( build_delete307_request, build_get300_request, @@ -94,6 +96,7 @@ async def head300(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -104,8 +107,6 @@ async def head300(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200, 300]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -142,6 +143,7 @@ async def get300(self, **kwargs: Any) -> Optional[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +154,6 @@ async def get300(self, **kwargs: Any) -> Optional[List[str]]: response = pipeline_response.http_response if response.status_code not in [200, 300]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -195,6 +195,7 @@ async def head301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -205,8 +206,6 @@ async def head301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200, 301]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -243,6 +242,7 @@ async def get301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,8 +253,6 @@ async def get301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200, 301]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -305,6 +303,7 @@ async def put301( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,8 +314,6 @@ async def put301( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [301]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -352,6 +349,7 @@ async def head302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -362,8 +360,6 @@ async def head302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200, 302]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -400,6 +396,7 @@ async def get302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -410,8 +407,6 @@ async def get302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200, 302]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -462,6 +457,7 @@ async def patch302( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -472,8 +468,6 @@ async def patch302( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [302]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -523,6 +517,7 @@ async def post303( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -533,8 +528,6 @@ async def post303( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 303]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -571,6 +564,7 @@ async def head307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -581,8 +575,6 @@ async def head307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -619,6 +611,7 @@ async def get307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -629,8 +622,6 @@ async def get307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -667,6 +658,7 @@ async def options307(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -677,8 +669,6 @@ async def options307(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -728,6 +718,7 @@ async def put307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -738,8 +729,6 @@ async def put307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -789,6 +778,7 @@ async def patch307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -799,8 +789,6 @@ async def patch307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -850,6 +838,7 @@ async def post307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -860,8 +849,6 @@ async def post307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -911,6 +898,7 @@ async def delete307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -921,8 +909,6 @@ async def delete307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py index 036aa3678a4..bf37d0efdbe 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_retry_operations import ( build_delete503_request, build_get502_request, @@ -87,6 +89,7 @@ async def head408(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -97,8 +100,6 @@ async def head408(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -144,6 +145,7 @@ async def put500( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,8 +156,6 @@ async def put500( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -201,6 +201,7 @@ async def patch500( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -211,8 +212,6 @@ async def patch500( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -245,6 +244,7 @@ async def get502(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +255,6 @@ async def get502(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -289,6 +287,7 @@ async def options502(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,8 +298,6 @@ async def options502(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -350,6 +347,7 @@ async def post503( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -360,8 +358,6 @@ async def post503( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -407,6 +403,7 @@ async def delete503( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -417,8 +414,6 @@ async def delete503( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -464,6 +459,7 @@ async def put504( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,8 +470,6 @@ async def put504( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -521,6 +515,7 @@ async def patch504( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -531,8 +526,6 @@ async def patch504( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py index acdc6a7a9d6..09e7fd5758d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_server_failure_operations import ( build_delete505_request, build_get501_request, @@ -82,6 +84,7 @@ async def head501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,8 +95,6 @@ async def head501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -126,6 +127,7 @@ async def get501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -136,8 +138,6 @@ async def get501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -183,6 +183,7 @@ async def post505( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -193,8 +194,6 @@ async def post505( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -240,6 +239,7 @@ async def delete505( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -250,8 +250,6 @@ async def delete505( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py index 7e2e755e46f..84896e6dd48 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._http_success_operations import ( build_delete200_request, build_delete202_request, @@ -97,6 +99,7 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -107,8 +110,6 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -141,6 +142,7 @@ async def get200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -151,8 +153,6 @@ async def get200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -189,6 +189,7 @@ async def options200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -199,8 +200,6 @@ async def options200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -250,6 +249,7 @@ async def put200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -260,8 +260,6 @@ async def put200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -307,6 +305,7 @@ async def patch200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -317,8 +316,6 @@ async def patch200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -364,6 +361,7 @@ async def post200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -374,8 +372,6 @@ async def post200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -421,6 +417,7 @@ async def delete200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -431,8 +428,6 @@ async def delete200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -478,6 +473,7 @@ async def put201( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -488,8 +484,6 @@ async def put201( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -535,6 +529,7 @@ async def post201( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -545,8 +540,6 @@ async def post201( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -592,6 +585,7 @@ async def put202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -602,8 +596,6 @@ async def put202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -649,6 +641,7 @@ async def patch202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -659,8 +652,6 @@ async def patch202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -706,6 +697,7 @@ async def post202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -716,8 +708,6 @@ async def post202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -763,6 +753,7 @@ async def delete202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -773,8 +764,6 @@ async def delete202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -807,6 +796,7 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -817,8 +807,6 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -864,6 +852,7 @@ async def put204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -874,8 +863,6 @@ async def put204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -921,6 +908,7 @@ async def patch204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -931,8 +919,6 @@ async def patch204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -978,6 +964,7 @@ async def post204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -988,8 +975,6 @@ async def post204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1035,6 +1020,7 @@ async def delete204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1045,8 +1031,6 @@ async def delete204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1079,6 +1063,7 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1089,8 +1074,6 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py index 865f8106d51..fc432aa70a9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiple_responses_operations import ( build_get200_model201_model_default_error200_valid_request, build_get200_model201_model_default_error201_valid_request, @@ -113,6 +115,7 @@ async def get200_model204_no_model_default_error200_valid( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -123,8 +126,6 @@ async def get200_model204_no_model_default_error200_valid( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -165,6 +166,7 @@ async def get200_model204_no_model_default_error204_valid( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +177,6 @@ async def get200_model204_no_model_default_error204_valid( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -217,6 +217,7 @@ async def get200_model204_no_model_default_error201_invalid( # pylint: disable= headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -227,8 +228,6 @@ async def get200_model204_no_model_default_error201_invalid( # pylint: disable= response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -269,6 +268,7 @@ async def get200_model204_no_model_default_error202_none( # pylint: disable=nam headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,8 +279,6 @@ async def get200_model204_no_model_default_error202_none( # pylint: disable=nam response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -321,6 +319,7 @@ async def get200_model204_no_model_default_error400_valid( # pylint: disable=na headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -331,8 +330,6 @@ async def get200_model204_no_model_default_error400_valid( # pylint: disable=na response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -373,6 +370,7 @@ async def get200_model201_model_default_error200_valid( # pylint: disable=name- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -383,8 +381,6 @@ async def get200_model201_model_default_error200_valid( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -427,6 +423,7 @@ async def get200_model201_model_default_error201_valid( # pylint: disable=name- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -437,8 +434,6 @@ async def get200_model201_model_default_error201_valid( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -481,6 +476,7 @@ async def get200_model201_model_default_error400_valid( # pylint: disable=name- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,8 +487,6 @@ async def get200_model201_model_default_error400_valid( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -536,6 +530,7 @@ async def get200_model_a201_model_c404_model_d_default_error200_valid( # pylint headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -546,8 +541,6 @@ async def get200_model_a201_model_c404_model_d_default_error200_valid( # pylint response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -594,6 +587,7 @@ async def get200_model_a201_model_c404_model_d_default_error201_valid( # pylint headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -604,8 +598,6 @@ async def get200_model_a201_model_c404_model_d_default_error201_valid( # pylint response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -652,6 +644,7 @@ async def get200_model_a201_model_c404_model_d_default_error404_valid( # pylint headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -662,8 +655,6 @@ async def get200_model_a201_model_c404_model_d_default_error404_valid( # pylint response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -710,6 +701,7 @@ async def get200_model_a201_model_c404_model_d_default_error400_valid( # pylint headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -720,8 +712,6 @@ async def get200_model_a201_model_c404_model_d_default_error400_valid( # pylint response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -767,6 +757,7 @@ async def get202_none204_none_default_error202_none( # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -777,8 +768,6 @@ async def get202_none204_none_default_error202_none( # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -813,6 +802,7 @@ async def get202_none204_none_default_error204_none( # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -823,8 +813,6 @@ async def get202_none204_none_default_error204_none( # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -859,6 +847,7 @@ async def get202_none204_none_default_error400_valid( # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -869,8 +858,6 @@ async def get202_none204_none_default_error400_valid( # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -905,6 +892,7 @@ async def get202_none204_none_default_none202_invalid( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -915,8 +903,6 @@ async def get202_none204_none_default_none202_invalid( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -950,6 +936,7 @@ async def get202_none204_none_default_none204_none( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -960,8 +947,6 @@ async def get202_none204_none_default_none204_none( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -995,6 +980,7 @@ async def get202_none204_none_default_none400_none( # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1005,8 +991,6 @@ async def get202_none204_none_default_none400_none( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1040,6 +1024,7 @@ async def get202_none204_none_default_none400_invalid( # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1050,8 +1035,6 @@ async def get202_none204_none_default_none400_invalid( # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1083,6 +1066,7 @@ async def get_default_model_a200_valid(self, **kwargs: Any) -> _models.MyExcepti headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1093,8 +1077,6 @@ async def get_default_model_a200_valid(self, **kwargs: Any) -> _models.MyExcepti response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1130,6 +1112,7 @@ async def get_default_model_a200_none(self, **kwargs: Any) -> _models.MyExceptio headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1140,8 +1123,6 @@ async def get_default_model_a200_none(self, **kwargs: Any) -> _models.MyExceptio response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1179,6 +1160,7 @@ async def get_default_model_a400_valid( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1189,8 +1171,6 @@ async def get_default_model_a400_valid( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.MyException, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1225,6 +1205,7 @@ async def get_default_model_a400_none( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1235,8 +1216,6 @@ async def get_default_model_a400_none( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.MyException, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1271,6 +1250,7 @@ async def get_default_none200_invalid( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1281,8 +1261,6 @@ async def get_default_none200_invalid( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1314,6 +1292,7 @@ async def get_default_none200_none(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1324,8 +1303,6 @@ async def get_default_none200_none(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1359,6 +1336,7 @@ async def get_default_none400_invalid( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1369,8 +1347,6 @@ async def get_default_none400_invalid( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1402,6 +1378,7 @@ async def get_default_none400_none(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1412,8 +1389,6 @@ async def get_default_none400_none(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1446,6 +1421,7 @@ async def get200_model_a200_none(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1456,8 +1432,6 @@ async def get200_model_a200_none(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1493,6 +1467,7 @@ async def get200_model_a200_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1503,8 +1478,6 @@ async def get200_model_a200_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1540,6 +1513,7 @@ async def get200_model_a200_invalid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1550,8 +1524,6 @@ async def get200_model_a200_invalid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1587,6 +1559,7 @@ async def get200_model_a400_none(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1597,8 +1570,6 @@ async def get200_model_a400_none(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1634,6 +1605,7 @@ async def get200_model_a400_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1644,8 +1616,6 @@ async def get200_model_a400_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1681,6 +1651,7 @@ async def get200_model_a400_invalid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1691,8 +1662,6 @@ async def get200_model_a400_invalid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1728,6 +1697,7 @@ async def get200_model_a202_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1738,8 +1708,6 @@ async def get200_model_a202_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py index b79dfaaa392..d75d6d01e28 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -483,6 +485,7 @@ def head400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -493,8 +496,6 @@ def head400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -527,6 +528,7 @@ def get400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -537,8 +539,6 @@ def get400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -571,6 +571,7 @@ def options400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -581,8 +582,6 @@ def options400(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -628,6 +627,7 @@ def put400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -638,8 +638,6 @@ def put400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -685,6 +683,7 @@ def patch400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -695,8 +694,6 @@ def patch400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -742,6 +739,7 @@ def post400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -752,8 +750,6 @@ def post400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -799,6 +795,7 @@ def delete400( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -809,8 +806,6 @@ def delete400( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -843,6 +838,7 @@ def head401(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -853,8 +849,6 @@ def head401(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -887,6 +881,7 @@ def get402(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -897,8 +892,6 @@ def get402(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -931,6 +924,7 @@ def options403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -941,8 +935,6 @@ def options403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -975,6 +967,7 @@ def get403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -985,8 +978,6 @@ def get403(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1032,6 +1023,7 @@ def put404( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1042,8 +1034,6 @@ def put404( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1089,6 +1079,7 @@ def patch405( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1099,8 +1090,6 @@ def patch405( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1146,6 +1135,7 @@ def post406( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1156,8 +1146,6 @@ def post406( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1203,6 +1191,7 @@ def delete407( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1213,8 +1202,6 @@ def delete407( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1260,6 +1247,7 @@ def put409( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1270,8 +1258,6 @@ def put409( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1304,6 +1290,7 @@ def head410(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1314,8 +1301,6 @@ def head410(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1348,6 +1333,7 @@ def get411(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1358,8 +1344,6 @@ def get411(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1392,6 +1376,7 @@ def options412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1402,8 +1387,6 @@ def options412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1436,6 +1419,7 @@ def get412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1446,8 +1430,6 @@ def get412(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1493,6 +1475,7 @@ def put413( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1503,8 +1486,6 @@ def put413( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1550,6 +1531,7 @@ def patch414( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1560,8 +1542,6 @@ def patch414( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1607,6 +1587,7 @@ def post415( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1617,8 +1598,6 @@ def post415( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1651,6 +1630,7 @@ def get416(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1661,8 +1641,6 @@ def get416(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1708,6 +1686,7 @@ def delete417( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1718,8 +1697,6 @@ def delete417( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1752,6 +1729,7 @@ def head429(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1762,8 +1740,6 @@ def head429(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py index c31afab7916..b64355798c4 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -122,6 +124,7 @@ def get_empty_error(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -132,8 +135,6 @@ def get_empty_error(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -170,6 +171,7 @@ def get_no_model_error(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -180,8 +182,6 @@ def get_no_model_error(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -217,6 +217,7 @@ def get_no_model_empty(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -227,8 +228,6 @@ def get_no_model_empty(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py index 9bacd9cc4f7..4460394152a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -325,6 +327,7 @@ def head300(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -335,8 +338,6 @@ def head300(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200, 300]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -373,6 +374,7 @@ def get300(self, **kwargs: Any) -> Optional[List[str]]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -383,8 +385,6 @@ def get300(self, **kwargs: Any) -> Optional[List[str]]: response = pipeline_response.http_response if response.status_code not in [200, 300]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -426,6 +426,7 @@ def head301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -436,8 +437,6 @@ def head301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200, 301]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -474,6 +473,7 @@ def get301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -484,8 +484,6 @@ def get301(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200, 301]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -536,6 +534,7 @@ def put301( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -546,8 +545,6 @@ def put301( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [301]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -583,6 +580,7 @@ def head302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -593,8 +591,6 @@ def head302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200, 302]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -631,6 +627,7 @@ def get302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -641,8 +638,6 @@ def get302(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200, 302]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -693,6 +688,7 @@ def patch302( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -703,8 +699,6 @@ def patch302( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [302]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -754,6 +748,7 @@ def post303( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -764,8 +759,6 @@ def post303( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 303]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -802,6 +795,7 @@ def head307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -812,8 +806,6 @@ def head307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -850,6 +842,7 @@ def get307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -860,8 +853,6 @@ def get307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -898,6 +889,7 @@ def options307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -908,8 +900,6 @@ def options307(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -959,6 +949,7 @@ def put307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -969,8 +960,6 @@ def put307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1020,6 +1009,7 @@ def patch307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1030,8 +1020,6 @@ def patch307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1081,6 +1069,7 @@ def post307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1091,8 +1080,6 @@ def post307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1142,6 +1129,7 @@ def delete307( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1152,8 +1140,6 @@ def delete307( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 307]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py index 40a60c0e578..4ffd0a08c7c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -224,6 +226,7 @@ def head408(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,8 +237,6 @@ def head408(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -281,6 +282,7 @@ def put500( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,8 +293,6 @@ def put500( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -338,6 +338,7 @@ def patch500( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -348,8 +349,6 @@ def patch500( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -382,6 +381,7 @@ def get502(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -392,8 +392,6 @@ def get502(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -426,6 +424,7 @@ def options502(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -436,8 +435,6 @@ def options502(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -487,6 +484,7 @@ def post503( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -497,8 +495,6 @@ def post503( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -544,6 +540,7 @@ def delete503( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -554,8 +551,6 @@ def delete503( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -601,6 +596,7 @@ def put504( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -611,8 +607,6 @@ def put504( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -658,6 +652,7 @@ def patch504( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -668,8 +663,6 @@ def patch504( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py index e894d973c16..c685625fba6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -142,6 +144,7 @@ def head501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -152,8 +155,6 @@ def head501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -186,6 +187,7 @@ def get501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +198,6 @@ def get501(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -243,6 +243,7 @@ def post505( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,8 +254,6 @@ def post505( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -300,6 +299,7 @@ def delete505( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,8 +310,6 @@ def delete505( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in []: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py index e21677e544b..0833c794138 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -388,6 +390,7 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +401,6 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -432,6 +433,7 @@ def get200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -442,8 +444,6 @@ def get200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -480,6 +480,7 @@ def options200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -490,8 +491,6 @@ def options200(self, **kwargs: Any) -> bool: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -541,6 +540,7 @@ def put200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -551,8 +551,6 @@ def put200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -598,6 +596,7 @@ def patch200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -608,8 +607,6 @@ def patch200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -655,6 +652,7 @@ def post200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -665,8 +663,6 @@ def post200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -712,6 +708,7 @@ def delete200( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -722,8 +719,6 @@ def delete200( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -769,6 +764,7 @@ def put201( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -779,8 +775,6 @@ def put201( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -826,6 +820,7 @@ def post201( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -836,8 +831,6 @@ def post201( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -883,6 +876,7 @@ def put202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -893,8 +887,6 @@ def put202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -940,6 +932,7 @@ def patch202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -950,8 +943,6 @@ def patch202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -997,6 +988,7 @@ def post202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1007,8 +999,6 @@ def post202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1054,6 +1044,7 @@ def delete202( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1064,8 +1055,6 @@ def delete202( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1098,6 +1087,7 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1108,8 +1098,6 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1155,6 +1143,7 @@ def put204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1165,8 +1154,6 @@ def put204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1212,6 +1199,7 @@ def patch204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1222,8 +1210,6 @@ def patch204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1269,6 +1255,7 @@ def post204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1279,8 +1266,6 @@ def post204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1326,6 +1311,7 @@ def delete204( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1336,8 +1322,6 @@ def delete204( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1370,6 +1354,7 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1380,8 +1365,6 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [204, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py index 3270872cee8..2e6effc07f3 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -540,6 +542,7 @@ def get200_model204_no_model_default_error200_valid( # pylint: disable=name-too headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -550,8 +553,6 @@ def get200_model204_no_model_default_error200_valid( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -592,6 +593,7 @@ def get200_model204_no_model_default_error204_valid( # pylint: disable=name-too headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -602,8 +604,6 @@ def get200_model204_no_model_default_error204_valid( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -644,6 +644,7 @@ def get200_model204_no_model_default_error201_invalid( # pylint: disable=name-t headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -654,8 +655,6 @@ def get200_model204_no_model_default_error201_invalid( # pylint: disable=name-t response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -696,6 +695,7 @@ def get200_model204_no_model_default_error202_none( # pylint: disable=name-too- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -706,8 +706,6 @@ def get200_model204_no_model_default_error202_none( # pylint: disable=name-too- response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -748,6 +746,7 @@ def get200_model204_no_model_default_error400_valid( # pylint: disable=name-too headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -758,8 +757,6 @@ def get200_model204_no_model_default_error400_valid( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [200, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -800,6 +797,7 @@ def get200_model201_model_default_error200_valid( # pylint: disable=name-too-lo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -810,8 +808,6 @@ def get200_model201_model_default_error200_valid( # pylint: disable=name-too-lo response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -854,6 +850,7 @@ def get200_model201_model_default_error201_valid( # pylint: disable=name-too-lo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -864,8 +861,6 @@ def get200_model201_model_default_error201_valid( # pylint: disable=name-too-lo response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -908,6 +903,7 @@ def get200_model201_model_default_error400_valid( # pylint: disable=name-too-lo headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -918,8 +914,6 @@ def get200_model201_model_default_error400_valid( # pylint: disable=name-too-lo response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -963,6 +957,7 @@ def get200_model_a201_model_c404_model_d_default_error200_valid( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -973,8 +968,6 @@ def get200_model_a201_model_c404_model_d_default_error200_valid( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1021,6 +1014,7 @@ def get200_model_a201_model_c404_model_d_default_error201_valid( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1031,8 +1025,6 @@ def get200_model_a201_model_c404_model_d_default_error201_valid( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1079,6 +1071,7 @@ def get200_model_a201_model_c404_model_d_default_error404_valid( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1089,8 +1082,6 @@ def get200_model_a201_model_c404_model_d_default_error404_valid( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1137,6 +1128,7 @@ def get200_model_a201_model_c404_model_d_default_error400_valid( # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1147,8 +1139,6 @@ def get200_model_a201_model_c404_model_d_default_error400_valid( # pylint: disa response = pipeline_response.http_response if response.status_code not in [200, 201, 404]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1194,6 +1184,7 @@ def get202_none204_none_default_error202_none( # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1204,8 +1195,6 @@ def get202_none204_none_default_error202_none( # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1240,6 +1229,7 @@ def get202_none204_none_default_error204_none( # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1250,8 +1240,6 @@ def get202_none204_none_default_error204_none( # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1286,6 +1274,7 @@ def get202_none204_none_default_error400_valid( # pylint: disable=inconsistent- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1296,8 +1285,6 @@ def get202_none204_none_default_error400_valid( # pylint: disable=inconsistent- response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1332,6 +1319,7 @@ def get202_none204_none_default_none202_invalid( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1342,8 +1330,6 @@ def get202_none204_none_default_none202_invalid( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1377,6 +1363,7 @@ def get202_none204_none_default_none204_none( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1387,8 +1374,6 @@ def get202_none204_none_default_none204_none( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1422,6 +1407,7 @@ def get202_none204_none_default_none400_none( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1432,8 +1418,6 @@ def get202_none204_none_default_none400_none( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1467,6 +1451,7 @@ def get202_none204_none_default_none400_invalid( # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1477,8 +1462,6 @@ def get202_none204_none_default_none400_invalid( # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1510,6 +1493,7 @@ def get_default_model_a200_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1520,8 +1504,6 @@ def get_default_model_a200_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1557,6 +1539,7 @@ def get_default_model_a200_none(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1567,8 +1550,6 @@ def get_default_model_a200_none(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1604,6 +1585,7 @@ def get_default_model_a400_valid(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1614,8 +1596,6 @@ def get_default_model_a400_valid(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.MyException, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1648,6 +1628,7 @@ def get_default_model_a400_none(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1658,8 +1639,6 @@ def get_default_model_a400_none(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.MyException, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1692,6 +1671,7 @@ def get_default_none200_invalid(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1702,8 +1682,6 @@ def get_default_none200_invalid(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1735,6 +1713,7 @@ def get_default_none200_none(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1745,8 +1724,6 @@ def get_default_none200_none(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1778,6 +1755,7 @@ def get_default_none400_invalid(self, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1788,8 +1766,6 @@ def get_default_none400_invalid(self, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1821,6 +1797,7 @@ def get_default_none400_none(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1831,8 +1808,6 @@ def get_default_none400_none(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1865,6 +1840,7 @@ def get200_model_a200_none(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1875,8 +1851,6 @@ def get200_model_a200_none(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1912,6 +1886,7 @@ def get200_model_a200_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1922,8 +1897,6 @@ def get200_model_a200_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1959,6 +1932,7 @@ def get200_model_a200_invalid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1969,8 +1943,6 @@ def get200_model_a200_invalid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2006,6 +1978,7 @@ def get200_model_a400_none(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2016,8 +1989,6 @@ def get200_model_a400_none(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2053,6 +2024,7 @@ def get200_model_a400_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2063,8 +2035,6 @@ def get200_model_a400_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2100,6 +2070,7 @@ def get200_model_a400_invalid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2110,8 +2081,6 @@ def get200_model_a400_invalid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2147,6 +2116,7 @@ def get200_model_a202_valid(self, **kwargs: Any) -> _models.MyException: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2157,8 +2127,6 @@ def get200_model_a202_valid(self, **kwargs: Any) -> _models.MyException: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_vendor.py index f44286f6df3..5da5ef74d1f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import IncorrectReturnedErrorModelConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class IncorrectReturnedErrorModelMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_vendor.py index 890e7156ceb..1e6fcc92549 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import IncorrectReturnedErrorModelConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py index a4fefcfbf6a..bd5e5e22ced 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._incorrect_returned_error_model_operations import build_get_incorrect_error_from_server_request from .._vendor import IncorrectReturnedErrorModelMixinABC @@ -62,6 +64,7 @@ async def get_incorrect_error_from_server( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -72,8 +75,6 @@ async def get_incorrect_error_from_server( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py index e70dd6893f9..8aa97c44987 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import IncorrectReturnedErrorModelMixinABC +from .._vendor import IncorrectReturnedErrorModelMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,6 +71,7 @@ def get_incorrect_error_from_server(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -80,8 +82,6 @@ def get_incorrect_error_from_server(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_vendor.py index 059f572c7b2..e6389a0d4d0 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MediaTypesClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/_vendor.py index 2e6d0c12365..c4778c60b1c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py index af9db13747a..87fb103d029 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._media_types_client_operations import ( build_analyze_body_no_accept_header_request, build_analyze_body_request, @@ -121,6 +123,7 @@ async def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,8 +134,6 @@ async def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -224,6 +225,7 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,8 +236,6 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -277,6 +277,7 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -287,8 +288,6 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -332,6 +331,7 @@ async def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -342,8 +342,6 @@ async def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -388,6 +386,7 @@ async def binary_body_with_three_content_types(self, message: IO[bytes], **kwarg headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +397,6 @@ async def binary_body_with_three_content_types(self, message: IO[bytes], **kwarg response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -463,6 +460,7 @@ async def _body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -473,8 +471,6 @@ async def _body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -517,6 +513,7 @@ async def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -527,8 +524,6 @@ async def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/operations/_media_types_client_operations.py index a7c394c688d..b107faeb026 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/operations/_media_types_client_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import MediaTypesClientMixinABC +from .._vendor import MediaTypesClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -236,6 +237,7 @@ def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes]]] = N headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -246,8 +248,6 @@ def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes]]] = N response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -339,6 +339,7 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -349,8 +350,6 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -392,6 +391,7 @@ def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -402,8 +402,6 @@ def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -447,6 +445,7 @@ def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -457,8 +456,6 @@ def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -503,6 +500,7 @@ def binary_body_with_three_content_types(self, message: IO[bytes], **kwargs: Any headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -513,8 +511,6 @@ def binary_body_with_three_content_types(self, message: IO[bytes], **kwargs: Any response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -576,6 +572,7 @@ def _body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -586,8 +583,6 @@ def _body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -630,6 +625,7 @@ def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -640,8 +636,6 @@ def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_vendor.py index 059f572c7b2..e6389a0d4d0 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MediaTypesClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_vendor.py index 2e6d0c12365..c4778c60b1c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py index 4d5a14d2016..f41eeb48d44 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._media_types_client_operations import ( build_analyze_body_no_accept_header_request, build_analyze_body_request, @@ -121,6 +123,7 @@ async def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,8 +134,6 @@ async def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -224,6 +225,7 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,8 +236,6 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -277,6 +277,7 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -287,8 +288,6 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -332,6 +331,7 @@ async def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -342,8 +342,6 @@ async def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -388,6 +386,7 @@ async def binary_body_with_three_content_types(self, message: IO[bytes], **kwarg headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +397,6 @@ async def binary_body_with_three_content_types(self, message: IO[bytes], **kwarg response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -503,6 +500,7 @@ async def body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -513,8 +511,6 @@ async def body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -557,6 +553,7 @@ async def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -567,8 +564,6 @@ async def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py index be2c1fa3231..ec862580b68 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import MediaTypesClientMixinABC +from .._vendor import MediaTypesClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -236,6 +237,7 @@ def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes]]] = N headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -246,8 +248,6 @@ def analyze_body(self, input: Optional[Union[_models.SourcePath, IO[bytes]]] = N response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -339,6 +339,7 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -349,8 +350,6 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -392,6 +391,7 @@ def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -402,8 +402,6 @@ def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -447,6 +445,7 @@ def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -457,8 +456,6 @@ def binary_body_with_two_content_types(self, message: IO[bytes], **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -503,6 +500,7 @@ def binary_body_with_three_content_types(self, message: IO[bytes], **kwargs: Any headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -513,8 +511,6 @@ def binary_body_with_three_content_types(self, message: IO[bytes], **kwargs: Any response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -618,6 +614,7 @@ def body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: Any) - headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -628,8 +625,6 @@ def body_three_types(self, message: Union[Any, IO[bytes], str], **kwargs: Any) - response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -672,6 +667,7 @@ def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -682,8 +678,6 @@ def put_text_and_json_body(self, message: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_vendor.py index bc7fd4a52a0..5289f742597 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MergePatchJsonClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MergePatchJsonClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/_vendor.py index 0521b5d17da..b4b7cf93232 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MergePatchJsonClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py index 426d5ac5532..e9b8b003c40 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict +from ..._vendor import _convert_request from ...operations._merge_patch_json_client_operations import build_patch_single_request from .._vendor import MergePatchJsonClientMixinABC @@ -68,6 +70,7 @@ async def patch_single(self, body: JSON, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -78,8 +81,6 @@ async def patch_single(self, body: JSON, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/operations/_merge_patch_json_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/operations/_merge_patch_json_client_operations.py index 79b556256c3..76c659601c4 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/operations/_merge_patch_json_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/operations/_merge_patch_json_client_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import MergePatchJsonClientMixinABC +from .._vendor import MergePatchJsonClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -88,6 +89,7 @@ def patch_single(self, body: JSON, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -98,8 +100,6 @@ def patch_single(self, body: JSON, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_vendor.py index a9c5cb94413..139e656ed38 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutoRestResourceFlatteningTestServiceMixinABC(ABC): # pylint: disable=name-too-long """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_vendor.py index a7599da945c..8df7cec19de 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py index 8f5ca9b2414..41324a95b67 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._auto_rest_resource_flattening_test_service_operations import ( build_get_array_request, build_get_dictionary_request, @@ -141,6 +143,7 @@ async def put_array( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -151,8 +154,6 @@ async def put_array( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -188,6 +189,7 @@ async def get_array(self, **kwargs: Any) -> List[_models.FlattenedProduct]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -198,8 +200,6 @@ async def get_array(self, **kwargs: Any) -> List[_models.FlattenedProduct]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -304,6 +304,7 @@ async def put_wrapped_array( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -314,8 +315,6 @@ async def put_wrapped_array( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -352,6 +351,7 @@ async def get_wrapped_array(self, **kwargs: Any) -> List[_models.ProductWrapper] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -362,8 +362,6 @@ async def get_wrapped_array(self, **kwargs: Any) -> List[_models.ProductWrapper] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -465,6 +463,7 @@ async def put_dictionary( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -475,8 +474,6 @@ async def put_dictionary( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -512,6 +509,7 @@ async def get_dictionary(self, **kwargs: Any) -> Dict[str, _models.FlattenedProd headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -522,8 +520,6 @@ async def get_dictionary(self, **kwargs: Any) -> Dict[str, _models.FlattenedProd response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -631,6 +627,7 @@ async def put_resource_collection( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -641,8 +638,6 @@ async def put_resource_collection( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -678,6 +673,7 @@ async def get_resource_collection(self, **kwargs: Any) -> _models.ResourceCollec headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -688,8 +684,6 @@ async def get_resource_collection(self, **kwargs: Any) -> _models.ResourceCollec response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -791,6 +785,7 @@ async def put_simple_product( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -801,8 +796,6 @@ async def put_simple_product( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -882,6 +875,7 @@ async def post_flattened_simple_product( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -892,8 +886,6 @@ async def post_flattened_simple_product( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -971,6 +963,7 @@ async def put_simple_product_with_grouping( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -981,8 +974,6 @@ async def put_simple_product_with_grouping( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py index add61d5ed54..15b42e73523 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import AutoRestResourceFlatteningTestServiceMixinABC +from .._vendor import AutoRestResourceFlatteningTestServiceMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -314,6 +315,7 @@ def put_array( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -324,8 +326,6 @@ def put_array( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -361,6 +361,7 @@ def get_array(self, **kwargs: Any) -> List[_models.FlattenedProduct]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -371,8 +372,6 @@ def get_array(self, **kwargs: Any) -> List[_models.FlattenedProduct]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -477,6 +476,7 @@ def put_wrapped_array( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,8 +487,6 @@ def put_wrapped_array( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -525,6 +523,7 @@ def get_wrapped_array(self, **kwargs: Any) -> List[_models.ProductWrapper]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,8 +534,6 @@ def get_wrapped_array(self, **kwargs: Any) -> List[_models.ProductWrapper]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -638,6 +635,7 @@ def put_dictionary( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -648,8 +646,6 @@ def put_dictionary( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -685,6 +681,7 @@ def get_dictionary(self, **kwargs: Any) -> Dict[str, _models.FlattenedProduct]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -695,8 +692,6 @@ def get_dictionary(self, **kwargs: Any) -> Dict[str, _models.FlattenedProduct]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -804,6 +799,7 @@ def put_resource_collection( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -814,8 +810,6 @@ def put_resource_collection( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -851,6 +845,7 @@ def get_resource_collection(self, **kwargs: Any) -> _models.ResourceCollection: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -861,8 +856,6 @@ def get_resource_collection(self, **kwargs: Any) -> _models.ResourceCollection: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -964,6 +957,7 @@ def put_simple_product( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -974,8 +968,6 @@ def put_simple_product( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1055,6 +1047,7 @@ def post_flattened_simple_product( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1065,8 +1058,6 @@ def post_flattened_simple_product( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1144,6 +1135,7 @@ def put_simple_product_with_grouping( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1154,8 +1146,6 @@ def put_simple_product_with_grouping( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_vendor.py index ab12708447c..0c3f73c1af8 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultipleInheritanceServiceClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class MultipleInheritanceServiceClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_vendor.py index 22e0b34b3f3..f62abf36f85 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import MultipleInheritanceServiceClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py index 883690a1e8d..cce0e11e655 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._multiple_inheritance_service_client_operations import ( build_get_cat_request, build_get_feline_request, @@ -75,6 +77,7 @@ async def get_horse(self, **kwargs: Any) -> _models.Horse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -85,8 +88,6 @@ async def get_horse(self, **kwargs: Any) -> _models.Horse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -166,6 +167,7 @@ async def put_horse(self, horse: Union[_models.Horse, IO[bytes]], **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -176,8 +178,6 @@ async def put_horse(self, horse: Union[_models.Horse, IO[bytes]], **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -213,6 +213,7 @@ async def get_pet(self, **kwargs: Any) -> _models.Pet: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -223,8 +224,6 @@ async def get_pet(self, **kwargs: Any) -> _models.Pet: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -269,6 +268,7 @@ async def put_pet(self, name: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,8 +279,6 @@ async def put_pet(self, name: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -316,6 +314,7 @@ async def get_feline(self, **kwargs: Any) -> _models.Feline: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -326,8 +325,6 @@ async def get_feline(self, **kwargs: Any) -> _models.Feline: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -407,6 +404,7 @@ async def put_feline(self, feline: Union[_models.Feline, IO[bytes]], **kwargs: A headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -417,8 +415,6 @@ async def put_feline(self, feline: Union[_models.Feline, IO[bytes]], **kwargs: A response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -454,6 +450,7 @@ async def get_cat(self, **kwargs: Any) -> _models.Cat: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -464,8 +461,6 @@ async def get_cat(self, **kwargs: Any) -> _models.Cat: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -547,6 +542,7 @@ async def put_cat(self, cat: Union[_models.Cat, IO[bytes]], **kwargs: Any) -> st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,8 +553,6 @@ async def put_cat(self, cat: Union[_models.Cat, IO[bytes]], **kwargs: Any) -> st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -595,6 +589,7 @@ async def get_kitten(self, **kwargs: Any) -> _models.Kitten: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -605,8 +600,6 @@ async def get_kitten(self, **kwargs: Any) -> _models.Kitten: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -691,6 +684,7 @@ async def put_kitten(self, kitten: Union[_models.Kitten, IO[bytes]], **kwargs: A headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -701,8 +695,6 @@ async def put_kitten(self, kitten: Union[_models.Kitten, IO[bytes]], **kwargs: A response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py index ca8bba2f740..302509da94c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py @@ -19,13 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import MultipleInheritanceServiceClientMixinABC +from .._vendor import MultipleInheritanceServiceClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -222,6 +223,7 @@ def get_horse(self, **kwargs: Any) -> _models.Horse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,8 +234,6 @@ def get_horse(self, **kwargs: Any) -> _models.Horse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -313,6 +313,7 @@ def put_horse(self, horse: Union[_models.Horse, IO[bytes]], **kwargs: Any) -> st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -323,8 +324,6 @@ def put_horse(self, horse: Union[_models.Horse, IO[bytes]], **kwargs: Any) -> st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -360,6 +359,7 @@ def get_pet(self, **kwargs: Any) -> _models.Pet: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -370,8 +370,6 @@ def get_pet(self, **kwargs: Any) -> _models.Pet: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -416,6 +414,7 @@ def put_pet(self, name: str, **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -426,8 +425,6 @@ def put_pet(self, name: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -463,6 +460,7 @@ def get_feline(self, **kwargs: Any) -> _models.Feline: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -473,8 +471,6 @@ def get_feline(self, **kwargs: Any) -> _models.Feline: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -554,6 +550,7 @@ def put_feline(self, feline: Union[_models.Feline, IO[bytes]], **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -564,8 +561,6 @@ def put_feline(self, feline: Union[_models.Feline, IO[bytes]], **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -601,6 +596,7 @@ def get_cat(self, **kwargs: Any) -> _models.Cat: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -611,8 +607,6 @@ def get_cat(self, **kwargs: Any) -> _models.Cat: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -694,6 +688,7 @@ def put_cat(self, cat: Union[_models.Cat, IO[bytes]], **kwargs: Any) -> str: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -704,8 +699,6 @@ def put_cat(self, cat: Union[_models.Cat, IO[bytes]], **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -742,6 +735,7 @@ def get_kitten(self, **kwargs: Any) -> _models.Kitten: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -752,8 +746,6 @@ def get_kitten(self, **kwargs: Any) -> _models.Kitten: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -838,6 +830,7 @@ def put_kitten(self, kitten: Union[_models.Kitten, IO[bytes]], **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -848,8 +841,6 @@ def put_kitten(self, kitten: Union[_models.Kitten, IO[bytes]], **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py index 4b115578546..68bf635cf8a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._float_operations import build_get_request, build_put_request if sys.version_info >= (3, 9): @@ -86,6 +88,7 @@ async def put(self, input: Optional[Union[float, _models.FloatEnum]] = None, **k headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def put(self, input: Optional[Union[float, _models.FloatEnum]] = None, **k response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -133,6 +134,7 @@ async def get(self, **kwargs: Any) -> Union[float, _models.FloatEnum]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -143,8 +145,6 @@ async def get(self, **kwargs: Any) -> Union[float, _models.FloatEnum]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations_operations.py index 096aef49d38..2cc594802b6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._int_operations_operations import build_get_request, build_put_request if sys.version_info >= (3, 9): @@ -86,6 +88,7 @@ async def put(self, input: Optional[Union[int, _models.IntEnum]] = None, **kwarg headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -96,8 +99,6 @@ async def put(self, input: Optional[Union[int, _models.IntEnum]] = None, **kwarg response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -133,6 +134,7 @@ async def get(self, **kwargs: Any) -> Union[int, _models.IntEnum]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -143,8 +145,6 @@ async def get(self, **kwargs: Any) -> Union[int, _models.IntEnum]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py index 824179de458..099418af4f2 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,6 +122,7 @@ def put(self, input: Optional[Union[float, _models.FloatEnum]] = None, **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -130,8 +133,6 @@ def put(self, input: Optional[Union[float, _models.FloatEnum]] = None, **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -167,6 +168,7 @@ def get(self, **kwargs: Any) -> Union[float, _models.FloatEnum]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def get(self, **kwargs: Any) -> Union[float, _models.FloatEnum]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations_operations.py index 6ee8a564715..4f03dc0e17d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,6 +122,7 @@ def put(self, input: Optional[Union[int, _models.IntEnum]] = None, **kwargs: Any headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -130,8 +133,6 @@ def put(self, input: Optional[Union[int, _models.IntEnum]] = None, **kwargs: Any response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -167,6 +168,7 @@ def get(self, **kwargs: Any) -> Union[int, _models.IntEnum]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -177,8 +179,6 @@ def get(self, **kwargs: Any) -> Union[int, _models.IntEnum]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_vendor.py index 38f277f20f4..5bf024b7798 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ObjectTypeClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class ObjectTypeClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_vendor.py index 97ff8285a95..f313807443d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ObjectTypeClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py index bbc6d8669ba..2b0b5de7b5b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict +from ..._vendor import _convert_request from ...operations._object_type_client_operations import build_get_request, build_put_request from .._vendor import ObjectTypeClientMixinABC @@ -62,6 +64,7 @@ async def get(self, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -72,8 +75,6 @@ async def get(self, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) @@ -119,6 +120,7 @@ async def put(self, put_object: JSON, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -129,8 +131,6 @@ async def put(self, put_object: JSON, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py index 44b05d10099..948c62621ba 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import ObjectTypeClientMixinABC +from .._vendor import ObjectTypeClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -96,6 +97,7 @@ def get(self, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -106,8 +108,6 @@ def get(self, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) @@ -153,6 +153,7 @@ def put(self, put_object: JSON, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -163,8 +164,6 @@ def put(self, put_object: JSON, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize("object", pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_vendor.py index dc910ddc7e5..d756d07f319 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AnythingClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/_vendor.py index 29d65bdd121..2007e9f7a76 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py index f2671ee3f00..c6d091f4a40 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict +from ..._vendor import _convert_request from ...operations._anything_client_operations import ( build_get_array_request, build_get_object_request, @@ -68,6 +70,7 @@ async def get_object(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -78,8 +81,6 @@ async def get_object(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -123,6 +124,7 @@ async def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -133,8 +135,6 @@ async def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -166,6 +166,7 @@ async def get_string(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -176,8 +177,6 @@ async def get_string(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -221,6 +220,7 @@ async def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,8 +231,6 @@ async def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -264,6 +262,7 @@ async def get_array(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -274,8 +273,6 @@ async def get_array(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -319,6 +316,7 @@ async def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -329,8 +327,6 @@ async def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/operations/_anything_client_operations.py index 16b288c25d8..5e68127ea9c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/operations/_anything_client_operations.py @@ -18,12 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import AnythingClientMixinABC +from .._vendor import AnythingClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -148,6 +149,7 @@ def get_object(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -158,8 +160,6 @@ def get_object(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -203,6 +203,7 @@ def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -213,8 +214,6 @@ def put_object(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -246,6 +245,7 @@ def get_string(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,8 +256,6 @@ def get_string(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -301,6 +299,7 @@ def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,8 +310,6 @@ def put_string(self, input: Any, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -344,6 +341,7 @@ def get_array(self, **kwargs: Any) -> Any: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -354,8 +352,6 @@ def get_array(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -399,6 +395,7 @@ def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -409,8 +406,6 @@ def put_array(self, input: Any, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py index acaba671f66..905e75e3b53 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._availability_sets_operations import build_update_request if sys.version_info >= (3, 9): @@ -93,6 +95,7 @@ async def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -103,8 +106,6 @@ async def update( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py index 75c698a544c..fbf104dcb0d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -116,6 +118,7 @@ def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -126,8 +129,6 @@ def update( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_vendor.py index 3aa95cca6e2..6038f7aee92 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ParmaterizedEndpointClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class ParmaterizedEndpointClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/_vendor.py index c8495a15c6f..54fe7210a6f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ParmaterizedEndpointClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py index bef061cb6d4..e1fe0052b05 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._parmaterized_endpoint_client_operations import build_get_request from .._vendor import ParmaterizedEndpointClientMixinABC @@ -59,6 +61,7 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -72,8 +75,6 @@ async def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retu response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/operations/_parmaterized_endpoint_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/operations/_parmaterized_endpoint_client_operations.py index 2812639cd79..6aff1fb8f56 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/operations/_parmaterized_endpoint_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/operations/_parmaterized_endpoint_client_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import ParmaterizedEndpointClientMixinABC +from .._vendor import ParmaterizedEndpointClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -69,6 +70,7 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } @@ -82,8 +84,6 @@ def get(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_vendor.py index 3809d97ecea..5576189da06 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestReportServiceConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutoRestReportServiceMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_vendor.py index ebe95d1ea53..52ad4a50f69 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestReportServiceConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py index e6c69dc647f..e83dbf0e725 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._auto_rest_report_service_operations import ( build_get_optional_report_request, build_get_report_request, @@ -68,6 +70,7 @@ async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Di headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -78,8 +81,6 @@ async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Di response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -121,6 +122,7 @@ async def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: A headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,8 +133,6 @@ async def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: A response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py index 1e8d850fcb8..84cb88e4a2c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import AutoRestReportServiceMixinABC +from .._vendor import AutoRestReportServiceMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -107,6 +108,7 @@ def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -117,8 +119,6 @@ def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -160,6 +160,7 @@ def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -170,8 +171,6 @@ def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py index bcec8cd4664..d6657feda81 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._explicit_operations import ( build_post_optional_array_header_request, build_post_optional_array_parameter_request, @@ -112,6 +114,7 @@ async def put_optional_binary_body( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,8 +125,6 @@ async def put_optional_binary_body( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -165,6 +166,7 @@ async def put_required_binary_body( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,8 +177,6 @@ async def put_required_binary_body( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -219,6 +219,7 @@ async def post_required_integer_parameter( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,8 +230,6 @@ async def post_required_integer_parameter( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -275,6 +274,7 @@ async def post_optional_integer_parameter( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -285,8 +285,6 @@ async def post_optional_integer_parameter( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -330,6 +328,7 @@ async def post_required_integer_property( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -340,8 +339,6 @@ async def post_required_integer_property( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -387,6 +384,7 @@ async def post_optional_integer_property( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -397,8 +395,6 @@ async def post_optional_integer_property( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -437,6 +433,7 @@ async def post_required_integer_header( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -447,8 +444,6 @@ async def post_required_integer_header( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -486,6 +481,7 @@ async def post_optional_integer_header( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -496,8 +492,6 @@ async def post_optional_integer_header( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -540,6 +534,7 @@ async def post_required_string_parameter( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -550,8 +545,6 @@ async def post_required_string_parameter( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -596,6 +589,7 @@ async def post_optional_string_parameter( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -606,8 +600,6 @@ async def post_optional_string_parameter( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -651,6 +643,7 @@ async def post_required_string_property( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -661,8 +654,6 @@ async def post_required_string_property( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -708,6 +699,7 @@ async def post_optional_string_property( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -718,8 +710,6 @@ async def post_optional_string_property( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -758,6 +748,7 @@ async def post_required_string_header( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -768,8 +759,6 @@ async def post_required_string_header( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -807,6 +796,7 @@ async def post_optional_string_header( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -817,8 +807,6 @@ async def post_optional_string_header( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -902,6 +890,7 @@ async def post_required_class_parameter( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -912,8 +901,6 @@ async def post_required_class_parameter( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -997,6 +984,7 @@ async def post_optional_class_parameter( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1007,8 +995,6 @@ async def post_optional_class_parameter( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1052,6 +1038,7 @@ async def post_required_class_property( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1062,8 +1049,6 @@ async def post_required_class_property( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1109,6 +1094,7 @@ async def post_optional_class_property( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1119,8 +1105,6 @@ async def post_optional_class_property( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1204,6 +1188,7 @@ async def post_required_array_parameter( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1214,8 +1199,6 @@ async def post_required_array_parameter( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1299,6 +1282,7 @@ async def post_optional_array_parameter( # pylint: disable=inconsistent-return- headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1309,8 +1293,6 @@ async def post_optional_array_parameter( # pylint: disable=inconsistent-return- response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1354,6 +1336,7 @@ async def post_required_array_property( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1364,8 +1347,6 @@ async def post_required_array_property( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1411,6 +1392,7 @@ async def post_optional_array_property( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1421,8 +1403,6 @@ async def post_optional_array_property( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1461,6 +1441,7 @@ async def post_required_array_header( # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1471,8 +1452,6 @@ async def post_required_array_header( # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1510,6 +1489,7 @@ async def post_optional_array_header( # pylint: disable=inconsistent-return-sta headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1520,8 +1500,6 @@ async def post_optional_array_header( # pylint: disable=inconsistent-return-sta response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py index 063f8985317..322bc41c59a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._implicit_operations import ( build_get_optional_global_query_request, build_get_required_global_path_request, @@ -91,6 +93,7 @@ async def get_required_path( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -101,8 +104,6 @@ async def get_required_path( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -140,6 +141,7 @@ async def put_optional_query( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -150,8 +152,6 @@ async def put_optional_query( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -189,6 +189,7 @@ async def put_optional_header( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -199,8 +200,6 @@ async def put_optional_header( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -245,6 +244,7 @@ async def put_optional_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,8 +255,6 @@ async def put_optional_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -298,6 +296,7 @@ async def put_optional_binary_body( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -308,8 +307,6 @@ async def put_optional_binary_body( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -343,6 +340,7 @@ async def get_required_global_path(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -353,8 +351,6 @@ async def get_required_global_path(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -388,6 +384,7 @@ async def get_required_global_query(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -398,8 +395,6 @@ async def get_required_global_query(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -433,6 +428,7 @@ async def get_optional_global_query(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -443,8 +439,6 @@ async def get_optional_global_query(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py index 86c9150fab2..669edcff3d5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -507,6 +509,7 @@ def put_optional_binary_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -517,8 +520,6 @@ def put_optional_binary_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -560,6 +561,7 @@ def put_required_binary_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -570,8 +572,6 @@ def put_required_binary_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -614,6 +614,7 @@ def post_required_integer_parameter( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -624,8 +625,6 @@ def post_required_integer_parameter( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -670,6 +669,7 @@ def post_optional_integer_parameter( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -680,8 +680,6 @@ def post_optional_integer_parameter( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -725,6 +723,7 @@ def post_required_integer_property( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -735,8 +734,6 @@ def post_required_integer_property( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -782,6 +779,7 @@ def post_optional_integer_property( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -792,8 +790,6 @@ def post_optional_integer_property( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -832,6 +828,7 @@ def post_required_integer_header( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -842,8 +839,6 @@ def post_required_integer_header( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -881,6 +876,7 @@ def post_optional_integer_header( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -891,8 +887,6 @@ def post_optional_integer_header( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -935,6 +929,7 @@ def post_required_string_parameter( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -945,8 +940,6 @@ def post_required_string_parameter( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -991,6 +984,7 @@ def post_optional_string_parameter( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1001,8 +995,6 @@ def post_optional_string_parameter( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1046,6 +1038,7 @@ def post_required_string_property( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1056,8 +1049,6 @@ def post_required_string_property( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1103,6 +1094,7 @@ def post_optional_string_property( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1113,8 +1105,6 @@ def post_optional_string_property( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1153,6 +1143,7 @@ def post_required_string_header( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1163,8 +1154,6 @@ def post_required_string_header( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1202,6 +1191,7 @@ def post_optional_string_header( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1212,8 +1202,6 @@ def post_optional_string_header( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1297,6 +1285,7 @@ def post_required_class_parameter( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1307,8 +1296,6 @@ def post_required_class_parameter( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1392,6 +1379,7 @@ def post_optional_class_parameter( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1402,8 +1390,6 @@ def post_optional_class_parameter( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1447,6 +1433,7 @@ def post_required_class_property( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1457,8 +1444,6 @@ def post_required_class_property( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1504,6 +1489,7 @@ def post_optional_class_property( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1514,8 +1500,6 @@ def post_optional_class_property( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1599,6 +1583,7 @@ def post_required_array_parameter( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1609,8 +1594,6 @@ def post_required_array_parameter( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1694,6 +1677,7 @@ def post_optional_array_parameter( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1704,8 +1688,6 @@ def post_optional_array_parameter( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1749,6 +1731,7 @@ def post_required_array_property( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1759,8 +1742,6 @@ def post_required_array_property( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1806,6 +1787,7 @@ def post_optional_array_property( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1816,8 +1798,6 @@ def post_optional_array_property( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1856,6 +1836,7 @@ def post_required_array_header( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1866,8 +1847,6 @@ def post_required_array_header( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1905,6 +1884,7 @@ def post_optional_array_header( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1915,8 +1895,6 @@ def post_optional_array_header( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py index d0c97128911..8a1fc1311fa 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -231,6 +233,7 @@ def get_required_path( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,8 +244,6 @@ def get_required_path( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -280,6 +281,7 @@ def put_optional_query( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -290,8 +292,6 @@ def put_optional_query( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -329,6 +329,7 @@ def put_optional_header( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -339,8 +340,6 @@ def put_optional_header( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -385,6 +384,7 @@ def put_optional_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -395,8 +395,6 @@ def put_optional_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -438,6 +436,7 @@ def put_optional_binary_body( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -448,8 +447,6 @@ def put_optional_binary_body( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -483,6 +480,7 @@ def get_required_global_path(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -493,8 +491,6 @@ def get_required_global_path(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -528,6 +524,7 @@ def get_required_global_query(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -538,8 +535,6 @@ def get_required_global_query(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -573,6 +568,7 @@ def get_optional_global_query(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -583,8 +579,6 @@ def get_optional_global_query(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_vendor.py index d403fc63b46..3cde08fb119 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ReservedWordsClientConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class ReservedWordsClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/_vendor.py index 2d710d6e319..6546cfae4fe 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import ReservedWordsClientConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_import_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_import_operations_operations.py index b25abef8731..80f0522c1a7 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_import_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_import_operations_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._import_operations_operations import build_operation_one_request from .._vendor import ReservedWordsClientMixinABC @@ -81,6 +83,7 @@ async def operation_one(self, parameter1: str, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -91,8 +94,6 @@ async def operation_one(self, parameter1: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py index 717fdddcb48..21aa0b2793d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._reserved_words_client_operations import ( build_operation_with_content_param_request, build_operation_with_data_param_request, @@ -76,6 +78,7 @@ async def operation_with_content_param(self, content: IO[bytes], **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -86,8 +89,6 @@ async def operation_with_content_param(self, content: IO[bytes], **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -130,6 +131,7 @@ async def operation_with_json_param(self, json: Any, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -140,8 +142,6 @@ async def operation_with_json_param(self, json: Any, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -192,6 +192,7 @@ async def operation_with_data_param(self, data: str, world: str, **kwargs: Any) headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -202,8 +203,6 @@ async def operation_with_data_param(self, data: str, world: str, **kwargs: Any) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -252,6 +251,7 @@ async def operation_with_files_param(self, files: IO[bytes], file_name: str, **k headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,8 +262,6 @@ async def operation_with_files_param(self, files: IO[bytes], file_name: str, **k response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -313,6 +311,7 @@ async def operation_with_url( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -323,8 +322,6 @@ async def operation_with_url( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -364,6 +361,7 @@ async def reserved_enum(self, enum_parameter: Union[str, _models.MyEnum], **kwar headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -374,8 +372,6 @@ async def reserved_enum(self, enum_parameter: Union[str, _models.MyEnum], **kwar response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_import_operations_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_import_operations_operations.py index 30aa18e93a9..96cc06cee8f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_import_operations_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_import_operations_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import ReservedWordsClientMixinABC +from .._vendor import ReservedWordsClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -103,6 +104,7 @@ def operation_one(self, parameter1: str, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,8 +115,6 @@ def operation_one(self, parameter1: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_reserved_words_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_reserved_words_client_operations.py index 3edb11a518e..d552dca394f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_reserved_words_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/operations/_reserved_words_client_operations.py @@ -18,13 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer -from .._vendor import ReservedWordsClientMixinABC +from .._vendor import ReservedWordsClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -182,6 +183,7 @@ def operation_with_content_param(self, content: IO[bytes], **kwargs: Any) -> JSO headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -192,8 +194,6 @@ def operation_with_content_param(self, content: IO[bytes], **kwargs: Any) -> JSO response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -236,6 +236,7 @@ def operation_with_json_param(self, json: Any, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -246,8 +247,6 @@ def operation_with_json_param(self, json: Any, **kwargs: Any) -> JSON: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -298,6 +297,7 @@ def operation_with_data_param(self, data: str, world: str, **kwargs: Any) -> JSO headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -308,8 +308,6 @@ def operation_with_data_param(self, data: str, world: str, **kwargs: Any) -> JSO response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -358,6 +356,7 @@ def operation_with_files_param(self, files: IO[bytes], file_name: str, **kwargs: headers=_headers, params=_params, ) + _request = _convert_request(_request, _files) _request.url = self._client.format_url(_request.url) _stream = False @@ -368,8 +367,6 @@ def operation_with_files_param(self, files: IO[bytes], file_name: str, **kwargs: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -419,6 +416,7 @@ def operation_with_url( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -429,8 +427,6 @@ def operation_with_url( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -470,6 +466,7 @@ def reserved_enum(self, enum_parameter: Union[str, _models.MyEnum], **kwargs: An headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -480,8 +477,6 @@ def reserved_enum(self, enum_parameter: Union[str, _models.MyEnum], **kwargs: An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py index 307a2440f73..7fdee8b3dfe 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutorestSecurityAadMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py index 8e6e310bac2..8925dce2632 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py index 10cf8a5f34b..0304a1f2a03 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._autorest_security_aad_operations import build_head_request from .._vendor import AutorestSecurityAadMixinABC @@ -59,6 +61,7 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -69,8 +72,6 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py index 54b7e97bd34..24eddfea9e1 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/operations/_autorest_security_aad_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import AutorestSecurityAadMixinABC +from .._vendor import AutorestSecurityAadMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -69,6 +70,7 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -79,8 +81,6 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_vendor.py index bc2ebad1a2d..11635e217a0 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import SecurityAadSwaggerCredentialFlagConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class SecurityAadSwaggerCredentialFlagMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/_vendor.py index f93d4cba9e3..085e406b6f9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import SecurityAadSwaggerCredentialFlagConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py index d2edbb1411e..7c1dfe85f48 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._security_aad_swagger_credential_flag_operations import build_head_request from .._vendor import SecurityAadSwaggerCredentialFlagMixinABC @@ -61,6 +63,7 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -71,8 +74,6 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/_security_aad_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/_security_aad_swagger_credential_flag_operations.py index 54666a09a7d..eb3a227cf9f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/_security_aad_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/_security_aad_swagger_credential_flag_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import SecurityAadSwaggerCredentialFlagMixinABC +from .._vendor import SecurityAadSwaggerCredentialFlagMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -71,6 +72,7 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -81,8 +83,6 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py index 9fb96a324c5..c8a5025a2fb 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutorestSecurityKeyMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py index 7b331844629..b2d14534fb2 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py index 46ed9526712..578b86aa291 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._autorest_security_key_operations import build_head_request from .._vendor import AutorestSecurityKeyMixinABC @@ -59,6 +61,7 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -69,8 +72,6 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py index dc7f39fc366..3cd7e76329b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/operations/_autorest_security_key_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import AutorestSecurityKeyMixinABC +from .._vendor import AutorestSecurityKeyMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -69,6 +70,7 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -79,8 +81,6 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_vendor.py index 4a233605917..528e40858f1 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import SecurityKeySwaggerCredentialFlagConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from ._serialization import Deserializer, Serializer +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class SecurityKeySwaggerCredentialFlagMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/_vendor.py index c9bea806ed6..939606c8825 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import SecurityKeySwaggerCredentialFlagConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py index 9bcf8560fee..bd4b7ed8f32 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py @@ -18,9 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ..._vendor import _convert_request from ...operations._security_key_swagger_credential_flag_operations import build_head_request from .._vendor import SecurityKeySwaggerCredentialFlagMixinABC @@ -61,6 +63,7 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -71,8 +74,6 @@ async def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/_security_key_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/_security_key_swagger_credential_flag_operations.py index 4d90c61cf77..cacd3d7cc0d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/_security_key_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/_security_key_swagger_credential_flag_operations.py @@ -18,11 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import SecurityKeySwaggerCredentialFlagMixinABC +from .._vendor import SecurityKeySwaggerCredentialFlagMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -71,6 +72,7 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -81,8 +83,6 @@ def head(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py index c45256242fd..62a1cb5ee11 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._path_items_operations import ( build_get_all_with_values_request, build_get_global_and_local_query_null_request, @@ -106,6 +108,7 @@ async def get_all_with_values( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -116,8 +119,6 @@ async def get_all_with_values( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -175,6 +176,7 @@ async def get_global_query_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -185,8 +187,6 @@ async def get_global_query_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -244,6 +244,7 @@ async def get_global_and_local_query_null( # pylint: disable=inconsistent-retur headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -254,8 +255,6 @@ async def get_global_and_local_query_null( # pylint: disable=inconsistent-retur response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -312,6 +311,7 @@ async def get_local_path_item_query_null( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -322,8 +322,6 @@ async def get_local_path_item_query_null( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py index 8361adddc19..3aca9d7ca9c 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py @@ -19,10 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._paths_operations import ( build_array_csv_in_path_request, build_base64_url_request, @@ -107,6 +109,7 @@ async def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -117,8 +120,6 @@ async def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -153,6 +154,7 @@ async def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -163,8 +165,6 @@ async def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -199,6 +199,7 @@ async def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,8 +210,6 @@ async def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -247,6 +246,7 @@ async def get_int_negative_one_million( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -257,8 +257,6 @@ async def get_int_negative_one_million( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -293,6 +291,7 @@ async def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -303,8 +302,6 @@ async def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -339,6 +336,7 @@ async def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -349,8 +347,6 @@ async def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -385,6 +381,7 @@ async def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -395,8 +392,6 @@ async def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -431,6 +426,7 @@ async def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -441,8 +437,6 @@ async def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -477,6 +471,7 @@ async def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,8 +482,6 @@ async def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -523,6 +516,7 @@ async def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -533,8 +527,6 @@ async def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -569,6 +561,7 @@ async def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -579,8 +572,6 @@ async def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -615,6 +606,7 @@ async def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -625,8 +617,6 @@ async def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -663,6 +653,7 @@ async def string_url_non_encoded(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -673,8 +664,6 @@ async def string_url_non_encoded(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -709,6 +698,7 @@ async def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -719,8 +709,6 @@ async def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -758,6 +746,7 @@ async def string_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -768,8 +757,6 @@ async def string_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -808,6 +795,7 @@ async def enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -818,8 +806,6 @@ async def enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -858,6 +844,7 @@ async def enum_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -868,8 +855,6 @@ async def enum_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -907,6 +892,7 @@ async def byte_multi_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -917,8 +903,6 @@ async def byte_multi_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -953,6 +937,7 @@ async def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -963,8 +948,6 @@ async def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1002,6 +985,7 @@ async def byte_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1012,8 +996,6 @@ async def byte_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1048,6 +1030,7 @@ async def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1058,8 +1041,6 @@ async def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1098,6 +1079,7 @@ async def date_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1108,8 +1090,6 @@ async def date_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1144,6 +1124,7 @@ async def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1154,8 +1135,6 @@ async def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1193,6 +1172,7 @@ async def date_time_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1203,8 +1183,6 @@ async def date_time_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1242,6 +1220,7 @@ async def base64_url( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1252,8 +1231,6 @@ async def base64_url( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1293,6 +1270,7 @@ async def array_csv_in_path( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1303,8 +1281,6 @@ async def array_csv_in_path( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1342,6 +1318,7 @@ async def unix_time_url( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1352,8 +1329,6 @@ async def unix_time_url( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py index 70b26351c2e..f6b4e309981 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._queries_operations import ( build_array_string_csv_empty_request, build_array_string_csv_null_request, @@ -116,6 +118,7 @@ async def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -126,8 +129,6 @@ async def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -162,6 +163,7 @@ async def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -172,8 +174,6 @@ async def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -211,6 +211,7 @@ async def get_boolean_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,8 +222,6 @@ async def get_boolean_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -257,6 +256,7 @@ async def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -267,8 +267,6 @@ async def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -305,6 +303,7 @@ async def get_int_negative_one_million( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,8 +314,6 @@ async def get_int_negative_one_million( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -354,6 +351,7 @@ async def get_int_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -364,8 +362,6 @@ async def get_int_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -400,6 +396,7 @@ async def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -410,8 +407,6 @@ async def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -446,6 +441,7 @@ async def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disa headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -456,8 +452,6 @@ async def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disa response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -495,6 +489,7 @@ async def get_long_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -505,8 +500,6 @@ async def get_long_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -541,6 +534,7 @@ async def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -551,8 +545,6 @@ async def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -587,6 +579,7 @@ async def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -597,8 +590,6 @@ async def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -636,6 +627,7 @@ async def float_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -646,8 +638,6 @@ async def float_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -682,6 +672,7 @@ async def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -692,8 +683,6 @@ async def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -728,6 +717,7 @@ async def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -738,8 +728,6 @@ async def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -777,6 +765,7 @@ async def double_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -787,8 +776,6 @@ async def double_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -825,6 +812,7 @@ async def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=incons headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -835,8 +823,6 @@ async def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=incons response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -873,6 +859,7 @@ async def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -883,8 +870,6 @@ async def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -919,6 +904,7 @@ async def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -929,8 +915,6 @@ async def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -968,6 +952,7 @@ async def string_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -978,8 +963,6 @@ async def string_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1018,6 +1001,7 @@ async def enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1028,8 +1012,6 @@ async def enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1068,6 +1050,7 @@ async def enum_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1078,8 +1061,6 @@ async def enum_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1118,6 +1099,7 @@ async def byte_multi_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1128,8 +1110,6 @@ async def byte_multi_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1164,6 +1144,7 @@ async def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1174,8 +1155,6 @@ async def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1213,6 +1192,7 @@ async def byte_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1223,8 +1203,6 @@ async def byte_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1259,6 +1237,7 @@ async def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1269,8 +1248,6 @@ async def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1308,6 +1285,7 @@ async def date_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1318,8 +1296,6 @@ async def date_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1356,6 +1332,7 @@ async def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=incon headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1366,8 +1343,6 @@ async def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=incon response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1405,6 +1380,7 @@ async def date_time_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1415,8 +1391,6 @@ async def date_time_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1456,6 +1430,7 @@ async def array_string_csv_valid( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1466,8 +1441,6 @@ async def array_string_csv_valid( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1505,6 +1478,7 @@ async def array_string_csv_null( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1515,8 +1489,6 @@ async def array_string_csv_null( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1555,6 +1527,7 @@ async def array_string_csv_empty( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1565,8 +1538,6 @@ async def array_string_csv_empty( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1606,6 +1577,7 @@ async def array_string_no_collection_format_empty( # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1616,8 +1588,6 @@ async def array_string_no_collection_format_empty( # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1657,6 +1627,7 @@ async def array_string_ssv_valid( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1667,8 +1638,6 @@ async def array_string_ssv_valid( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1708,6 +1677,7 @@ async def array_string_tsv_valid( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1718,8 +1688,6 @@ async def array_string_tsv_valid( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1759,6 +1727,7 @@ async def array_string_pipes_valid( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1769,8 +1738,6 @@ async def array_string_pipes_valid( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py index 05b846b6487..2773bb8ec5b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py @@ -20,11 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -273,6 +275,7 @@ def get_all_with_values( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -283,8 +286,6 @@ def get_all_with_values( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -342,6 +343,7 @@ def get_global_query_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -352,8 +354,6 @@ def get_global_query_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -411,6 +411,7 @@ def get_global_and_local_query_null( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -421,8 +422,6 @@ def get_global_and_local_query_null( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -479,6 +478,7 @@ def get_local_path_item_query_null( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -489,8 +489,6 @@ def get_local_path_item_query_null( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py index d19d2392b76..035cc79e6b0 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -618,6 +620,7 @@ def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -628,8 +631,6 @@ def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -664,6 +665,7 @@ def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -674,8 +676,6 @@ def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -710,6 +710,7 @@ def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -720,8 +721,6 @@ def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -756,6 +755,7 @@ def get_int_negative_one_million(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -766,8 +766,6 @@ def get_int_negative_one_million(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -802,6 +800,7 @@ def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -812,8 +811,6 @@ def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -848,6 +845,7 @@ def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -858,8 +856,6 @@ def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -894,6 +890,7 @@ def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -904,8 +901,6 @@ def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -940,6 +935,7 @@ def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -950,8 +946,6 @@ def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -986,6 +980,7 @@ def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -996,8 +991,6 @@ def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1032,6 +1025,7 @@ def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1042,8 +1036,6 @@ def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1078,6 +1070,7 @@ def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1088,8 +1081,6 @@ def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1124,6 +1115,7 @@ def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1134,8 +1126,6 @@ def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1172,6 +1162,7 @@ def string_url_non_encoded(self, **kwargs: Any) -> None: # pylint: disable=inco headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1182,8 +1173,6 @@ def string_url_non_encoded(self, **kwargs: Any) -> None: # pylint: disable=inco response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1218,6 +1207,7 @@ def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1228,8 +1218,6 @@ def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1265,6 +1253,7 @@ def string_null(self, string_path: str, **kwargs: Any) -> None: # pylint: disab headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1275,8 +1264,6 @@ def string_null(self, string_path: str, **kwargs: Any) -> None: # pylint: disab response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1315,6 +1302,7 @@ def enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1325,8 +1313,6 @@ def enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1365,6 +1351,7 @@ def enum_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1375,8 +1362,6 @@ def enum_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1414,6 +1399,7 @@ def byte_multi_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1424,8 +1410,6 @@ def byte_multi_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1460,6 +1444,7 @@ def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1470,8 +1455,6 @@ def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1507,6 +1490,7 @@ def byte_null(self, byte_path: bytes, **kwargs: Any) -> None: # pylint: disable headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1517,8 +1501,6 @@ def byte_null(self, byte_path: bytes, **kwargs: Any) -> None: # pylint: disable response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1553,6 +1535,7 @@ def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1563,8 +1546,6 @@ def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1603,6 +1584,7 @@ def date_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1613,8 +1595,6 @@ def date_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1649,6 +1629,7 @@ def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1659,8 +1640,6 @@ def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1698,6 +1677,7 @@ def date_time_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1708,8 +1688,6 @@ def date_time_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [400]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1747,6 +1725,7 @@ def base64_url( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1757,8 +1736,6 @@ def base64_url( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1798,6 +1775,7 @@ def array_csv_in_path( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1808,8 +1786,6 @@ def array_csv_in_path( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1847,6 +1823,7 @@ def unix_time_url( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1857,8 +1834,6 @@ def unix_time_url( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py index 5b5518aa69f..fefbaf3b55e 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py @@ -21,11 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -760,6 +762,7 @@ def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inconsiste headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -770,8 +773,6 @@ def get_boolean_true(self, **kwargs: Any) -> None: # pylint: disable=inconsiste response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -806,6 +807,7 @@ def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -816,8 +818,6 @@ def get_boolean_false(self, **kwargs: Any) -> None: # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -855,6 +855,7 @@ def get_boolean_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -865,8 +866,6 @@ def get_boolean_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -901,6 +900,7 @@ def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=inconsi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -911,8 +911,6 @@ def get_int_one_million(self, **kwargs: Any) -> None: # pylint: disable=inconsi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -947,6 +945,7 @@ def get_int_negative_one_million(self, **kwargs: Any) -> None: # pylint: disabl headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -957,8 +956,6 @@ def get_int_negative_one_million(self, **kwargs: Any) -> None: # pylint: disabl response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -996,6 +993,7 @@ def get_int_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1006,8 +1004,6 @@ def get_int_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1042,6 +1038,7 @@ def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1052,8 +1049,6 @@ def get_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1088,6 +1083,7 @@ def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=in headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1098,8 +1094,6 @@ def get_negative_ten_billion(self, **kwargs: Any) -> None: # pylint: disable=in response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1137,6 +1131,7 @@ def get_long_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1147,8 +1142,6 @@ def get_long_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1183,6 +1176,7 @@ def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1193,8 +1187,6 @@ def float_scientific_positive(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1229,6 +1221,7 @@ def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1239,8 +1232,6 @@ def float_scientific_negative(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1278,6 +1269,7 @@ def float_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1288,8 +1280,6 @@ def float_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1324,6 +1314,7 @@ def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1334,8 +1325,6 @@ def double_decimal_positive(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1370,6 +1359,7 @@ def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disable=inc headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1380,8 +1370,6 @@ def double_decimal_negative(self, **kwargs: Any) -> None: # pylint: disable=inc response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1419,6 +1407,7 @@ def double_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1429,8 +1418,6 @@ def double_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1467,6 +1454,7 @@ def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=inconsistent headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1477,8 +1465,6 @@ def string_unicode(self, **kwargs: Any) -> None: # pylint: disable=inconsistent response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1515,6 +1501,7 @@ def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=inconsis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1525,8 +1512,6 @@ def string_url_encoded(self, **kwargs: Any) -> None: # pylint: disable=inconsis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1561,6 +1546,7 @@ def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1571,8 +1557,6 @@ def string_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1610,6 +1594,7 @@ def string_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1620,8 +1605,6 @@ def string_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1660,6 +1643,7 @@ def enum_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1670,8 +1654,6 @@ def enum_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1710,6 +1692,7 @@ def enum_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1720,8 +1703,6 @@ def enum_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1760,6 +1741,7 @@ def byte_multi_byte( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1770,8 +1752,6 @@ def byte_multi_byte( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1806,6 +1786,7 @@ def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1816,8 +1797,6 @@ def byte_empty(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1855,6 +1834,7 @@ def byte_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1865,8 +1845,6 @@ def byte_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1901,6 +1879,7 @@ def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1911,8 +1890,6 @@ def date_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1950,6 +1927,7 @@ def date_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1960,8 +1938,6 @@ def date_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1998,6 +1974,7 @@ def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsisten headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2008,8 +1985,6 @@ def date_time_valid(self, **kwargs: Any) -> None: # pylint: disable=inconsisten response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2047,6 +2022,7 @@ def date_time_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2057,8 +2033,6 @@ def date_time_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2098,6 +2072,7 @@ def array_string_csv_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2108,8 +2083,6 @@ def array_string_csv_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2147,6 +2120,7 @@ def array_string_csv_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2157,8 +2131,6 @@ def array_string_csv_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2197,6 +2169,7 @@ def array_string_csv_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2207,8 +2180,6 @@ def array_string_csv_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2248,6 +2219,7 @@ def array_string_no_collection_format_empty( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2258,8 +2230,6 @@ def array_string_no_collection_format_empty( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2299,6 +2269,7 @@ def array_string_ssv_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2309,8 +2280,6 @@ def array_string_ssv_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2350,6 +2319,7 @@ def array_string_tsv_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2360,8 +2330,6 @@ def array_string_tsv_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2401,6 +2369,7 @@ def array_string_pipes_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2411,8 +2380,6 @@ def array_string_pipes_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py index 2374956f354..3d5ae26e52f 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._queries_operations import ( build_array_string_multi_empty_request, build_array_string_multi_null_request, @@ -85,6 +87,7 @@ async def array_string_multi_null( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -95,8 +98,6 @@ async def array_string_multi_null( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -135,6 +136,7 @@ async def array_string_multi_empty( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,8 +147,6 @@ async def array_string_multi_empty( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -186,6 +186,7 @@ async def array_string_multi_valid( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,8 +197,6 @@ async def array_string_multi_valid( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py index 17badce0a55..586565c7247 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -148,6 +150,7 @@ def array_string_multi_null( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -158,8 +161,6 @@ def array_string_multi_null( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -198,6 +199,7 @@ def array_string_multi_empty( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -208,8 +210,6 @@ def array_string_multi_empty( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -249,6 +249,7 @@ def array_string_multi_valid( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,8 +260,6 @@ def array_string_multi_valid( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_vendor.py index 296ecb35e57..02205ff13b6 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestValidationTestConfiguration if TYPE_CHECKING: @@ -17,6 +19,14 @@ from azure.core import PipelineClient +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + class AutoRestValidationTestMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_vendor.py index 3d120f48d9e..985521f58ba 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_vendor.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_vendor.py @@ -8,6 +8,8 @@ from abc import ABC from typing import TYPE_CHECKING +from azure.core.pipeline.transport import HttpRequest + from ._configuration import AutoRestValidationTestConfiguration if TYPE_CHECKING: diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py index 801457e7285..1b62947d993 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py @@ -19,11 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._auto_rest_validation_test_operations import ( build_get_with_constant_in_path_request, build_post_with_constant_in_body_request, @@ -79,6 +81,7 @@ async def validation_of_method_parameters( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -89,8 +92,6 @@ async def validation_of_method_parameters( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -210,6 +211,7 @@ async def validation_of_body( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -220,8 +222,6 @@ async def validation_of_body( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -260,6 +260,7 @@ async def get_with_constant_in_path(self, **kwargs: Any) -> None: # pylint: dis headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -270,8 +271,6 @@ async def get_with_constant_in_path(self, **kwargs: Any) -> None: # pylint: dis response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -356,6 +355,7 @@ async def post_with_constant_in_body( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -366,8 +366,6 @@ async def post_with_constant_in_body( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py index 66acd37bd9a..75ca9b1158d 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py @@ -21,12 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models -from .._vendor import AutoRestValidationTestMixinABC +from .._vendor import AutoRestValidationTestMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -174,6 +175,7 @@ def validation_of_method_parameters(self, resource_group_name: str, id: int, **k headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -184,8 +186,6 @@ def validation_of_method_parameters(self, resource_group_name: str, id: int, **k response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -305,6 +305,7 @@ def validation_of_body( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,8 +316,6 @@ def validation_of_body( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -355,6 +354,7 @@ def get_with_constant_in_path(self, **kwargs: Any) -> None: # pylint: disable=i headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -365,8 +365,6 @@ def get_with_constant_in_path(self, **kwargs: Any) -> None: # pylint: disable=i response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -451,6 +449,7 @@ def post_with_constant_in_body( headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -461,8 +460,6 @@ def post_with_constant_in_body( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py index 7dccd1e7525..f689b8b480b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py @@ -18,11 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models +from ..._vendor import _convert_request from ...operations._xml_operations import ( build_get_acls_request, build_get_bytes_request, @@ -112,6 +114,7 @@ async def get_complex_type_ref_no_meta(self, **kwargs: Any) -> _models.RootWithR headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,8 +125,6 @@ async def get_complex_type_ref_no_meta(self, **kwargs: Any) -> _models.RootWithR response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -168,6 +169,7 @@ async def put_complex_type_ref_no_meta( # pylint: disable=inconsistent-return-s headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,8 +180,6 @@ async def put_complex_type_ref_no_meta( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -211,6 +211,7 @@ async def get_complex_type_ref_with_meta(self, **kwargs: Any) -> _models.RootWit headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,8 +222,6 @@ async def get_complex_type_ref_with_meta(self, **kwargs: Any) -> _models.RootWit response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -267,6 +266,7 @@ async def put_complex_type_ref_with_meta( # pylint: disable=inconsistent-return headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -277,8 +277,6 @@ async def put_complex_type_ref_with_meta( # pylint: disable=inconsistent-return response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -310,6 +308,7 @@ async def get_simple(self, **kwargs: Any) -> _models.Slideshow: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -320,8 +319,6 @@ async def get_simple(self, **kwargs: Any) -> _models.Slideshow: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -367,6 +364,7 @@ async def put_simple( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -377,8 +375,6 @@ async def put_simple( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -411,6 +407,7 @@ async def get_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -421,8 +418,6 @@ async def get_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -467,6 +462,7 @@ async def put_wrapped_lists( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -477,8 +473,6 @@ async def put_wrapped_lists( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -511,6 +505,7 @@ async def get_headers(self, **kwargs: Any) -> None: # pylint: disable=inconsist headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -521,8 +516,6 @@ async def get_headers(self, **kwargs: Any) -> None: # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -557,6 +550,7 @@ async def get_empty_list(self, **kwargs: Any) -> _models.Slideshow: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -567,8 +561,6 @@ async def get_empty_list(self, **kwargs: Any) -> _models.Slideshow: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -613,6 +605,7 @@ async def put_empty_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -623,8 +616,6 @@ async def put_empty_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -656,6 +647,7 @@ async def get_empty_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -666,8 +658,6 @@ async def get_empty_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -712,6 +702,7 @@ async def put_empty_wrapped_lists( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -722,8 +713,6 @@ async def put_empty_wrapped_lists( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -755,6 +744,7 @@ async def get_root_list(self, **kwargs: Any) -> List[_models.Banana]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -765,8 +755,6 @@ async def get_root_list(self, **kwargs: Any) -> List[_models.Banana]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -812,6 +800,7 @@ async def put_root_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -822,8 +811,6 @@ async def put_root_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -855,6 +842,7 @@ async def get_root_list_single_item(self, **kwargs: Any) -> List[_models.Banana] headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -865,8 +853,6 @@ async def get_root_list_single_item(self, **kwargs: Any) -> List[_models.Banana] response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -912,6 +898,7 @@ async def put_root_list_single_item( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -922,8 +909,6 @@ async def put_root_list_single_item( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -955,6 +940,7 @@ async def get_empty_root_list(self, **kwargs: Any) -> List[_models.Banana]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -965,8 +951,6 @@ async def get_empty_root_list(self, **kwargs: Any) -> List[_models.Banana]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1012,6 +996,7 @@ async def put_empty_root_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1022,8 +1007,6 @@ async def put_empty_root_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1055,6 +1038,7 @@ async def get_empty_child_element(self, **kwargs: Any) -> _models.Banana: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1065,8 +1049,6 @@ async def get_empty_child_element(self, **kwargs: Any) -> _models.Banana: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1111,6 +1093,7 @@ async def put_empty_child_element( # pylint: disable=inconsistent-return-statem headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1121,8 +1104,6 @@ async def put_empty_child_element( # pylint: disable=inconsistent-return-statem response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1156,6 +1137,7 @@ async def list_containers(self, **kwargs: Any) -> _models.ListContainersResponse headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1166,8 +1148,6 @@ async def list_containers(self, **kwargs: Any) -> _models.ListContainersResponse response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1207,6 +1187,7 @@ async def get_service_properties(self, **kwargs: Any) -> _models.StorageServiceP headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1217,8 +1198,6 @@ async def get_service_properties(self, **kwargs: Any) -> _models.StorageServiceP response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1267,6 +1246,7 @@ async def put_service_properties( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1277,8 +1257,6 @@ async def put_service_properties( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1314,6 +1292,7 @@ async def get_acls(self, **kwargs: Any) -> List[_models.SignedIdentifier]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1324,8 +1303,6 @@ async def get_acls(self, **kwargs: Any) -> List[_models.SignedIdentifier]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1377,6 +1354,7 @@ async def put_acls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1387,8 +1365,6 @@ async def put_acls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1424,6 +1400,7 @@ async def list_blobs(self, **kwargs: Any) -> _models.ListBlobsResponse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1434,8 +1411,6 @@ async def list_blobs(self, **kwargs: Any) -> _models.ListBlobsResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1482,6 +1457,7 @@ async def json_input( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1492,8 +1468,6 @@ async def json_input( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1525,6 +1499,7 @@ async def json_output(self, **kwargs: Any) -> _models.JSONOutput: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1535,8 +1510,6 @@ async def json_output(self, **kwargs: Any) -> _models.JSONOutput: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1573,6 +1546,7 @@ async def get_xms_text(self, **kwargs: Any) -> _models.ObjectWithXMsTextProperty headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1583,8 +1557,6 @@ async def get_xms_text(self, **kwargs: Any) -> _models.ObjectWithXMsTextProperty response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1620,6 +1592,7 @@ async def get_bytes(self, **kwargs: Any) -> _models.ModelWithByteProperty: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1630,8 +1603,6 @@ async def get_bytes(self, **kwargs: Any) -> _models.ModelWithByteProperty: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1678,6 +1649,7 @@ async def put_binary( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1688,8 +1660,6 @@ async def put_binary( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1722,6 +1692,7 @@ async def get_uri(self, **kwargs: Any) -> _models.ModelWithUrlProperty: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1732,8 +1703,6 @@ async def get_uri(self, **kwargs: Any) -> _models.ModelWithUrlProperty: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1780,6 +1749,7 @@ async def put_uri( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1790,8 +1760,6 @@ async def put_uri( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py index 9e11b0ad5c2..ef8109a990b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -605,6 +607,7 @@ def get_complex_type_ref_no_meta(self, **kwargs: Any) -> _models.RootWithRefAndN headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -615,8 +618,6 @@ def get_complex_type_ref_no_meta(self, **kwargs: Any) -> _models.RootWithRefAndN response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -661,6 +662,7 @@ def put_complex_type_ref_no_meta( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -671,8 +673,6 @@ def put_complex_type_ref_no_meta( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -704,6 +704,7 @@ def get_complex_type_ref_with_meta(self, **kwargs: Any) -> _models.RootWithRefAn headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -714,8 +715,6 @@ def get_complex_type_ref_with_meta(self, **kwargs: Any) -> _models.RootWithRefAn response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -760,6 +759,7 @@ def put_complex_type_ref_with_meta( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -770,8 +770,6 @@ def put_complex_type_ref_with_meta( # pylint: disable=inconsistent-return-state response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -803,6 +801,7 @@ def get_simple(self, **kwargs: Any) -> _models.Slideshow: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -813,8 +812,6 @@ def get_simple(self, **kwargs: Any) -> _models.Slideshow: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -860,6 +857,7 @@ def put_simple( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -870,8 +868,6 @@ def put_simple( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -904,6 +900,7 @@ def get_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -914,8 +911,6 @@ def get_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -960,6 +955,7 @@ def put_wrapped_lists( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -970,8 +966,6 @@ def put_wrapped_lists( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -1004,6 +998,7 @@ def get_headers(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1014,8 +1009,6 @@ def get_headers(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1050,6 +1043,7 @@ def get_empty_list(self, **kwargs: Any) -> _models.Slideshow: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1060,8 +1054,6 @@ def get_empty_list(self, **kwargs: Any) -> _models.Slideshow: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1106,6 +1098,7 @@ def put_empty_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1116,8 +1109,6 @@ def put_empty_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1149,6 +1140,7 @@ def get_empty_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1159,8 +1151,6 @@ def get_empty_wrapped_lists(self, **kwargs: Any) -> _models.AppleBarrel: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1205,6 +1195,7 @@ def put_empty_wrapped_lists( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1215,8 +1206,6 @@ def put_empty_wrapped_lists( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1248,6 +1237,7 @@ def get_root_list(self, **kwargs: Any) -> List[_models.Banana]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1258,8 +1248,6 @@ def get_root_list(self, **kwargs: Any) -> List[_models.Banana]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1305,6 +1293,7 @@ def put_root_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1315,8 +1304,6 @@ def put_root_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1348,6 +1335,7 @@ def get_root_list_single_item(self, **kwargs: Any) -> List[_models.Banana]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1358,8 +1346,6 @@ def get_root_list_single_item(self, **kwargs: Any) -> List[_models.Banana]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1405,6 +1391,7 @@ def put_root_list_single_item( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1415,8 +1402,6 @@ def put_root_list_single_item( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1448,6 +1433,7 @@ def get_empty_root_list(self, **kwargs: Any) -> List[_models.Banana]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1458,8 +1444,6 @@ def get_empty_root_list(self, **kwargs: Any) -> List[_models.Banana]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1505,6 +1489,7 @@ def put_empty_root_list( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1515,8 +1500,6 @@ def put_empty_root_list( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1548,6 +1531,7 @@ def get_empty_child_element(self, **kwargs: Any) -> _models.Banana: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1558,8 +1542,6 @@ def get_empty_child_element(self, **kwargs: Any) -> _models.Banana: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1604,6 +1586,7 @@ def put_empty_child_element( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1614,8 +1597,6 @@ def put_empty_child_element( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1649,6 +1630,7 @@ def list_containers(self, **kwargs: Any) -> _models.ListContainersResponse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1659,8 +1641,6 @@ def list_containers(self, **kwargs: Any) -> _models.ListContainersResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1700,6 +1680,7 @@ def get_service_properties(self, **kwargs: Any) -> _models.StorageServicePropert headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1710,8 +1691,6 @@ def get_service_properties(self, **kwargs: Any) -> _models.StorageServicePropert response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1760,6 +1739,7 @@ def put_service_properties( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1770,8 +1750,6 @@ def put_service_properties( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1807,6 +1785,7 @@ def get_acls(self, **kwargs: Any) -> List[_models.SignedIdentifier]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1817,8 +1796,6 @@ def get_acls(self, **kwargs: Any) -> List[_models.SignedIdentifier]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1870,6 +1847,7 @@ def put_acls( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1880,8 +1858,6 @@ def put_acls( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1917,6 +1893,7 @@ def list_blobs(self, **kwargs: Any) -> _models.ListBlobsResponse: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1927,8 +1904,6 @@ def list_blobs(self, **kwargs: Any) -> _models.ListBlobsResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1975,6 +1950,7 @@ def json_input( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1985,8 +1961,6 @@ def json_input( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2018,6 +1992,7 @@ def json_output(self, **kwargs: Any) -> _models.JSONOutput: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2028,8 +2003,6 @@ def json_output(self, **kwargs: Any) -> _models.JSONOutput: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2066,6 +2039,7 @@ def get_xms_text(self, **kwargs: Any) -> _models.ObjectWithXMsTextProperty: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2076,8 +2050,6 @@ def get_xms_text(self, **kwargs: Any) -> _models.ObjectWithXMsTextProperty: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2113,6 +2085,7 @@ def get_bytes(self, **kwargs: Any) -> _models.ModelWithByteProperty: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2123,8 +2096,6 @@ def get_bytes(self, **kwargs: Any) -> _models.ModelWithByteProperty: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2171,6 +2142,7 @@ def put_binary( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2181,8 +2153,6 @@ def put_binary( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2215,6 +2185,7 @@ def get_uri(self, **kwargs: Any) -> _models.ModelWithUrlProperty: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2225,8 +2196,6 @@ def get_uri(self, **kwargs: Any) -> _models.ModelWithUrlProperty: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -2273,6 +2242,7 @@ def put_uri( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2283,8 +2253,6 @@ def put_uri( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_vendor.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_vendor.py new file mode 100644 index 00000000000..0dafe0e287f --- /dev/null +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py index 1bcbfe01560..9e579d9a259 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py @@ -18,10 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._vendor import _convert_request from ...operations._pet_operations import ( build_do_something_request, build_get_pet_by_id_request, @@ -90,6 +92,7 @@ async def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pe headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -100,8 +103,6 @@ async def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pe response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) @@ -148,6 +149,7 @@ async def do_something(self, what_action: str, **kwargs: Any) -> _models.PetActi headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -158,8 +160,6 @@ async def do_something(self, what_action: str, **kwargs: Any) -> _models.PetActi response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -209,6 +209,7 @@ async def has_models_param( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,8 +220,6 @@ async def has_models_param( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) raise HttpResponseError(response=response, model=error) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py index d29920cfa70..7c1fdb8fa49 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py @@ -18,12 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .. import models as _models from .._serialization import Serializer +from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -147,6 +149,7 @@ def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pet]: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -157,8 +160,6 @@ def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pet]: response = pipeline_response.http_response if response.status_code not in [200, 202]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) @@ -205,6 +206,7 @@ def do_something(self, what_action: str, **kwargs: Any) -> _models.PetAction: headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -215,8 +217,6 @@ def do_something(self, what_action: str, **kwargs: Any) -> _models.PetAction: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) raise HttpResponseError(response=response, model=error) @@ -266,6 +266,7 @@ def has_models_param( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) + _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -276,8 +277,6 @@ def has_models_param( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) raise HttpResponseError(response=response, model=error)