From c732a7d74bfa9533a32135cc61bf42b90521230e Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:32:12 -0400 Subject: [PATCH] Revert "Revert "switch over completely to rest requests and responses (#2605)" (#2616)" (#2621) --- .../switch_to_rest-2024-4-30-12-59-16.md | 7 + .../autorest/codegen/models/client.py | 12 - .../autorest/codegen/models/code_model.py | 6 +- .../autorest/codegen/models/operation.py | 38 +--- .../codegen/serializers/builder_serializer.py | 18 +- .../codegen/serializers/general_serializer.py | 7 - .../codegen/templates/vendor.py.jinja2 | 8 - .../generated/azure/mgmt/sample/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../azure/multiapi/sample/v1/_vendor.py | 10 - .../azure/multiapi/sample/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../azure/multiapi/sample/v2/_vendor.py | 10 - .../azure/multiapi/sample/v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../azure/multiapi/sample/v3/_vendor.py | 10 - .../azure/multiapi/sample/v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../AzureBodyDuration/bodyduration/_vendor.py | 16 -- .../aio/operations/_duration_operations.py | 16 +- .../operations/_duration_operations.py | 16 +- .../azureparametergrouping/_vendor.py | 16 -- .../_parameter_grouping_operations.py | 22 +- .../_parameter_grouping_operations.py | 22 +- .../AzureReport/azurereport/_vendor.py | 10 - .../AzureReport/azurereport/aio/_vendor.py | 2 - ...est_report_service_for_azure_operations.py | 7 +- ...est_report_service_for_azure_operations.py | 8 +- .../azurespecialproperties/_vendor.py | 16 -- .../_api_version_default_operations.py | 16 +- .../_api_version_local_operations.py | 16 +- .../aio/operations/_header_operations.py | 13 +- .../aio/operations/_odata_operations.py | 7 +- .../_skip_url_encoding_operations.py | 25 ++- ..._subscription_in_credentials_operations.py | 19 +- .../_subscription_in_method_operations.py | 16 +- .../_xms_client_request_id_operations.py | 10 +- .../_api_version_default_operations.py | 16 +- .../_api_version_local_operations.py | 16 +- .../operations/_header_operations.py | 13 +- .../operations/_odata_operations.py | 7 +- .../_skip_url_encoding_operations.py | 25 ++- ..._subscription_in_credentials_operations.py | 19 +- .../_subscription_in_method_operations.py | 16 +- .../_xms_client_request_id_operations.py | 10 +- .../CustomBaseUri/custombaseurl/_vendor.py | 16 -- .../aio/operations/_paths_operations.py | 7 +- .../operations/_paths_operations.py | 7 +- .../custompollerpager/_vendor.py | 16 -- .../aio/operations/_paging_operations.py | 99 ++++---- .../operations/_paging_operations.py | 99 ++++---- .../custombaseurlpaging/_vendor.py | 16 -- .../aio/operations/_paging_operations.py | 12 +- .../operations/_paging_operations.py | 12 +- .../AcceptanceTests/Head/head/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../HeadExceptions/headexceptions/_vendor.py | 16 -- .../operations/_head_exception_operations.py | 13 +- .../operations/_head_exception_operations.py | 13 +- .../_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../AcceptanceTests/Lro/lro/_vendor.py | 16 -- .../_lr_os_custom_header_operations.py | 16 +- .../aio/operations/_lro_retrys_operations.py | 25 ++- .../lro/aio/operations/_lros_operations.py | 136 +++++++---- .../lro/aio/operations/_lrosads_operations.py | 82 ++++--- .../_lr_os_custom_header_operations.py | 16 +- .../lro/operations/_lro_retrys_operations.py | 25 ++- .../Lro/lro/operations/_lros_operations.py | 136 +++++++---- .../Lro/lro/operations/_lrosads_operations.py | 82 ++++--- .../lrowithparameterizedendpoints/_vendor.py | 10 - .../aio/_vendor.py | 2 - ...with_paramaterized_endpoints_operations.py | 10 +- ...with_paramaterized_endpoints_operations.py | 11 +- .../mixedapiversion/_vendor.py | 16 -- .../_api_version_default_operations.py | 16 +- .../_api_version_local_operations.py | 16 +- .../aio/operations/_header_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../aio/operations/_odata_operations.py | 7 +- .../_skip_url_encoding_operations.py | 25 ++- ..._subscription_in_credentials_operations.py | 19 +- .../_subscription_in_method_operations.py | 16 +- .../_xms_client_request_id_operations.py | 10 +- .../_api_version_default_operations.py | 16 +- .../_api_version_local_operations.py | 16 +- .../operations/_header_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../operations/_odata_operations.py | 7 +- .../_skip_url_encoding_operations.py | 25 ++- ..._subscription_in_credentials_operations.py | 19 +- .../_subscription_in_method_operations.py | 16 +- .../_xms_client_request_id_operations.py | 10 +- .../azure/packagemode/batch/head/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../azure/packagemode/batch/paging/_vendor.py | 16 -- .../aio/operations/_paging_operations.py | 99 ++++---- .../paging/operations/_paging_operations.py | 99 ++++---- .../azure/packagemode/customize/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../azure/packagemode/dataplane/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../azure/package/mode/_vendor.py | 16 -- .../operations/_http_success_operations.py | 13 +- .../operations/_http_success_operations.py | 13 +- .../AcceptanceTests/Paging/paging/_vendor.py | 16 -- .../aio/operations/_paging_operations.py | 99 ++++---- .../paging/operations/_paging_operations.py | 99 ++++---- .../securityaadswagger/_vendor.py | 10 - .../securityaadswagger/aio/_vendor.py | 2 - .../_autorest_security_aad_operations.py | 7 +- .../_autorest_security_aad_operations.py | 8 +- .../securitykeyswagger/_vendor.py | 10 - .../securitykeyswagger/aio/_vendor.py | 2 - .../_autorest_security_key_operations.py | 7 +- .../_autorest_security_key_operations.py | 8 +- .../storage/_vendor.py | 16 -- .../_storage_accounts_operations.py | 33 +-- .../aio/operations/_usage_operations.py | 7 +- .../_storage_accounts_operations.py | 33 +-- .../storage/operations/_usage_operations.py | 7 +- .../subscriptionidapiversion/_vendor.py | 16 -- .../aio/operations/_group_operations.py | 7 +- .../operations/_group_operations.py | 7 +- .../Multiapi/multiapi/v0/_vendor.py | 16 -- .../_operation_group_one_operations.py | 7 +- .../_operation_group_one_operations.py | 7 +- .../Multiapi/multiapi/v1/_vendor.py | 10 - .../Multiapi/multiapi/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../Multiapi/multiapi/v2/_vendor.py | 10 - .../Multiapi/multiapi/v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../Multiapi/multiapi/v3/_vendor.py | 10 - .../Multiapi/multiapi/v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../v1/_vendor.py | 10 - .../v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../v2/_vendor.py | 10 - .../v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../v3/_vendor.py | 10 - .../v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../multiapicustombaseurl/v1/_vendor.py | 10 - .../multiapicustombaseurl/v1/aio/_vendor.py | 2 - ...stom_base_url_service_client_operations.py | 7 +- ...stom_base_url_service_client_operations.py | 8 +- .../multiapicustombaseurl/v2/_vendor.py | 10 - .../multiapicustombaseurl/v2/aio/_vendor.py | 2 - ...stom_base_url_service_client_operations.py | 7 +- ...stom_base_url_service_client_operations.py | 8 +- .../multiapidataplane/v1/_vendor.py | 10 - .../multiapidataplane/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../multiapidataplane/v2/_vendor.py | 10 - .../multiapidataplane/v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../multiapidataplane/v3/_vendor.py | 10 - .../multiapidataplane/v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../multiapikeywordonly/v1/_vendor.py | 10 - .../multiapikeywordonly/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../multiapikeywordonly/v2/_vendor.py | 10 - .../multiapikeywordonly/v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../multiapikeywordonly/v3/_vendor.py | 10 - .../multiapikeywordonly/v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../multiapinoasync/v1/_vendor.py | 10 - .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../multiapinoasync/v2/_vendor.py | 10 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../multiapinoasync/v3/_vendor.py | 10 - .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../multiapisecurity/v0/_vendor.py | 16 -- .../_operation_group_one_operations.py | 7 +- .../_operation_group_one_operations.py | 7 +- .../multiapisecurity/v1/_vendor.py | 10 - .../multiapisecurity/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../submodule/v1/_vendor.py | 10 - .../submodule/v1/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 20 +- .../_operation_group_one_operations.py | 7 +- .../_multiapi_service_client_operations.py | 21 +- .../_operation_group_one_operations.py | 8 +- .../submodule/v2/_vendor.py | 10 - .../submodule/v2/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 10 +- .../_operation_group_one_operations.py | 10 +- .../_operation_group_two_operations.py | 7 +- .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 8 +- .../submodule/v3/_vendor.py | 10 - .../submodule/v3/aio/_vendor.py | 2 - .../_multiapi_service_client_operations.py | 11 +- .../_operation_group_one_operations.py | 11 +- .../_operation_group_two_operations.py | 10 +- .../_multiapi_service_client_operations.py | 12 +- .../_operation_group_one_operations.py | 12 +- .../_operation_group_two_operations.py | 11 +- .../multiapicombiner/_vendor.py | 10 - .../multiapicombiner/aio/_vendor.py | 2 - .../aio/operations/_operations.py | 40 ++-- .../operations/_operations.py | 41 ++-- .../multiapicombiner/v1/_vendor.py | 10 - .../multiapicombiner/v1/aio/_vendor.py | 2 - .../v1/aio/operations/_operations.py | 23 +- .../v1/operations/_operations.py | 24 +- .../multiapicombiner/v2/_vendor.py | 10 - .../multiapicombiner/v2/aio/_vendor.py | 2 - .../v2/aio/operations/_operations.py | 19 +- .../v2/operations/_operations.py | 20 +- .../multiapicombiner/v3/_vendor.py | 10 - .../multiapicombiner/v3/aio/_vendor.py | 2 - .../v3/aio/operations/_operations.py | 24 +- .../v3/operations/_operations.py | 25 ++- .../AcceptanceTests/asynctests/test_header.py | 4 +- .../AcceptanceTests/asynctests/test_hooks.py | 4 +- .../asynctests/test_send_request.py | 2 +- .../legacy/AcceptanceTests/test_hooks.py | 4 +- .../AcceptanceTests/test_send_request.py | 2 +- .../additionalproperties/_vendor.py | 16 -- .../aio/operations/_pets_operations.py | 22 +- .../operations/_pets_operations.py | 22 +- .../Anything/anything/_vendor.py | 10 - .../Anything/anything/aio/_vendor.py | 2 - .../operations/_anything_client_operations.py | 22 +- .../operations/_anything_client_operations.py | 23 +- .../BodyArray/bodyarray/_vendor.py | 16 -- .../aio/operations/_array_operations.py | 211 ++++++++++++------ .../bodyarray/operations/_array_operations.py | 211 ++++++++++++------ .../vanilla/body/array/_vendor.py | 16 -- .../array/aio/operations/_array_operations.py | 211 ++++++++++++------ .../array/operations/_array_operations.py | 211 ++++++++++++------ .../BodyBinary/bodybinary/_vendor.py | 16 -- .../aio/operations/_download_operations.py | 7 +- .../aio/operations/_upload_operations.py | 10 +- .../operations/_download_operations.py | 7 +- .../operations/_upload_operations.py | 10 +- .../BodyBoolean/bodyboolean/_vendor.py | 16 -- .../aio/operations/_bool_operations.py | 22 +- .../operations/_bool_operations.py | 22 +- .../BodyByte/bodybyte/_vendor.py | 16 -- .../aio/operations/_byte_operations.py | 19 +- .../bodybyte/operations/_byte_operations.py | 19 +- .../bodybytewithpackagename/_vendor.py | 16 -- .../aio/operations/_byte_operations.py | 19 +- .../operations/_byte_operations.py | 19 +- .../BodyComplex/bodycomplex/_vendor.py | 16 -- .../aio/operations/_array_operations.py | 19 +- .../aio/operations/_basic_operations.py | 22 +- .../aio/operations/_dictionary_operations.py | 22 +- .../operations/_flattencomplex_operations.py | 7 +- .../aio/operations/_inheritance_operations.py | 10 +- .../_polymorphicrecursive_operations.py | 10 +- .../operations/_polymorphism_operations.py | 31 ++- .../aio/operations/_primitive_operations.py | 70 +++--- .../_readonlyproperty_operations.py | 10 +- .../operations/_array_operations.py | 19 +- .../operations/_basic_operations.py | 22 +- .../operations/_dictionary_operations.py | 22 +- .../operations/_flattencomplex_operations.py | 7 +- .../operations/_inheritance_operations.py | 10 +- .../_polymorphicrecursive_operations.py | 10 +- .../operations/_polymorphism_operations.py | 31 ++- .../operations/_primitive_operations.py | 70 +++--- .../_readonlyproperty_operations.py | 10 +- .../BodyDate/bodydate/_vendor.py | 16 -- .../aio/operations/_date_operations.py | 28 ++- .../bodydate/operations/_date_operations.py | 28 ++- .../BodyDateTime/bodydatetime/_vendor.py | 16 -- .../aio/operations/_datetime_operations.py | 70 +++--- .../operations/_datetime_operations.py | 70 +++--- .../bodydatetimerfc1123/_vendor.py | 16 -- .../operations/_datetimerfc1123_operations.py | 31 ++- .../operations/_datetimerfc1123_operations.py | 31 ++- .../BodyDictionary/bodydictionary/_vendor.py | 16 -- .../aio/operations/_dictionary_operations.py | 199 +++++++++++------ .../operations/_dictionary_operations.py | 199 +++++++++++------ .../BodyDuration/bodyduration/_vendor.py | 16 -- .../aio/operations/_duration_operations.py | 16 +- .../operations/_duration_operations.py | 16 +- .../BodyFile/bodyfile/_vendor.py | 16 -- .../aio/operations/_files_operations.py | 13 +- .../bodyfile/operations/_files_operations.py | 13 +- .../BodyFormData/bodyformdata/_vendor.py | 10 - .../aio/operations/_formdata_operations.py | 13 +- .../operations/_formdata_operations.py | 13 +- .../bodyformurlencodeddata/_vendor.py | 10 - .../_formdataurlencoded_operations.py | 10 +- .../_formdataurlencoded_operations.py | 10 +- .../BodyInteger/bodyinteger/_vendor.py | 16 -- .../operations/_int_operations_operations.py | 46 ++-- .../operations/_int_operations_operations.py | 46 ++-- .../BodyNumber/bodynumber/_vendor.py | 16 -- .../aio/operations/_number_operations.py | 76 ++++--- .../operations/_number_operations.py | 76 ++++--- .../BodyString/bodystring/_vendor.py | 16 -- .../aio/operations/_enum_operations.py | 22 +- .../aio/operations/_string_operations.py | 43 ++-- .../bodystring/operations/_enum_operations.py | 22 +- .../operations/_string_operations.py | 43 ++-- .../BodyTime/bodytime/_vendor.py | 16 -- .../aio/operations/_time_operations.py | 10 +- .../bodytime/operations/_time_operations.py | 10 +- .../ClientEnum/clientenum/_vendor.py | 10 - .../ClientEnum/clientenum/aio/_vendor.py | 2 - .../_client_with_enum_operations.py | 7 +- .../_client_with_enum_operations.py | 8 +- .../Constants/constants/_vendor.py | 16 -- .../aio/operations/_contants_operations.py | 55 +++-- .../operations/_contants_operations.py | 55 +++-- .../CustomBaseUri/custombaseurl/_vendor.py | 16 -- .../aio/operations/_paths_operations.py | 7 +- .../operations/_paths_operations.py | 7 +- .../custombaseurlmoreoptions/_vendor.py | 16 -- .../aio/operations/_paths_operations.py | 7 +- .../operations/_paths_operations.py | 7 +- .../errorwithsecrets/_vendor.py | 10 - .../errorwithsecrets/aio/_vendor.py | 2 - .../_error_with_secrets_operations.py | 10 +- .../_error_with_secrets_operations.py | 11 +- .../extensibleenumsswagger/_vendor.py | 16 -- .../aio/operations/_pet_operations.py | 10 +- .../operations/_pet_operations.py | 10 +- .../AcceptanceTests/Header/header/_vendor.py | 16 -- .../aio/operations/_header_operations.py | 91 +++++--- .../header/operations/_header_operations.py | 91 +++++--- .../Http/httpinfrastructure/_vendor.py | 16 -- .../_http_client_failure_operations.py | 82 ++++--- .../operations/_http_failure_operations.py | 13 +- .../operations/_http_redirects_operations.py | 52 +++-- .../aio/operations/_http_retry_operations.py | 31 ++- .../_http_server_failure_operations.py | 16 +- .../operations/_http_success_operations.py | 61 +++-- .../_multiple_responses_operations.py | 106 ++++++--- .../_http_client_failure_operations.py | 82 ++++--- .../operations/_http_failure_operations.py | 13 +- .../operations/_http_redirects_operations.py | 52 +++-- .../operations/_http_retry_operations.py | 31 ++- .../_http_server_failure_operations.py | 16 +- .../operations/_http_success_operations.py | 61 +++-- .../_multiple_responses_operations.py | 106 ++++++--- .../incorrecterrorresponse/_vendor.py | 10 - .../incorrecterrorresponse/aio/_vendor.py | 2 - ...correct_returned_error_model_operations.py | 7 +- ...correct_returned_error_model_operations.py | 8 +- .../internaloperation/_vendor.py | 10 - .../internaloperation/aio/_vendor.py | 2 - .../_media_types_client_operations.py | 25 ++- .../_media_types_client_operations.py | 26 ++- .../MediaTypes/mediatypes/_vendor.py | 10 - .../MediaTypes/mediatypes/aio/_vendor.py | 2 - .../_media_types_client_operations.py | 25 ++- .../_media_types_client_operations.py | 26 ++- .../MergePatchJson/mergepatchjson/_vendor.py | 10 - .../mergepatchjson/aio/_vendor.py | 2 - .../_merge_patch_json_client_operations.py | 7 +- .../_merge_patch_json_client_operations.py | 8 +- .../modelflattening/_vendor.py | 10 - .../modelflattening/aio/_vendor.py | 2 - ...urce_flattening_test_service_operations.py | 37 +-- ...urce_flattening_test_service_operations.py | 38 ++-- .../multipleinheritance/_vendor.py | 10 - .../multipleinheritance/aio/_vendor.py | 2 - ...e_inheritance_service_client_operations.py | 34 +-- ...e_inheritance_service_client_operations.py | 35 +-- .../NonStringEnums/nonstringenums/_vendor.py | 16 -- .../aio/operations/_float_operations.py | 10 +- .../operations/_int_operations_operations.py | 10 +- .../operations/_float_operations.py | 10 +- .../operations/_int_operations_operations.py | 10 +- .../ObjectType/objecttype/_vendor.py | 10 - .../ObjectType/objecttype/aio/_vendor.py | 2 - .../_object_type_client_operations.py | 10 +- .../_object_type_client_operations.py | 11 +- .../packagemode/_vendor.py | 10 - .../packagemode/aio/_vendor.py | 2 - .../operations/_anything_client_operations.py | 22 +- .../operations/_anything_client_operations.py | 23 +- .../parameterflattening/_vendor.py | 16 -- .../_availability_sets_operations.py | 7 +- .../_availability_sets_operations.py | 7 +- .../parameterizedendpoint/_vendor.py | 10 - .../parameterizedendpoint/aio/_vendor.py | 2 - ...parmaterized_endpoint_client_operations.py | 7 +- ...parmaterized_endpoint_client_operations.py | 8 +- .../AcceptanceTests/Report/report/_vendor.py | 10 - .../Report/report/aio/_vendor.py | 2 - .../_auto_rest_report_service_operations.py | 10 +- .../_auto_rest_report_service_operations.py | 11 +- .../requiredoptional/_vendor.py | 16 -- .../aio/operations/_explicit_operations.py | 76 ++++--- .../aio/operations/_implicit_operations.py | 28 ++- .../operations/_explicit_operations.py | 76 ++++--- .../operations/_implicit_operations.py | 28 ++- .../ReservedWords/reservedwords/_vendor.py | 10 - .../reservedwords/aio/_vendor.py | 2 - .../_import_operations_operations.py | 7 +- .../_reserved_words_client_operations.py | 22 +- .../_import_operations_operations.py | 8 +- .../_reserved_words_client_operations.py | 23 +- .../securityaadswagger/_vendor.py | 10 - .../securityaadswagger/aio/_vendor.py | 2 - .../_autorest_security_aad_operations.py | 7 +- .../_autorest_security_aad_operations.py | 8 +- .../_vendor.py | 10 - .../aio/_vendor.py | 2 - ..._aad_swagger_credential_flag_operations.py | 7 +- ..._aad_swagger_credential_flag_operations.py | 8 +- .../securitykeyswagger/_vendor.py | 10 - .../securitykeyswagger/aio/_vendor.py | 2 - .../_autorest_security_key_operations.py | 7 +- .../_autorest_security_key_operations.py | 8 +- .../_vendor.py | 10 - .../aio/_vendor.py | 2 - ..._key_swagger_credential_flag_operations.py | 7 +- ..._key_swagger_credential_flag_operations.py | 8 +- .../AcceptanceTests/Url/url/_vendor.py | 16 -- .../aio/operations/_path_items_operations.py | 16 +- .../url/aio/operations/_paths_operations.py | 85 ++++--- .../url/aio/operations/_queries_operations.py | 109 +++++---- .../url/operations/_path_items_operations.py | 16 +- .../Url/url/operations/_paths_operations.py | 85 ++++--- .../Url/url/operations/_queries_operations.py | 109 +++++---- .../urlmulticollectionformat/_vendor.py | 16 -- .../aio/operations/_queries_operations.py | 13 +- .../operations/_queries_operations.py | 13 +- .../Validation/validation/_vendor.py | 10 - .../Validation/validation/aio/_vendor.py | 2 - .../_auto_rest_validation_test_operations.py | 16 +- .../_auto_rest_validation_test_operations.py | 17 +- .../AcceptanceTests/Xml/xmlservice/_vendor.py | 16 -- .../aio/operations/_xml_operations.py | 106 ++++++--- .../xmlservice/operations/_xml_operations.py | 106 ++++++--- .../xmserrorresponse/_vendor.py | 16 -- .../aio/operations/_pet_operations.py | 13 +- .../operations/_pet_operations.py | 13 +- 522 files changed, 5223 insertions(+), 5193 deletions(-) create mode 100644 .chronus/changes/switch_to_rest-2024-4-30-12-59-16.md delete mode 100644 packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_vendor.py delete mode 100644 packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_vendor.py delete mode 100644 packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_vendor.py delete mode 100644 packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_vendor.py delete mode 100644 packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_vendor.py 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 new file mode 100644 index 00000000000..0368c675010 --- /dev/null +++ b/.chronus/changes/switch_to_rest-2024-4-30-12-59-16.md @@ -0,0 +1,7 @@ +--- +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 3d880e32852..953ad7d63d8 100644 --- a/packages/autorest.python/autorest/codegen/models/client.py +++ b/packages/autorest.python/autorest/codegen/models/client.py @@ -253,18 +253,6 @@ 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 ab3c41f4ac6..c94ec77c2b7 100644 --- a/packages/autorest.python/autorest/codegen/models/code_model.py +++ b/packages/autorest.python/autorest/codegen/models/code_model.py @@ -120,11 +120,7 @@ def need_vendored_code(self, async_mode: bool) -> bool: return True if async_mode: return self.need_mixin_abc - 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) + return self.need_mixin_abc or self.has_etag or self.has_form_data @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 09136058537..c121649ca88 100644 --- a/packages/autorest.python/autorest/codegen/models/operation.py +++ b/packages/autorest.python/autorest/codegen/models/operation.py @@ -366,8 +366,6 @@ 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", @@ -377,32 +375,18 @@ 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 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, - ) + if async_mode: + file_import.add_submodule_import( + "rest", + "AsyncHttpResponse", + ImportType.SDKCORE, + ) else: - if async_mode: - file_import.add_submodule_import( - "rest", - "AsyncHttpResponse", - ImportType.SDKCORE, - ) - else: - file_import.add_submodule_import( - "rest", - "HttpResponse", - ImportType.SDKCORE, - ) + 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 42df4ae0ff9..ea292d0aea2 100644 --- a/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py +++ b/packages/autorest.python/autorest/codegen/serializers/builder_serializer.py @@ -846,11 +846,6 @@ 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" @@ -969,13 +964,12 @@ 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)}:"] - 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", - ] - ) + 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 f70f00a38f0..b3b0877da3c 100644 --- a/packages/autorest.python/autorest/codegen/serializers/general_serializer.py +++ b/packages/autorest.python/autorest/codegen/serializers/general_serializer.py @@ -87,13 +87,6 @@ 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 5e790a5697a..bc15b14dd56 100644 --- a/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 +++ b/packages/autorest.python/autorest/codegen/templates/vendor.py.jinja2 @@ -3,14 +3,6 @@ {{ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 ee0912a5af5..1ee6aaec91d 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 8d073da10e7..2649d7f9ba4 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 4be9f4faa37..1a8e5f2ceae 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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,7 +144,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -156,6 +154,8 @@ 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,7 +291,6 @@ 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 @@ -302,6 +301,8 @@ 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) @@ -360,7 +361,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -376,7 +376,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -398,6 +397,8 @@ 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) @@ -476,7 +477,6 @@ 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,6 +487,8 @@ 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 690f2856ffb..18e160f50f7 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -84,7 +82,6 @@ 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 @@ -95,6 +92,8 @@ 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 f8c3e856901..cdaa5e61d23 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +222,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,6 +232,8 @@ 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) @@ -365,7 +366,6 @@ 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,6 +376,8 @@ 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) @@ -434,7 +436,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,7 +451,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,6 +472,8 @@ 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) @@ -550,7 +552,6 @@ 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,6 +562,8 @@ 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 9a1698f1e80..e27867bf6fd 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -105,7 +104,6 @@ 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 @@ -116,6 +114,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 5a0be7edf6a..b6b6ea30af5 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -138,7 +137,6 @@ 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 @@ -149,6 +147,8 @@ 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 60a12c78568..52ad664194c 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,6 +145,8 @@ 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) @@ -186,7 +185,6 @@ 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 @@ -197,6 +195,8 @@ 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 4319a9592b6..2dca79cc775 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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 c5eb192672d..0ff32041779 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 966f69141c4..b7ab5ba85fe 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,6 +189,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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 b6b3ebd461a..62dcf13cde0 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ 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 @@ -120,6 +118,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 3607f228970..1864cba2ae2 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,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -78,7 +76,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -94,7 +91,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -116,6 +112,8 @@ 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) @@ -167,7 +165,6 @@ 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 @@ -178,6 +175,8 @@ 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 3c1c3e5b565..e65dc20427f 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -92,7 +90,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -108,7 +105,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -130,6 +126,8 @@ 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) @@ -220,7 +218,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,6 +228,8 @@ 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 ffaf7a29d00..c6a8b9c2a2c 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -138,7 +136,6 @@ 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 @@ -149,6 +146,8 @@ 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) @@ -183,7 +182,6 @@ 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 @@ -194,6 +192,8 @@ 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 573fcbb01a2..0e78b6b6062 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,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -136,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -158,6 +155,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 6be2c244390..e1449550c17 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,6 +161,8 @@ 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) @@ -254,7 +253,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,6 +263,8 @@ 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 dc2e7f1a577..4752c605c6b 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -181,7 +180,6 @@ 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 @@ -192,6 +190,8 @@ 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,7 +226,6 @@ 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 @@ -237,6 +236,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 5a6fdc953fd..62d89fee002 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -85,7 +83,6 @@ 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 @@ -96,6 +93,8 @@ 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) @@ -141,7 +140,6 @@ 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 @@ -152,6 +150,8 @@ 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,7 +184,6 @@ 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 @@ -195,6 +194,8 @@ 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) @@ -231,7 +232,6 @@ 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,6 +242,8 @@ 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 97fec1d0745..5888447d655 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +140,6 @@ 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 @@ -153,6 +150,8 @@ 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) @@ -198,7 +197,6 @@ 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 @@ -209,6 +207,8 @@ 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,7 +241,6 @@ 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 @@ -252,6 +251,8 @@ 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) @@ -288,7 +289,6 @@ 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,6 +299,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 db72dc2daf6..e450414482d 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -110,7 +108,6 @@ 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 @@ -121,6 +118,8 @@ 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) @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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) @@ -300,7 +301,6 @@ 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,6 +311,8 @@ 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) @@ -355,7 +357,6 @@ 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 @@ -366,6 +367,8 @@ 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) @@ -411,7 +414,6 @@ 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 @@ -422,6 +424,8 @@ 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 7fdc047cb9f..d1d5dd07afa 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -256,7 +254,6 @@ 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 @@ -267,6 +264,8 @@ 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) @@ -314,7 +313,6 @@ 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 @@ -325,6 +323,8 @@ 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,7 +375,6 @@ 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 @@ -386,6 +385,8 @@ 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) @@ -446,7 +447,6 @@ 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,6 +457,8 @@ 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) @@ -501,7 +503,6 @@ 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 @@ -512,6 +513,8 @@ 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) @@ -557,7 +560,6 @@ 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 @@ -568,6 +570,8 @@ 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 8a8317945dd..f2b160bbc2a 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutoRestReportServiceForAzureConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 53160cab8e8..cff94c45790 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,8 +8,6 @@ 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 328832f5291..d81c000f4db 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -69,7 +67,6 @@ 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 @@ -80,6 +77,8 @@ 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 e230c78f039..8b892cd76ce 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import AutoRestReportServiceForAzureMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -91,7 +90,6 @@ 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 @@ -102,6 +100,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 a0d06bbb4af..518a503d154 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -134,7 +133,6 @@ 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 @@ -145,6 +143,8 @@ 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,7 +179,6 @@ 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 @@ -190,6 +189,8 @@ 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) @@ -224,7 +225,6 @@ 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,6 +235,8 @@ 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 986313069c4..868d2bf5115 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -136,7 +135,6 @@ 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 @@ -147,6 +145,8 @@ 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,7 +181,6 @@ 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 @@ -192,6 +191,8 @@ 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) @@ -226,7 +227,6 @@ 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,6 +237,8 @@ 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 999f39840b4..90984ec1f6b 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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) @@ -147,7 +146,6 @@ 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 @@ -158,6 +156,8 @@ 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,7 +196,6 @@ 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 @@ -207,6 +206,8 @@ 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 1ba19532d36..711a6161e54 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -91,7 +89,6 @@ 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 @@ -102,6 +99,8 @@ 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 0e7e7aaa732..583b0c8509a 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -93,7 +91,6 @@ 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 @@ -104,6 +101,8 @@ 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) @@ -141,7 +140,6 @@ 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 @@ -152,6 +150,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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) @@ -234,7 +235,6 @@ 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,6 +245,8 @@ 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) @@ -282,7 +284,6 @@ 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,6 +294,8 @@ 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) @@ -330,7 +333,6 @@ 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 @@ -341,6 +343,8 @@ 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) @@ -375,7 +379,6 @@ 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 @@ -386,6 +389,8 @@ 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 218d4209d13..387548354b0 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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) @@ -133,7 +132,6 @@ 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 @@ -144,6 +142,8 @@ 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,7 +182,6 @@ 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 @@ -193,6 +192,8 @@ 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) @@ -227,7 +228,6 @@ 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,6 +238,8 @@ 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) @@ -272,7 +274,6 @@ 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,6 +284,8 @@ 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 362238e6721..f43a5388797 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -91,7 +89,6 @@ 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 @@ -102,6 +99,8 @@ 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) @@ -141,7 +140,6 @@ 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 @@ -152,6 +150,8 @@ 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,7 +191,6 @@ 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 @@ -202,6 +201,8 @@ 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) @@ -241,7 +242,6 @@ 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,6 +252,8 @@ 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 949fd5feee5..a1004ee5e0e 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -80,7 +78,6 @@ 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 @@ -91,6 +88,8 @@ 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) @@ -129,7 +128,6 @@ 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 @@ -140,6 +138,8 @@ 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 b4d6d1b7813..aa332059637 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -163,7 +161,6 @@ 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 @@ -174,6 +171,8 @@ 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) @@ -210,7 +209,6 @@ 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 @@ -221,6 +219,8 @@ 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,7 +255,6 @@ 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 @@ -266,6 +265,8 @@ 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) @@ -300,7 +301,6 @@ 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,6 +311,8 @@ 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 cac5ebb2995..7071d39b939 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +159,6 @@ 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 @@ -172,6 +169,8 @@ 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) @@ -210,7 +209,6 @@ 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 @@ -221,6 +219,8 @@ 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,7 +255,6 @@ 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 @@ -266,6 +265,8 @@ 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) @@ -300,7 +301,6 @@ 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,6 +311,8 @@ 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 3f4da7ff52a..dbf97c2a8cc 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -137,7 +135,6 @@ 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 @@ -148,6 +145,8 @@ 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) @@ -196,7 +195,6 @@ 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 @@ -207,6 +205,8 @@ 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,7 +245,6 @@ 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 @@ -256,6 +255,8 @@ 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 13a8ca41309..40b1f802528 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -120,7 +118,6 @@ 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 @@ -131,6 +128,8 @@ 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 85f1ca15ff0..6faf7a7a4eb 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -220,7 +218,6 @@ 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 @@ -231,6 +228,8 @@ 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) @@ -268,7 +267,6 @@ 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 @@ -279,6 +277,8 @@ 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,7 +313,6 @@ 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 @@ -324,6 +323,8 @@ 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) @@ -359,7 +360,6 @@ 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,6 +370,8 @@ 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) @@ -407,7 +409,6 @@ 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,6 +419,8 @@ 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) @@ -453,7 +456,6 @@ 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 @@ -464,6 +466,8 @@ 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) @@ -498,7 +502,6 @@ 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 @@ -509,6 +512,8 @@ 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 dd010c7a06a..33740ae67f3 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -201,7 +199,6 @@ 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 @@ -212,6 +209,8 @@ 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) @@ -246,7 +245,6 @@ 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 @@ -257,6 +255,8 @@ 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,7 +295,6 @@ 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 @@ -306,6 +305,8 @@ 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) @@ -340,7 +341,6 @@ 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,6 +351,8 @@ 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) @@ -385,7 +387,6 @@ 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,6 +397,8 @@ 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 9805b798275..1f10df01c54 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -176,7 +174,6 @@ 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 @@ -187,6 +184,8 @@ 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) @@ -226,7 +225,6 @@ 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 @@ -237,6 +235,8 @@ 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,7 +276,6 @@ 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 @@ -287,6 +286,8 @@ 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) @@ -326,7 +327,6 @@ 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,6 +337,8 @@ 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 21ffcb7dd60..4c16deef6c2 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -106,7 +104,6 @@ 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 @@ -117,6 +114,8 @@ 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) @@ -155,7 +154,6 @@ 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 @@ -166,6 +164,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 9bc8bf896e1..7fed59ce996 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -82,7 +80,6 @@ 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), @@ -97,6 +94,8 @@ 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 470325040a6..28f8d219ce4 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -98,7 +96,6 @@ 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), @@ -113,6 +110,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 0e84264ad4f..9caa65cd62a 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,9 +22,8 @@ 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 HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -32,7 +31,6 @@ 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, @@ -117,7 +115,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -133,7 +130,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -155,6 +151,8 @@ 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) @@ -190,7 +188,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -206,7 +203,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -228,6 +224,8 @@ 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) @@ -263,7 +261,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -279,7 +276,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -301,6 +297,8 @@ 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) @@ -336,7 +334,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -352,7 +349,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -374,6 +370,8 @@ 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) @@ -418,7 +416,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -434,7 +431,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -456,6 +452,8 @@ 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) @@ -492,7 +490,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -508,7 +505,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -530,6 +526,8 @@ 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) @@ -583,7 +581,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -599,7 +596,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -621,6 +617,8 @@ 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) @@ -663,7 +661,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -673,7 +670,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -695,6 +691,8 @@ 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) @@ -735,7 +733,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -751,7 +748,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -773,6 +769,8 @@ 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) @@ -814,7 +812,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -830,7 +827,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -852,6 +848,8 @@ 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) @@ -905,7 +903,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -921,7 +918,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -943,6 +939,8 @@ 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) @@ -999,7 +997,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1015,7 +1012,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1037,6 +1033,8 @@ 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) @@ -1073,7 +1071,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1089,7 +1086,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1111,6 +1107,8 @@ 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) @@ -1147,7 +1145,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1163,7 +1160,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1185,6 +1181,8 @@ 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) @@ -1220,7 +1218,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1236,7 +1233,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1258,6 +1254,8 @@ 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) @@ -1293,7 +1291,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1309,7 +1306,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1331,6 +1327,8 @@ 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) @@ -1366,7 +1364,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1382,7 +1379,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1404,6 +1400,8 @@ 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) @@ -1447,7 +1445,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1459,7 +1456,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1481,6 +1477,8 @@ 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) @@ -1527,7 +1525,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1544,7 +1541,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1566,6 +1562,8 @@ 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) @@ -1605,7 +1603,6 @@ 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 @@ -1616,6 +1613,8 @@ 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) @@ -1675,7 +1674,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1691,7 +1689,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1713,6 +1710,8 @@ 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) @@ -1788,7 +1787,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1804,7 +1802,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1826,6 +1823,8 @@ 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) @@ -1864,7 +1863,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1880,7 +1878,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1902,6 +1899,8 @@ 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) @@ -1940,7 +1939,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1956,7 +1954,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1978,6 +1975,8 @@ 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 8d7a3989cc1..d2a05b90726 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,9 +22,8 @@ ) 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 +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -32,7 +31,6 @@ 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 @@ -578,7 +576,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -594,7 +591,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -616,6 +612,8 @@ 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) @@ -651,7 +649,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -667,7 +664,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -689,6 +685,8 @@ 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) @@ -724,7 +722,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -740,7 +737,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -762,6 +758,8 @@ 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) @@ -797,7 +795,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -813,7 +810,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -835,6 +831,8 @@ 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) @@ -879,7 +877,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -895,7 +892,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -917,6 +913,8 @@ 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) @@ -953,7 +951,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -969,7 +966,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -991,6 +987,8 @@ 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) @@ -1044,7 +1042,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1060,7 +1057,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1082,6 +1078,8 @@ 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) @@ -1124,7 +1122,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1134,7 +1131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1156,6 +1152,8 @@ 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) @@ -1196,7 +1194,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1212,7 +1209,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1234,6 +1230,8 @@ 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) @@ -1273,7 +1271,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1289,7 +1286,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1311,6 +1307,8 @@ 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) @@ -1364,7 +1362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1380,7 +1377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1402,6 +1398,8 @@ 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) @@ -1458,7 +1456,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1474,7 +1471,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1496,6 +1492,8 @@ 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) @@ -1532,7 +1530,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1548,7 +1545,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1570,6 +1566,8 @@ 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) @@ -1606,7 +1604,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1622,7 +1619,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1644,6 +1640,8 @@ 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) @@ -1679,7 +1677,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1695,7 +1692,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1717,6 +1713,8 @@ 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) @@ -1752,7 +1750,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1768,7 +1765,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1790,6 +1786,8 @@ 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) @@ -1825,7 +1823,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1841,7 +1838,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1863,6 +1859,8 @@ 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) @@ -1906,7 +1904,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1918,7 +1915,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1940,6 +1936,8 @@ 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) @@ -1986,7 +1984,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2003,7 +2000,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -2025,6 +2021,8 @@ 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) @@ -2064,7 +2062,6 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2075,6 +2072,8 @@ 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) @@ -2134,7 +2133,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2150,7 +2148,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2172,6 +2169,8 @@ 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) @@ -2247,7 +2246,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2263,7 +2261,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2285,6 +2282,8 @@ 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) @@ -2323,7 +2322,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2339,7 +2337,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2361,6 +2358,8 @@ 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) @@ -2399,7 +2398,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2415,7 +2413,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2437,6 +2434,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 71dae3aa12e..78c396239bc 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,12 +19,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -89,7 +87,6 @@ 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), @@ -98,7 +95,6 @@ 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), @@ -124,6 +120,8 @@ 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) @@ -161,7 +159,6 @@ 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), @@ -175,7 +172,6 @@ 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), @@ -201,6 +197,8 @@ 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 bc025caaffa..89798aa5d59 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,14 +19,12 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -138,7 +136,6 @@ 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), @@ -147,7 +144,6 @@ 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), @@ -173,6 +169,8 @@ 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) @@ -210,7 +208,6 @@ 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), @@ -224,7 +221,6 @@ 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), @@ -250,6 +246,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 94925145ff3..cdc4be25b64 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 98be09f4ec4..7cb5cd048e4 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 46fbb451345..87892a4f668 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 7f00fc61a4f..16cd2e0d9f3 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 89fb466a342..e1a6a5014b7 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 62e1f00a3a3..512f3a613ed 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 04b650bb614..f8f583080f6 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,16 +19,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.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -98,7 +96,6 @@ 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 @@ -109,6 +106,8 @@ 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) @@ -268,7 +267,6 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,6 +277,8 @@ 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,7 +427,6 @@ 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 @@ -438,6 +437,8 @@ 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) @@ -572,7 +573,6 @@ 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,6 +583,8 @@ 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 c475f62b94e..fb0b5986cf2 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,16 +19,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.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -101,7 +99,6 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -112,6 +109,8 @@ 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) @@ -257,7 +256,6 @@ 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 @@ -268,6 +266,8 @@ 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,7 +409,6 @@ 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 @@ -420,6 +419,8 @@ 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) @@ -507,7 +508,6 @@ 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,6 +518,8 @@ 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) @@ -589,7 +591,6 @@ 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 @@ -600,6 +601,8 @@ 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) @@ -691,7 +694,6 @@ 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 @@ -702,6 +704,8 @@ 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) @@ -833,7 +837,6 @@ 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 @@ -844,6 +847,8 @@ 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 74fbde0894b..320a13257ea 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,16 +19,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.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -138,7 +136,6 @@ async def _put200_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -149,6 +146,8 @@ 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) @@ -289,7 +288,6 @@ 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 @@ -300,6 +298,8 @@ 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,7 +449,6 @@ 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 @@ -460,6 +459,8 @@ 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) @@ -607,7 +608,6 @@ 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,6 +618,8 @@ 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) @@ -766,7 +768,6 @@ async def _put201_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -777,6 +778,8 @@ 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) @@ -898,7 +901,6 @@ 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 @@ -909,6 +911,8 @@ 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) @@ -1009,7 +1013,6 @@ 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 @@ -1020,6 +1023,8 @@ 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) @@ -1158,7 +1163,6 @@ async def _put202_retry200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1169,6 +1173,8 @@ 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) @@ -1310,7 +1316,6 @@ async def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1321,6 +1326,8 @@ 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) @@ -1466,7 +1473,6 @@ async def _put200_updating_succeeded204_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1477,6 +1483,8 @@ 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) @@ -1618,7 +1626,6 @@ async def _put201_creating_failed200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1629,6 +1636,8 @@ 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) @@ -1774,7 +1783,6 @@ async def _put200_acceptedcanceled200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1785,6 +1793,8 @@ 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) @@ -1926,7 +1936,6 @@ 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 @@ -1937,6 +1946,8 @@ 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) @@ -2082,7 +2093,6 @@ 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 @@ -2093,6 +2103,8 @@ 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) @@ -2249,7 +2261,6 @@ 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 @@ -2260,6 +2271,8 @@ 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) @@ -2414,7 +2427,6 @@ 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 @@ -2425,6 +2437,8 @@ 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) @@ -2581,7 +2595,6 @@ 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 @@ -2592,6 +2605,8 @@ 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) @@ -2746,7 +2761,6 @@ 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 @@ -2757,6 +2771,8 @@ 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) @@ -2909,7 +2925,6 @@ async def _put_non_resource_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2920,6 +2935,8 @@ 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) @@ -3046,7 +3063,6 @@ 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 @@ -3057,6 +3073,8 @@ 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) @@ -3177,7 +3195,6 @@ async def _put_sub_resource_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3188,6 +3205,8 @@ 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) @@ -3282,7 +3301,6 @@ 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 @@ -3293,6 +3311,8 @@ 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) @@ -3378,7 +3398,6 @@ 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 @@ -3389,6 +3408,8 @@ 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) @@ -3476,7 +3497,6 @@ 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 @@ -3487,6 +3507,8 @@ 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) @@ -3574,7 +3596,6 @@ 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 @@ -3585,6 +3606,8 @@ 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) @@ -3672,7 +3695,6 @@ 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 @@ -3683,6 +3705,8 @@ 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) @@ -3747,7 +3771,6 @@ 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 @@ -3758,6 +3781,8 @@ 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) @@ -3839,7 +3864,6 @@ 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 @@ -3850,6 +3874,8 @@ 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) @@ -3933,7 +3959,6 @@ 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 @@ -3944,6 +3969,8 @@ 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) @@ -4015,7 +4042,6 @@ 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 @@ -4026,6 +4052,8 @@ 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) @@ -4097,7 +4125,6 @@ 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 @@ -4108,6 +4135,8 @@ 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) @@ -4182,7 +4211,6 @@ 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 @@ -4193,6 +4221,8 @@ 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) @@ -4267,7 +4297,6 @@ 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 @@ -4278,6 +4307,8 @@ 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) @@ -4352,7 +4383,6 @@ 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 @@ -4363,6 +4393,8 @@ 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) @@ -4435,7 +4467,6 @@ 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 @@ -4446,6 +4477,8 @@ 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) @@ -4540,7 +4573,6 @@ 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 @@ -4551,6 +4583,8 @@ 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) @@ -4682,7 +4716,6 @@ async def _post202_no_retry204_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -4693,6 +4726,8 @@ 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) @@ -4825,7 +4860,6 @@ 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 @@ -4836,6 +4870,8 @@ 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) @@ -4917,7 +4953,6 @@ 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 @@ -4928,6 +4963,8 @@ 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) @@ -5010,7 +5047,6 @@ 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 @@ -5021,6 +5057,8 @@ 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) @@ -5115,7 +5153,6 @@ 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 @@ -5126,6 +5163,8 @@ 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) @@ -5277,7 +5316,6 @@ 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 @@ -5288,6 +5326,8 @@ 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) @@ -5439,7 +5479,6 @@ 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 @@ -5450,6 +5489,8 @@ 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) @@ -5587,7 +5628,6 @@ 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 @@ -5598,6 +5638,8 @@ 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 775cd7fd02e..92e3f43293c 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,16 +19,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.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -120,7 +118,6 @@ async def _put_non_retry400_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,6 +128,8 @@ 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) @@ -270,7 +269,6 @@ 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 @@ -281,6 +279,8 @@ 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,7 +423,6 @@ 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 @@ -434,6 +433,8 @@ 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) @@ -576,7 +577,6 @@ 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,6 +587,8 @@ 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) @@ -725,7 +727,6 @@ 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 @@ -736,6 +737,8 @@ 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) @@ -806,7 +809,6 @@ 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 @@ -817,6 +819,8 @@ 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) @@ -887,7 +891,6 @@ 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 @@ -898,6 +901,8 @@ 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) @@ -987,7 +992,6 @@ 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 @@ -998,6 +1002,8 @@ 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) @@ -1126,7 +1132,6 @@ 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 @@ -1137,6 +1142,8 @@ 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) @@ -1265,7 +1272,6 @@ 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 @@ -1276,6 +1282,8 @@ 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) @@ -1410,7 +1418,6 @@ 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 @@ -1421,6 +1428,8 @@ 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) @@ -1560,7 +1569,6 @@ 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 @@ -1571,6 +1579,8 @@ 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) @@ -1727,7 +1737,6 @@ 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 @@ -1738,6 +1747,8 @@ 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) @@ -1879,7 +1890,6 @@ 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 @@ -1890,6 +1900,8 @@ 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) @@ -1956,7 +1968,6 @@ 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 @@ -1967,6 +1978,8 @@ 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) @@ -2058,7 +2071,6 @@ 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 @@ -2069,6 +2081,8 @@ 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) @@ -2200,7 +2214,6 @@ 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 @@ -2211,6 +2224,8 @@ 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) @@ -2348,7 +2363,6 @@ async def _put200_invalid_json_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2359,6 +2373,8 @@ 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) @@ -2499,7 +2515,6 @@ 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 @@ -2510,6 +2525,8 @@ 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) @@ -2666,7 +2683,6 @@ 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 @@ -2677,6 +2693,8 @@ 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) @@ -2818,7 +2836,6 @@ 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 @@ -2829,6 +2846,8 @@ 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) @@ -2900,7 +2919,6 @@ 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 @@ -2911,6 +2929,8 @@ 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) @@ -2987,7 +3007,6 @@ 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 @@ -2998,6 +3017,8 @@ 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) @@ -3089,7 +3110,6 @@ 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 @@ -3100,6 +3120,8 @@ 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) @@ -3231,7 +3253,6 @@ 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 @@ -3242,6 +3263,8 @@ 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) @@ -3379,7 +3402,6 @@ 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 @@ -3390,6 +3412,8 @@ 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 2dbe4d19c52..8add602861c 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,9 +19,8 @@ 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 +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,7 +28,6 @@ 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 @@ -164,7 +162,6 @@ def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -175,6 +172,8 @@ 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) @@ -331,7 +330,6 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -342,6 +340,8 @@ 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,7 +487,6 @@ 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 @@ -498,6 +497,8 @@ 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) @@ -632,7 +633,6 @@ 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,6 +643,8 @@ 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 b859de72de2..f21828b4c92 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,9 +19,8 @@ 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 +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,7 +28,6 @@ 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 @@ -208,7 +206,6 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,6 +216,8 @@ 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) @@ -361,7 +360,6 @@ 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 @@ -372,6 +370,8 @@ 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,7 +510,6 @@ 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 @@ -521,6 +520,8 @@ 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) @@ -605,7 +606,6 @@ 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,6 +616,8 @@ 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) @@ -687,7 +689,6 @@ 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 @@ -698,6 +699,8 @@ 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) @@ -789,7 +792,6 @@ 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 @@ -800,6 +802,8 @@ 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) @@ -931,7 +935,6 @@ 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 @@ -942,6 +945,8 @@ 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 7919b651f09..9c8af1a028b 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,9 +19,8 @@ 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 +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,7 +28,6 @@ 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 @@ -805,7 +803,6 @@ def _put200_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -816,6 +813,8 @@ 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) @@ -953,7 +952,6 @@ 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 @@ -964,6 +962,8 @@ 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,7 +1110,6 @@ 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 @@ -1121,6 +1120,8 @@ 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) @@ -1264,7 +1265,6 @@ 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,6 +1275,8 @@ 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) @@ -1420,7 +1422,6 @@ def _put201_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1431,6 +1432,8 @@ 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) @@ -1549,7 +1552,6 @@ 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 @@ -1560,6 +1562,8 @@ 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) @@ -1658,7 +1662,6 @@ def _put200_succeeded_no_state_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1669,6 +1672,8 @@ 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) @@ -1804,7 +1809,6 @@ def _put202_retry200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1815,6 +1819,8 @@ 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) @@ -1953,7 +1959,6 @@ def _put201_creating_succeeded200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1964,6 +1969,8 @@ 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) @@ -2106,7 +2113,6 @@ def _put200_updating_succeeded204_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2117,6 +2123,8 @@ 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) @@ -2255,7 +2263,6 @@ def _put201_creating_failed200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2266,6 +2273,8 @@ 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) @@ -2408,7 +2417,6 @@ def _put200_acceptedcanceled200_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2419,6 +2427,8 @@ 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) @@ -2557,7 +2567,6 @@ 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 @@ -2568,6 +2577,8 @@ 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) @@ -2710,7 +2721,6 @@ def _put_async_retry_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2721,6 +2731,8 @@ 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) @@ -2874,7 +2886,6 @@ 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 @@ -2885,6 +2896,8 @@ 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) @@ -3036,7 +3049,6 @@ def _put_async_retry_failed_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3047,6 +3059,8 @@ 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) @@ -3200,7 +3214,6 @@ def _put_async_no_retrycanceled_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3211,6 +3224,8 @@ 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) @@ -3362,7 +3377,6 @@ 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 @@ -3373,6 +3387,8 @@ 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) @@ -3522,7 +3538,6 @@ def _put_non_resource_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3533,6 +3548,8 @@ 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) @@ -3657,7 +3674,6 @@ def _put_async_non_resource_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3668,6 +3684,8 @@ 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) @@ -3784,7 +3802,6 @@ 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 @@ -3795,6 +3812,8 @@ 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) @@ -3888,7 +3907,6 @@ def _put_async_sub_resource_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -3899,6 +3917,8 @@ 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) @@ -3983,7 +4003,6 @@ 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 @@ -3994,6 +4013,8 @@ 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) @@ -4080,7 +4101,6 @@ 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 @@ -4091,6 +4111,8 @@ 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) @@ -4177,7 +4199,6 @@ 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 @@ -4188,6 +4209,8 @@ 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) @@ -4272,7 +4295,6 @@ 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 @@ -4283,6 +4305,8 @@ 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) @@ -4347,7 +4371,6 @@ 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 @@ -4358,6 +4381,8 @@ 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) @@ -4438,7 +4463,6 @@ 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 @@ -4449,6 +4473,8 @@ 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) @@ -4531,7 +4557,6 @@ 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 @@ -4542,6 +4567,8 @@ 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) @@ -4613,7 +4640,6 @@ 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 @@ -4624,6 +4650,8 @@ 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) @@ -4695,7 +4723,6 @@ 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 @@ -4706,6 +4733,8 @@ 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) @@ -4780,7 +4809,6 @@ 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 @@ -4791,6 +4819,8 @@ 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) @@ -4865,7 +4895,6 @@ 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 @@ -4876,6 +4905,8 @@ 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) @@ -4950,7 +4981,6 @@ 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 @@ -4961,6 +4991,8 @@ 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) @@ -5033,7 +5065,6 @@ 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 @@ -5044,6 +5075,8 @@ 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) @@ -5136,7 +5169,6 @@ 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 @@ -5147,6 +5179,8 @@ 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) @@ -5278,7 +5312,6 @@ def _post202_no_retry204_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5289,6 +5322,8 @@ 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) @@ -5418,7 +5453,6 @@ 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 @@ -5429,6 +5463,8 @@ 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) @@ -5509,7 +5545,6 @@ 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 @@ -5520,6 +5555,8 @@ 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) @@ -5600,7 +5637,6 @@ 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 @@ -5611,6 +5647,8 @@ 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) @@ -5704,7 +5742,6 @@ def _post_async_retry_succeeded_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -5715,6 +5752,8 @@ 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) @@ -5863,7 +5902,6 @@ 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 @@ -5874,6 +5912,8 @@ 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) @@ -6022,7 +6062,6 @@ 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 @@ -6033,6 +6072,8 @@ 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) @@ -6170,7 +6211,6 @@ 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 @@ -6181,6 +6221,8 @@ 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 b650cbd4233..bbf399e014f 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,9 +19,8 @@ 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 +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,7 +28,6 @@ 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 @@ -532,7 +530,6 @@ def _put_non_retry400_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -543,6 +540,8 @@ 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) @@ -679,7 +678,6 @@ def _put_non_retry201_creating400_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -690,6 +688,8 @@ 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,7 +829,6 @@ 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 @@ -840,6 +839,8 @@ 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) @@ -979,7 +980,6 @@ 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,6 +990,8 @@ 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) @@ -1123,7 +1125,6 @@ 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 @@ -1134,6 +1135,8 @@ 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) @@ -1202,7 +1205,6 @@ 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 @@ -1213,6 +1215,8 @@ 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) @@ -1283,7 +1287,6 @@ 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 @@ -1294,6 +1297,8 @@ 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) @@ -1383,7 +1388,6 @@ 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 @@ -1394,6 +1398,8 @@ 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) @@ -1522,7 +1528,6 @@ 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 @@ -1533,6 +1538,8 @@ 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) @@ -1661,7 +1668,6 @@ 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 @@ -1672,6 +1678,8 @@ 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) @@ -1806,7 +1814,6 @@ 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 @@ -1817,6 +1824,8 @@ 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) @@ -1953,7 +1962,6 @@ 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 @@ -1964,6 +1972,8 @@ 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) @@ -2117,7 +2127,6 @@ 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 @@ -2128,6 +2137,8 @@ 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) @@ -2264,7 +2275,6 @@ 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 @@ -2275,6 +2285,8 @@ 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) @@ -2341,7 +2353,6 @@ 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 @@ -2352,6 +2363,8 @@ 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) @@ -2443,7 +2456,6 @@ 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 @@ -2454,6 +2466,8 @@ 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) @@ -2585,7 +2599,6 @@ 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 @@ -2596,6 +2609,8 @@ 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) @@ -2733,7 +2748,6 @@ def _put200_invalid_json_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2744,6 +2758,8 @@ 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) @@ -2881,7 +2897,6 @@ 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 @@ -2892,6 +2907,8 @@ 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) @@ -3045,7 +3062,6 @@ 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 @@ -3056,6 +3072,8 @@ 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) @@ -3194,7 +3212,6 @@ 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 @@ -3205,6 +3222,8 @@ 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) @@ -3276,7 +3295,6 @@ 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 @@ -3287,6 +3305,8 @@ 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) @@ -3363,7 +3383,6 @@ 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 @@ -3374,6 +3393,8 @@ 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) @@ -3465,7 +3486,6 @@ 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 @@ -3476,6 +3496,8 @@ 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) @@ -3607,7 +3629,6 @@ 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 @@ -3618,6 +3639,8 @@ 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) @@ -3755,7 +3778,6 @@ 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 @@ -3766,6 +3788,8 @@ 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 defd0d956d7..d74e3c6d01d 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import LROWithParamaterizedEndpointsConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 e7b8b3d9112..6a04cfda87e 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,8 +8,6 @@ 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 a6772e65ebe..27635622655 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,14 +18,12 @@ 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 HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -64,7 +62,6 @@ 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), @@ -79,6 +76,8 @@ 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) @@ -175,7 +174,6 @@ 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), @@ -190,6 +188,8 @@ 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 ac8a0616a25..d25c8b999e3 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,16 +18,15 @@ 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 +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import LROWithParamaterizedEndpointsMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -100,7 +99,6 @@ 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), @@ -115,6 +113,8 @@ 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,7 +211,6 @@ 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), @@ -226,6 +225,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 3f9a9d2e839..650cb019dfe 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -133,7 +132,6 @@ 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 @@ -144,6 +142,8 @@ 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,7 +178,6 @@ 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,6 +188,8 @@ 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) @@ -223,7 +224,6 @@ 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,6 +234,8 @@ 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 2beb2f5ce0b..cfcd7858823 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -135,7 +134,6 @@ 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 @@ -146,6 +144,8 @@ 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,7 +180,6 @@ 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,6 +190,8 @@ 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) @@ -225,7 +226,6 @@ 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,6 +236,8 @@ 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 528f936a3ae..52f5b9ea966 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -146,7 +145,6 @@ 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 @@ -157,6 +155,8 @@ 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,7 +197,6 @@ 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 @@ -208,6 +207,8 @@ 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 2808803f711..b5724e8c210 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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) @@ -120,7 +119,6 @@ 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 @@ -131,6 +129,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 53c0cd26163..7ddda776302 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -90,7 +88,6 @@ 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 @@ -101,6 +98,8 @@ 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 4dcb37af03f..26e11483186 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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) @@ -140,7 +139,6 @@ 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 @@ -151,6 +149,8 @@ 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,7 +185,6 @@ 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,6 +195,8 @@ 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) @@ -233,7 +234,6 @@ 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,6 +244,8 @@ 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) @@ -281,7 +283,6 @@ 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 @@ -292,6 +293,8 @@ 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) @@ -329,7 +332,6 @@ 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 @@ -340,6 +342,8 @@ 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) @@ -374,7 +378,6 @@ 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 @@ -385,6 +388,8 @@ 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 9c10b057d99..dfdba2c35ba 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -132,7 +131,6 @@ 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 @@ -143,6 +141,8 @@ 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,7 +181,6 @@ 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,6 +191,8 @@ 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) @@ -226,7 +227,6 @@ 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,6 +237,8 @@ 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) @@ -271,7 +273,6 @@ 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 @@ -282,6 +283,8 @@ 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 7857393831f..6aab470b98b 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -90,7 +88,6 @@ 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 @@ -101,6 +98,8 @@ 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) @@ -140,7 +139,6 @@ 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 @@ -151,6 +149,8 @@ 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,7 +190,6 @@ 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,6 +200,8 @@ 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) @@ -240,7 +241,6 @@ 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,6 +251,8 @@ 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 81f18ab37d4..e7922dc9f88 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -128,7 +127,6 @@ 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 @@ -139,6 +137,8 @@ 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 1d077ad1916..3e331368aa8 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -162,7 +160,6 @@ 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 @@ -173,6 +170,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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,7 +254,6 @@ 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,6 +264,8 @@ 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) @@ -299,7 +300,6 @@ 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,6 +310,8 @@ 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 54a597fa090..17ef2ee09f9 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +158,6 @@ 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 @@ -171,6 +168,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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,7 +254,6 @@ 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,6 +264,8 @@ 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) @@ -299,7 +300,6 @@ 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,6 +310,8 @@ 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 2034a1fc6bb..c7b384341d5 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +134,6 @@ 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 @@ -147,6 +144,8 @@ 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) @@ -195,7 +194,6 @@ 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 @@ -206,6 +204,8 @@ 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,7 +246,6 @@ 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 @@ -257,6 +256,8 @@ 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 6070dfedbff..d287b448689 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -102,7 +100,6 @@ 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 @@ -113,6 +110,8 @@ 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) @@ -144,7 +143,6 @@ 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 @@ -155,6 +153,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 da80e8d4734..afba7548ed0 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -119,7 +117,6 @@ 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 @@ -130,6 +127,8 @@ 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 166265cf45e..388079ab7ab 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -219,7 +217,6 @@ 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 @@ -230,6 +227,8 @@ 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) @@ -267,7 +266,6 @@ 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 @@ -278,6 +276,8 @@ 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,7 +312,6 @@ 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,6 +322,8 @@ 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) @@ -358,7 +359,6 @@ 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,6 +369,8 @@ 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) @@ -406,7 +408,6 @@ 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 @@ -417,6 +418,8 @@ 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) @@ -452,7 +455,6 @@ 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 @@ -463,6 +465,8 @@ 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) @@ -497,7 +501,6 @@ 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 @@ -508,6 +511,8 @@ 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 41712bb5cb3..940ce5daf74 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -200,7 +198,6 @@ 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 @@ -211,6 +208,8 @@ 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) @@ -245,7 +244,6 @@ 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 @@ -256,6 +254,8 @@ 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,7 +294,6 @@ 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,6 +304,8 @@ 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) @@ -339,7 +340,6 @@ 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,6 +350,8 @@ 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) @@ -384,7 +386,6 @@ 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 @@ -395,6 +396,8 @@ 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 b22920040f2..225d4c4196d 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -175,7 +173,6 @@ 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 @@ -186,6 +183,8 @@ 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) @@ -225,7 +224,6 @@ 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 @@ -236,6 +234,8 @@ 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,7 +275,6 @@ 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,6 +285,8 @@ 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) @@ -325,7 +326,6 @@ 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,6 +336,8 @@ 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 5df3f7f5ef3..069f4f906e3 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -105,7 +103,6 @@ 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 @@ -116,6 +113,8 @@ 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) @@ -154,7 +153,6 @@ 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 @@ -165,6 +163,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 e03dacc816a..858feb968fc 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 9fbfa6fa61d..1efa73c0ab5 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 cd3af171811..180b982fed2 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,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +29,6 @@ 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,7 +113,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -131,7 +128,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -153,6 +149,8 @@ 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,7 +186,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -204,7 +201,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -226,6 +222,8 @@ 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,7 +259,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -277,7 +274,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -299,6 +295,8 @@ 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,7 +332,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -350,7 +347,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -372,6 +368,8 @@ 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,7 +414,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -432,7 +429,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -454,6 +450,8 @@ 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,7 +488,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -506,7 +503,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -528,6 +524,8 @@ 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,7 +579,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -597,7 +594,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -619,6 +615,8 @@ 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,7 +659,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -671,7 +668,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -693,6 +689,8 @@ 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,7 +731,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -749,7 +746,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -771,6 +767,8 @@ 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,7 +810,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -828,7 +825,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -850,6 +846,8 @@ 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,7 +901,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -919,7 +916,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -941,6 +937,8 @@ 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,7 +995,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1013,7 +1010,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1035,6 +1031,8 @@ 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,7 +1069,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1087,7 +1084,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1109,6 +1105,8 @@ 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,7 +1143,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1161,7 +1158,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1183,6 +1179,8 @@ 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,7 +1216,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1234,7 +1231,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1256,6 +1252,8 @@ 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,7 +1289,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1307,7 +1304,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1329,6 +1325,8 @@ 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,7 +1362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1380,7 +1377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1402,6 +1398,8 @@ 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,7 +1443,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1457,7 +1454,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1479,6 +1475,8 @@ 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,7 +1523,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1542,7 +1539,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1564,6 +1560,8 @@ 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,7 +1601,6 @@ 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 @@ -1614,6 +1611,8 @@ 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) @@ -1673,7 +1672,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1689,7 +1687,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1711,6 +1708,8 @@ 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) @@ -1786,7 +1785,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1802,7 +1800,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1824,6 +1821,8 @@ 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) @@ -1862,7 +1861,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1878,7 +1876,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1900,6 +1897,8 @@ 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) @@ -1938,7 +1937,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1954,7 +1952,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1976,6 +1973,8 @@ 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 35da9c7b5e8..2b2166d9307 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,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 +29,6 @@ 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,7 +574,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -592,7 +589,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -614,6 +610,8 @@ 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,7 +647,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -665,7 +662,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -687,6 +683,8 @@ 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,7 +720,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -738,7 +735,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -760,6 +756,8 @@ 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,7 +793,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -811,7 +808,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -833,6 +829,8 @@ 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,7 +875,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -893,7 +890,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -915,6 +911,8 @@ 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,7 +949,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -967,7 +964,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -989,6 +985,8 @@ 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,7 +1040,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1058,7 +1055,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1080,6 +1076,8 @@ 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,7 +1120,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1132,7 +1129,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1154,6 +1150,8 @@ 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,7 +1192,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1210,7 +1207,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1232,6 +1228,8 @@ 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,7 +1269,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1287,7 +1284,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1309,6 +1305,8 @@ 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,7 +1360,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1378,7 +1375,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1400,6 +1396,8 @@ 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,7 +1454,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1472,7 +1469,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1494,6 +1490,8 @@ 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,7 +1528,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1546,7 +1543,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1568,6 +1564,8 @@ 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,7 +1602,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1620,7 +1617,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1642,6 +1638,8 @@ 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,7 +1675,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1693,7 +1690,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1715,6 +1711,8 @@ 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,7 +1748,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1766,7 +1763,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1788,6 +1784,8 @@ 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,7 +1821,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1839,7 +1836,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1861,6 +1857,8 @@ 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,7 +1902,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1916,7 +1913,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -1938,6 +1934,8 @@ 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,7 +1982,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2001,7 +1998,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) return _request @@ -2023,6 +2019,8 @@ 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,7 +2060,6 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2073,6 +2070,8 @@ 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) @@ -2132,7 +2131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2148,7 +2146,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2170,6 +2167,8 @@ 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) @@ -2245,7 +2244,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2261,7 +2259,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2283,6 +2280,8 @@ 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) @@ -2321,7 +2320,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2337,7 +2335,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2359,6 +2356,8 @@ 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) @@ -2397,7 +2396,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2413,7 +2411,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2435,6 +2432,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 3a7ef30639c..e319d944cd6 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 0b647071971..8a83d55bb32 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 ea673e144aa..72528972de3 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 7b831170305..430bfc761dd 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 7345730f265..7d44cd4b3d7 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -76,7 +74,6 @@ 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 @@ -87,6 +84,8 @@ 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) @@ -119,7 +118,6 @@ 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 @@ -130,6 +128,8 @@ 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,7 +162,6 @@ 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 @@ -173,6 +172,8 @@ 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 4d659f5cbfc..ce58cbbcd02 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -100,7 +98,6 @@ def head200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,6 +108,8 @@ 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) @@ -143,7 +142,6 @@ def head204(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,6 +152,8 @@ 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,7 +186,6 @@ def head404(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -197,6 +196,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 e8585ae3b2e..b499a081164 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,16 +20,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 HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._vendor import _convert_request from ...operations._paging_operations import ( build_append_api_version_request, build_duplicate_params_request, @@ -114,7 +112,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -130,7 +127,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -152,6 +148,8 @@ 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) @@ -187,7 +185,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -203,7 +200,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -225,6 +221,8 @@ 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) @@ -260,7 +258,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -276,7 +273,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -298,6 +294,8 @@ 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) @@ -333,7 +331,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -349,7 +346,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -371,6 +367,8 @@ 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) @@ -415,7 +413,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -431,7 +428,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -453,6 +449,8 @@ 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) @@ -489,7 +487,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -505,7 +502,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -527,6 +523,8 @@ 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) @@ -579,7 +577,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -595,7 +592,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -617,6 +613,8 @@ 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) @@ -659,7 +657,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -669,7 +666,6 @@ 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,6 +687,8 @@ 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) @@ -731,7 +729,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -747,7 +744,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -769,6 +765,8 @@ 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) @@ -810,7 +808,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -826,7 +823,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -848,6 +844,8 @@ 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) @@ -901,7 +899,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -917,7 +914,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -939,6 +935,8 @@ 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) @@ -995,7 +993,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1011,7 +1008,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1033,6 +1029,8 @@ 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) @@ -1069,7 +1067,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1085,7 +1082,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1107,6 +1103,8 @@ 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) @@ -1143,7 +1141,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1159,7 +1156,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1181,6 +1177,8 @@ 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) @@ -1216,7 +1214,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1232,7 +1229,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1254,6 +1250,8 @@ 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) @@ -1289,7 +1287,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1305,7 +1302,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1327,6 +1323,8 @@ 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) @@ -1362,7 +1360,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1378,7 +1375,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1400,6 +1396,8 @@ 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) @@ -1443,7 +1441,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1455,7 +1452,6 @@ 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,6 +1473,8 @@ 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) @@ -1523,7 +1521,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1540,7 +1537,6 @@ 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,6 +1558,8 @@ 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) @@ -1601,7 +1599,6 @@ 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 @@ -1612,6 +1609,8 @@ 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) @@ -1670,7 +1669,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1686,7 +1684,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1708,6 +1705,8 @@ 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) @@ -1783,7 +1782,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1799,7 +1797,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1821,6 +1818,8 @@ 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) @@ -1859,7 +1858,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1875,7 +1873,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1897,6 +1894,8 @@ 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) @@ -1935,7 +1934,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1951,7 +1949,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1973,6 +1970,8 @@ 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 c8ff50015b0..021eae876d5 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,16 +20,14 @@ ) 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 +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -575,7 +573,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -591,7 +588,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -613,6 +609,8 @@ 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) @@ -648,7 +646,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -664,7 +661,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -686,6 +682,8 @@ 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) @@ -721,7 +719,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -737,7 +734,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -759,6 +755,8 @@ 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) @@ -794,7 +792,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -810,7 +807,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -832,6 +828,8 @@ 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) @@ -876,7 +874,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -892,7 +889,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -914,6 +910,8 @@ 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) @@ -950,7 +948,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -966,7 +963,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -988,6 +984,8 @@ 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) @@ -1040,7 +1038,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1056,7 +1053,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1078,6 +1074,8 @@ 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) @@ -1120,7 +1118,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1130,7 +1127,6 @@ 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,6 +1148,8 @@ 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) @@ -1192,7 +1190,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1208,7 +1205,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1230,6 +1226,8 @@ 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) @@ -1269,7 +1267,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1285,7 +1282,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1307,6 +1303,8 @@ 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) @@ -1360,7 +1358,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1376,7 +1373,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1398,6 +1394,8 @@ 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) @@ -1454,7 +1452,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1470,7 +1467,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1492,6 +1488,8 @@ 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) @@ -1528,7 +1526,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1544,7 +1541,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1566,6 +1562,8 @@ 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) @@ -1602,7 +1600,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1618,7 +1615,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1640,6 +1636,8 @@ 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) @@ -1675,7 +1673,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1691,7 +1688,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1713,6 +1709,8 @@ 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) @@ -1748,7 +1746,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1764,7 +1761,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1786,6 +1782,8 @@ 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) @@ -1821,7 +1819,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1837,7 +1834,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1859,6 +1855,8 @@ 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) @@ -1902,7 +1900,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1914,7 +1911,6 @@ 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,6 +1932,8 @@ 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) @@ -1982,7 +1980,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1999,7 +1996,6 @@ 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,6 +2017,8 @@ 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) @@ -2060,7 +2058,6 @@ def _get_multiple_pages_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2071,6 +2068,8 @@ 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) @@ -2128,7 +2127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2144,7 +2142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2166,6 +2163,8 @@ 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) @@ -2241,7 +2240,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2257,7 +2255,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2279,6 +2276,8 @@ 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) @@ -2317,7 +2316,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2333,7 +2331,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2355,6 +2352,8 @@ 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) @@ -2393,7 +2392,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2409,7 +2407,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2431,6 +2428,8 @@ 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 7fdee8b3dfe..307a2440f73 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 8925dce2632..8e6e310bac2 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,8 +8,6 @@ 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 0e761341e0e..16f438cd590 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -62,7 +60,6 @@ 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 @@ -73,6 +70,8 @@ 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 a8b67573972..00b66763231 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer -from .._vendor import AutorestSecurityAadMixinABC, _convert_request +from .._vendor import AutorestSecurityAadMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -71,7 +70,6 @@ def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -82,6 +80,8 @@ 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 c8a5025a2fb..9fb96a324c5 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 b2d14534fb2..7b331844629 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,8 +8,6 @@ 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 eae8aacf726..d8052e1d1d1 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -62,7 +60,6 @@ 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 @@ -73,6 +70,8 @@ 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 8d594b99314..e6b6851da3a 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .._serialization import Serializer -from .._vendor import AutorestSecurityKeyMixinABC, _convert_request +from .._vendor import AutorestSecurityKeyMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -71,7 +70,6 @@ def head(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -82,6 +80,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 4b3b57c7890..eb7e90020aa 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -158,7 +156,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -169,6 +166,8 @@ 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) @@ -220,7 +219,6 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,6 +229,8 @@ 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,7 +422,6 @@ 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 @@ -433,6 +432,8 @@ 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) @@ -480,7 +481,6 @@ async def get_properties( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,6 +491,8 @@ 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) @@ -638,7 +640,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -649,6 +650,8 @@ 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) @@ -694,7 +697,6 @@ 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 @@ -705,6 +707,8 @@ 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) @@ -747,7 +751,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -763,7 +766,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -785,6 +787,8 @@ 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) @@ -830,7 +834,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -846,7 +849,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -868,6 +870,8 @@ 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) @@ -926,7 +930,6 @@ async def regenerate_key( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -937,6 +940,8 @@ 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 986b796cd9e..cefe34447e3 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 466733ac72b..66bd28eb2ce 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,6 @@ 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 @@ -420,7 +418,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -431,6 +428,8 @@ 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) @@ -482,7 +481,6 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -493,6 +491,8 @@ 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,7 +684,6 @@ 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 @@ -695,6 +694,8 @@ 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) @@ -740,7 +741,6 @@ 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,6 +751,8 @@ 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) @@ -898,7 +900,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -909,6 +910,8 @@ 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) @@ -954,7 +957,6 @@ 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 @@ -965,6 +967,8 @@ 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) @@ -1007,7 +1011,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1023,7 +1026,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1045,6 +1047,8 @@ 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) @@ -1088,7 +1092,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1104,7 +1107,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1126,6 +1128,8 @@ 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) @@ -1184,7 +1188,6 @@ def regenerate_key( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1195,6 +1198,8 @@ 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 68e1a8cc7b7..49cfd3b47aa 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,15 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -110,7 +108,6 @@ 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 @@ -121,6 +118,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 e533d6035a9..274b9699ec7 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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 5648a2b2d1a..d7595eb9bce 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,15 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -116,7 +114,6 @@ 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 @@ -127,6 +124,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 5bc31690d4d..3ce39b9aaaa 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 d68184a3893..d520fe189e5 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,15 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -105,7 +103,6 @@ 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 @@ -116,6 +113,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 1072d2c37f2..901366de5b4 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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,7 +144,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -156,6 +154,8 @@ 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,7 +291,6 @@ 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 @@ -302,6 +301,8 @@ 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) @@ -360,7 +361,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -376,7 +376,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -398,6 +397,8 @@ 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) @@ -476,7 +477,6 @@ 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,6 +487,8 @@ 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 d091d89086f..ecb3b5bd56b 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -84,7 +82,6 @@ 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 @@ -95,6 +92,8 @@ 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 52fdeab10df..66cffbf2621 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +222,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,6 +232,8 @@ 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) @@ -365,7 +366,6 @@ 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,6 +376,8 @@ 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) @@ -434,7 +436,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,7 +451,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,6 +472,8 @@ 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) @@ -550,7 +552,6 @@ 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,6 +562,8 @@ 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 9e4c7aa9d09..4f7696475b0 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -105,7 +104,6 @@ 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 @@ -116,6 +114,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 7e9a2481aab..fe0d0d63b59 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -138,7 +137,6 @@ 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 @@ -149,6 +147,8 @@ 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 d52dad91367..e3f04a0d83a 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,6 +145,8 @@ 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) @@ -186,7 +185,6 @@ 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 @@ -197,6 +195,8 @@ 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 b56ceb3f3d8..4c83170266a 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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 7c0d921e97f..44066bc09b2 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 07f77dc295a..b25deb21953 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,6 +189,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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 2a5ccbd4a31..7d7257f5451 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ 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 @@ -120,6 +118,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 49ffba0daf7..20346552a27 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,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -78,7 +76,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -94,7 +91,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -116,6 +112,8 @@ 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) @@ -167,7 +165,6 @@ 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 @@ -178,6 +175,8 @@ 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 f9c7cfd3931..7230a950fe9 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -92,7 +90,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -108,7 +105,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -130,6 +126,8 @@ 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) @@ -220,7 +218,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,6 +228,8 @@ 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 4ed262f8a20..b2d617a4bc5 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -138,7 +136,6 @@ 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 @@ -149,6 +146,8 @@ 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) @@ -183,7 +182,6 @@ 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 @@ -194,6 +192,8 @@ 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 c0606063c12..14648ca6628 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,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -136,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -158,6 +155,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 72a3e8e6ca8..90fd8a17424 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,6 +161,8 @@ 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) @@ -254,7 +253,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,6 +263,8 @@ 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 db36404219b..316e6a1c5a6 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -181,7 +180,6 @@ 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 @@ -192,6 +190,8 @@ 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,7 +226,6 @@ 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 @@ -237,6 +236,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 1c5045af84a..aa9ab529632 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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,7 +144,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -156,6 +154,8 @@ 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,7 +291,6 @@ 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 @@ -302,6 +301,8 @@ 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,7 +362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,7 +377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -399,6 +398,8 @@ 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,7 +478,6 @@ 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,6 +488,8 @@ 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 2c7b51cbd16..6db37ef56d1 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -84,7 +82,6 @@ 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 @@ -95,6 +92,8 @@ 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 453d1e9a701..3e0bb0f1a93 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +222,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,6 +232,8 @@ 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) @@ -365,7 +366,6 @@ 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,6 +376,8 @@ 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) @@ -435,7 +437,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,7 +452,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -473,6 +473,8 @@ 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) @@ -551,7 +553,6 @@ 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,6 +563,8 @@ 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 dd30113fffc..0841b347342 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -105,7 +104,6 @@ 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 @@ -116,6 +114,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 185a63cd51e..d19e97f871c 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -138,7 +137,6 @@ 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 @@ -149,6 +147,8 @@ 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 e69e20bee2a..1a74574ddfc 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,6 +145,8 @@ 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) @@ -186,7 +185,6 @@ 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 @@ -197,6 +195,8 @@ 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 8de23e0ad26..a64f0455077 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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 59900fc2413..1767db8ec68 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 f684a4a1fde..2257eb5d77d 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,6 +189,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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 e1f1adb7a03..8553ff59e8d 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ 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 @@ -120,6 +118,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 31ec5724871..3bc8bf90a28 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,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -79,7 +77,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -95,7 +92,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -117,6 +113,8 @@ 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) @@ -168,7 +166,6 @@ 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 @@ -179,6 +176,8 @@ 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 3feab7cebb8..f843108bd4a 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -93,7 +91,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -109,7 +106,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -131,6 +127,8 @@ 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) @@ -221,7 +219,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,6 +229,8 @@ 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 dde3040ce50..7d7e6fccd94 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -138,7 +136,6 @@ 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 @@ -149,6 +146,8 @@ 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) @@ -183,7 +182,6 @@ 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 @@ -194,6 +192,8 @@ 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 e3f947ceef7..c33d9b3e554 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,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -136,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -158,6 +155,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 b5d51c45e71..7f473c831f5 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,6 +161,8 @@ 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) @@ -254,7 +253,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,6 +263,8 @@ 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 9a2c801c161..b785c33e1d0 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -181,7 +180,6 @@ 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 @@ -192,6 +190,8 @@ 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,7 +226,6 @@ 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 @@ -237,6 +236,8 @@ 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 f0a0ec64e8c..e1d4f2b44df 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 5837d37a93c..9bfd415353f 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,8 +8,6 @@ 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 5da1edaade7..670e2970625 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -76,7 +74,6 @@ 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), } @@ -90,6 +87,8 @@ 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 1156b1266d8..78030eb6522 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,7 +97,6 @@ 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), } @@ -112,6 +110,8 @@ 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 f0a0ec64e8c..e1d4f2b44df 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 5837d37a93c..9bfd415353f 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,8 +8,6 @@ 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 ed43663199d..9d75db26558 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -76,7 +74,6 @@ 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), } @@ -90,6 +87,8 @@ 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 e6d93c9a4a2..89682526e61 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiCustomBaseUrlServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -98,7 +97,6 @@ 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), } @@ -112,6 +110,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 6c0778f461a..afd19250228 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,16 +21,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 HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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, @@ -91,7 +89,6 @@ 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 @@ -102,6 +99,8 @@ 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) @@ -144,7 +143,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,6 +153,8 @@ 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,7 +290,6 @@ 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,6 +300,8 @@ 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) @@ -359,7 +360,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -375,7 +375,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -397,6 +396,8 @@ 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) @@ -475,7 +476,6 @@ 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,6 +486,8 @@ 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 bf66c2887bc..35cf7ac23a5 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 04aba94b57c..f91bf72f402 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,16 +21,15 @@ ) 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 +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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,7 +221,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,6 +231,8 @@ 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) @@ -364,7 +365,6 @@ 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,6 +375,8 @@ 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) @@ -433,7 +435,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -449,7 +450,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -471,6 +471,8 @@ 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) @@ -549,7 +551,6 @@ 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 @@ -560,6 +561,8 @@ 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 4345de484fb..40df8333152 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,7 +103,6 @@ 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 @@ -115,6 +113,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 e7a5a3dd74b..c703955f430 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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) @@ -137,7 +136,6 @@ 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 @@ -148,6 +146,8 @@ 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 9ff1afd2622..b424ad4b509 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -136,7 +134,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,6 +144,8 @@ 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) @@ -185,7 +184,6 @@ 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 @@ -196,6 +194,8 @@ 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 62a704394e2..13dacc29a09 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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 f03d6739e97..d74dd04dcae 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ 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 @@ -137,6 +135,8 @@ 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,7 +185,6 @@ 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,6 +195,8 @@ 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 80e4554b0b8..8f65bc6605e 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,7 +178,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,6 +188,8 @@ 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,7 +228,6 @@ 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,6 +238,8 @@ 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 d0b3d469960..207ae5c0efe 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,7 +107,6 @@ 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 @@ -119,6 +117,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 51e4f058d06..616c854958c 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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,7 +75,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -93,7 +90,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -115,6 +111,8 @@ 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) @@ -166,7 +164,6 @@ 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 @@ -177,6 +174,8 @@ 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 6bec77d0dee..08ea870f44d 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,14 +21,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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,7 +89,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -107,7 +104,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -129,6 +125,8 @@ 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) @@ -219,7 +217,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -230,6 +227,8 @@ 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 6ae64795ada..1083bcd3a3d 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ 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 @@ -148,6 +145,8 @@ 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) @@ -182,7 +181,6 @@ 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 @@ -193,6 +191,8 @@ 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 4532a04d5a0..4e8bc6fb90f 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,14 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,7 +118,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -135,7 +133,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -157,6 +154,8 @@ 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,7 +207,6 @@ 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 @@ -219,6 +217,8 @@ 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 0e198d2b0ef..10a119e545b 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,14 +21,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,7 +124,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +139,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -163,6 +160,8 @@ 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) @@ -253,7 +252,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,6 +262,8 @@ 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 d208240aa57..83756a46c38 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ 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 @@ -191,6 +189,8 @@ 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,7 +225,6 @@ 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,6 +235,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 0219bdc3dbf..e01b59cc860 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,16 +21,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 HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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, @@ -91,7 +89,6 @@ 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 @@ -102,6 +99,8 @@ 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) @@ -144,7 +143,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,6 +153,8 @@ 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,7 +291,6 @@ 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 @@ -302,6 +301,8 @@ 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) @@ -361,7 +362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,7 +377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -399,6 +398,8 @@ 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) @@ -477,7 +478,6 @@ 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,6 +488,8 @@ 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 f8c13fe1c79..1eeb7920156 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 1667d4c8f50..5bf152f0c9b 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,16 +21,15 @@ ) 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 +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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,7 +221,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,6 +231,8 @@ 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,7 +366,6 @@ 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,6 +376,8 @@ 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,7 +437,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,7 +452,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -473,6 +473,8 @@ 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,7 +553,6 @@ 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,6 +563,8 @@ 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 c8f6aca5678..05491c08710 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,7 +103,6 @@ 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 @@ -115,6 +113,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 005dac84f0b..695ac8a6d18 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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) @@ -137,7 +136,6 @@ 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 @@ -148,6 +146,8 @@ 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 cee63f303da..8f8597d3c39 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -136,7 +134,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -147,6 +144,8 @@ 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) @@ -185,7 +184,6 @@ 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 @@ -196,6 +194,8 @@ 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 5a2e682d5f5..e9d1514c5de 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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 2042ca97598..4b0d4fcc39d 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ 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 @@ -137,6 +135,8 @@ 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,7 +185,6 @@ 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,6 +195,8 @@ 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 2877ae1fdfb..491217429ea 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -179,7 +178,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -190,6 +188,8 @@ 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,7 +228,6 @@ 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,6 +238,8 @@ 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 bc32eac6aa7..37a125c1521 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -110,7 +109,6 @@ 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 @@ -121,6 +119,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 0f6f6abb0f1..97703a13ce4 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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,7 +75,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -93,7 +90,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -115,6 +111,8 @@ 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) @@ -167,7 +165,6 @@ 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 @@ -178,6 +175,8 @@ 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 8d47a2f0f05..316a1ce46e2 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,14 +21,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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,7 +89,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -107,7 +104,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -129,6 +125,8 @@ 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) @@ -219,7 +217,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -230,6 +227,8 @@ 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 8ef944418fc..f83a76df385 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ 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 @@ -148,6 +145,8 @@ 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) @@ -182,7 +181,6 @@ 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 @@ -193,6 +191,8 @@ 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 4936107a744..d28ff56b4b9 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,14 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -119,7 +118,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -135,7 +133,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -157,6 +154,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 bb41543f524..1b2000a42a3 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,14 +21,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -125,7 +124,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +139,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -163,6 +160,8 @@ 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) @@ -253,7 +252,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,6 +262,8 @@ 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 25bd3ef9121..83083d43add 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ 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 @@ -191,6 +189,8 @@ 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,7 +225,6 @@ 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,6 +235,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 356b1537d1b..10da17381b7 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +222,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,6 +232,8 @@ 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) @@ -365,7 +366,6 @@ 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,6 +376,8 @@ 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) @@ -434,7 +436,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,7 +451,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,6 +472,8 @@ 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) @@ -550,7 +552,6 @@ 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,6 +562,8 @@ 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 c5aa4bca4e5..402f73f56a3 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -105,7 +104,6 @@ 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 @@ -116,6 +114,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 bdebed04763..eae9af664e5 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 43eb0f6d90b..f64ded1d62f 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,6 +189,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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 0985856792e..71e20b73c23 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ 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 @@ -120,6 +118,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 8e6ccb2ba82..9450b403895 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,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -136,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -158,6 +155,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 3b540720eeb..b50e412ea44 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,6 +161,8 @@ 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) @@ -254,7 +253,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,6 +263,8 @@ 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 d31b1fee492..a1d74190199 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -181,7 +180,6 @@ 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 @@ -192,6 +190,8 @@ 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,7 +226,6 @@ 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 @@ -237,6 +236,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v0/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 3335c32db1b..e88a42149fa 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -82,7 +80,6 @@ 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 @@ -93,6 +90,8 @@ 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 775e0d70b2d..5d9e895f7c3 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -104,7 +102,6 @@ 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 @@ -115,6 +112,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 139cedcc01b..d44697709d3 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,16 +21,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 HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from ... 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, @@ -91,7 +89,6 @@ 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 @@ -102,6 +99,8 @@ 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) @@ -144,7 +143,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,6 +153,8 @@ 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,7 +290,6 @@ 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,6 +300,8 @@ 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) @@ -359,7 +360,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -375,7 +375,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -397,6 +396,8 @@ 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) @@ -475,7 +476,6 @@ 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,6 +486,8 @@ 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 772795102c0..42f5a57c152 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 4b4b7787829..7c16cacc768 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,16 +21,15 @@ ) 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 +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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,7 +221,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,6 +231,8 @@ 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) @@ -364,7 +365,6 @@ 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,6 +375,8 @@ 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) @@ -433,7 +435,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -449,7 +450,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -471,6 +471,8 @@ 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) @@ -549,7 +551,6 @@ 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 @@ -560,6 +561,8 @@ 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 d3642d91846..abf523f4020 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,7 +103,6 @@ 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 @@ -115,6 +113,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 a1cf4362317..2fb93a9da09 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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,7 +144,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -156,6 +154,8 @@ 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,7 +291,6 @@ 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 @@ -302,6 +301,8 @@ 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,7 +362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -377,7 +377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -399,6 +398,8 @@ 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,7 +478,6 @@ 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,6 +488,8 @@ 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 6b909c30028..45282e90abe 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -84,7 +82,6 @@ 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 @@ -95,6 +92,8 @@ 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 151140b66b0..9bda7201a81 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +222,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,6 +232,8 @@ 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) @@ -365,7 +366,6 @@ 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,6 +376,8 @@ 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) @@ -435,7 +437,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -451,7 +452,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -473,6 +473,8 @@ 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) @@ -551,7 +553,6 @@ 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,6 +563,8 @@ 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 bd12c2d936c..40a3699fcdf 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -105,7 +104,6 @@ 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 @@ -116,6 +114,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 1eae7eead17..c323405e9e5 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -138,7 +137,6 @@ 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 @@ -149,6 +147,8 @@ 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 2acfcc6d071..b0b5a2c98ad 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -137,7 +135,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -148,6 +145,8 @@ 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) @@ -186,7 +185,6 @@ 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 @@ -197,6 +195,8 @@ 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 af533360a28..ff3aebc3161 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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 75ee72e7d0d..9e92ff499eb 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 405800b440c..b353783becc 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -180,7 +179,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -191,6 +189,8 @@ 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,7 +229,6 @@ 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 @@ -240,6 +239,8 @@ 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 8cac92a5466..8e759e32863 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,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ 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 @@ -120,6 +118,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 d5032cfec97..37fe9d2d6a3 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,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -79,7 +77,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -95,7 +92,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -117,6 +113,8 @@ 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) @@ -168,7 +166,6 @@ 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 @@ -179,6 +176,8 @@ 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 859e77d95f8..f0f75989d75 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -93,7 +91,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -109,7 +106,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -131,6 +127,8 @@ 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) @@ -221,7 +219,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -232,6 +229,8 @@ 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 968205204e9..087333854cc 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -138,7 +136,6 @@ 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 @@ -149,6 +146,8 @@ 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) @@ -183,7 +182,6 @@ 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 @@ -194,6 +192,8 @@ 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 518e11df628..1656e87ea52 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,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -120,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -136,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -158,6 +155,8 @@ 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) @@ -209,7 +208,6 @@ 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 @@ -220,6 +218,8 @@ 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 0cd9fdc8ae0..13be57028df 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -126,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,6 +161,8 @@ 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) @@ -254,7 +253,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -265,6 +263,8 @@ 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 da144e12350..5833bd4deae 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -181,7 +180,6 @@ 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 @@ -192,6 +190,8 @@ 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,7 +226,6 @@ 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 @@ -237,6 +236,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 b6af7d542e3..41597d9d2c7 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -131,7 +129,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -142,6 +139,8 @@ 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) @@ -184,7 +183,6 @@ 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,6 +193,8 @@ 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,7 +234,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -250,7 +249,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -272,6 +270,8 @@ 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,7 +353,6 @@ 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 @@ -364,6 +363,8 @@ 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) @@ -402,7 +403,6 @@ 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,6 +413,8 @@ 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) @@ -458,7 +460,6 @@ 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 @@ -469,6 +470,8 @@ 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) @@ -515,7 +518,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -526,6 +528,8 @@ 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) @@ -652,7 +656,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -668,7 +671,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -690,6 +692,8 @@ 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) @@ -786,7 +790,6 @@ 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 @@ -797,6 +800,8 @@ 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) @@ -843,7 +848,6 @@ 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 @@ -854,6 +858,8 @@ 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) @@ -897,7 +903,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -913,7 +918,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -935,6 +939,8 @@ 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 451d8b0f8fd..36db0ffe42c 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -175,7 +174,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -186,6 +184,8 @@ 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,7 +228,6 @@ 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,6 +238,8 @@ 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) @@ -278,7 +279,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -294,7 +294,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -316,6 +315,8 @@ 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) @@ -436,7 +437,6 @@ 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,6 +447,8 @@ 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) @@ -485,7 +487,6 @@ 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 @@ -496,6 +497,8 @@ 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) @@ -641,7 +644,6 @@ def _test_lro_and_paging_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -652,6 +654,8 @@ 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) @@ -698,7 +702,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -709,6 +712,8 @@ 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) @@ -834,7 +839,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -850,7 +854,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -872,6 +875,8 @@ 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) @@ -968,7 +973,6 @@ 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 @@ -979,6 +983,8 @@ 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) @@ -1025,7 +1031,6 @@ 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 @@ -1036,6 +1041,8 @@ 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) @@ -1079,7 +1086,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1095,7 +1101,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1117,6 +1122,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 5487c50e713..fd4ae202bd7 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,9 +21,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +30,6 @@ 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, @@ -93,7 +91,6 @@ 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 @@ -104,6 +101,8 @@ 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) @@ -146,7 +145,6 @@ async def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -157,6 +155,8 @@ 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,7 +293,6 @@ 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 @@ -304,6 +303,8 @@ 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) @@ -363,7 +364,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -379,7 +379,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -401,6 +400,8 @@ 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) @@ -479,7 +480,6 @@ 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,6 +490,8 @@ 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) @@ -545,7 +547,6 @@ 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 @@ -556,6 +557,8 @@ 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 9f24dd704da..0c20c8c7cc0 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,9 +21,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import MultiapiServiceClientMixinABC, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -190,7 +189,6 @@ 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 @@ -201,6 +199,8 @@ 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,7 +243,6 @@ def _test_lro_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -254,6 +253,8 @@ 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) @@ -387,7 +388,6 @@ 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,6 +398,8 @@ 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) @@ -457,7 +459,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -473,7 +474,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -495,6 +495,8 @@ 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) @@ -573,7 +575,6 @@ 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 @@ -584,6 +585,8 @@ 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) @@ -639,7 +642,6 @@ 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 @@ -650,6 +652,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 b491366faeb..f3c973a626a 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -145,7 +144,6 @@ 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 @@ -156,6 +154,8 @@ 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,7 +263,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -274,6 +273,8 @@ 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) @@ -312,7 +313,6 @@ 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,6 +323,8 @@ 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) @@ -383,7 +385,6 @@ 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 @@ -394,6 +395,8 @@ 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 a0d13f2b3dc..a98bf3ab7b6 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,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -191,7 +190,6 @@ 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 @@ -202,6 +200,8 @@ 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,7 +250,6 @@ 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 @@ -261,6 +260,8 @@ 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) @@ -368,7 +369,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -379,6 +379,8 @@ 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) @@ -417,7 +419,6 @@ 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 @@ -428,6 +429,8 @@ 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) @@ -488,7 +491,6 @@ 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 @@ -499,6 +501,8 @@ 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 e4f41f72ec9..62c06452bbc 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultiapiServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 26b7d931df4..f5ac980a7cb 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,8 +8,6 @@ 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 8e89514af11..244f67b1af2 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,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... 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, @@ -83,7 +81,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -99,7 +96,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -121,6 +117,8 @@ 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) @@ -173,7 +171,6 @@ 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 @@ -184,6 +181,8 @@ 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) @@ -240,7 +239,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -256,7 +254,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -278,6 +275,8 @@ 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) @@ -368,7 +367,6 @@ async def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -379,6 +377,8 @@ 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,7 +491,6 @@ 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 @@ -502,6 +501,8 @@ 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) @@ -536,7 +537,6 @@ 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,6 +547,8 @@ 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 480e7b1e9f0..beb8ca726c4 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,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultiapiServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -200,7 +199,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -216,7 +214,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -238,6 +235,8 @@ 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) @@ -290,7 +289,6 @@ 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 @@ -301,6 +299,8 @@ 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,7 +357,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -373,7 +372,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -395,6 +393,8 @@ 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,7 +485,6 @@ def test_two( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -496,6 +495,8 @@ 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) @@ -608,7 +609,6 @@ 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,6 +619,8 @@ 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) @@ -653,7 +655,6 @@ 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 @@ -664,6 +665,8 @@ 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 fcdb13e4ce3..a104b3f3b1d 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 == "" + assert response is None @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 == "" + assert response is None @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 5c6450501ad..dbb78e096b7 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 not is_rest(request.http_request) + assert 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 not is_rest(response.http_response) + assert 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 b21e98d27de..ed6c80edfef 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.pipeline.transport import HttpRequest +from azure.core.rest 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 28835c798e9..5ee10a42e87 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 not is_rest(request.http_request) + assert 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 not is_rest(response.http_response) + assert 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 5b4e79e5b88..3eb8d09f157 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.pipeline.transport import HttpRequest +from azure.core.rest 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 cb47773374c..a3f2273eec8 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -135,7 +133,6 @@ async def create_ap_true( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -146,6 +143,8 @@ 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) @@ -230,7 +229,6 @@ async def create_cat_ap_true( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,6 +239,8 @@ 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,7 +325,6 @@ async def create_ap_object( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -336,6 +335,8 @@ 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) @@ -420,7 +421,6 @@ async def create_ap_string( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -431,6 +431,8 @@ 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) @@ -515,7 +517,6 @@ async def create_ap_in_properties( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -526,6 +527,8 @@ 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) @@ -616,7 +619,6 @@ 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 @@ -627,6 +629,8 @@ 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 2e964d7390a..078ff62ba64 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -233,7 +231,6 @@ def create_ap_true( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -244,6 +241,8 @@ 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) @@ -328,7 +327,6 @@ def create_cat_ap_true( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -339,6 +337,8 @@ 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,7 +423,6 @@ def create_ap_object( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -434,6 +433,8 @@ 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) @@ -518,7 +519,6 @@ def create_ap_string( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -529,6 +529,8 @@ 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) @@ -613,7 +615,6 @@ def create_ap_in_properties( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -624,6 +625,8 @@ 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) @@ -714,7 +717,6 @@ 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 @@ -725,6 +727,8 @@ 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 d756d07f319..dc910ddc7e5 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 2007e9f7a76..29d65bdd121 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,8 +8,6 @@ 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 c6d091f4a40..f2671ee3f00 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -70,7 +68,6 @@ 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 @@ -81,6 +78,8 @@ 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) @@ -124,7 +123,6 @@ 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 @@ -135,6 +133,8 @@ 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,7 +166,6 @@ 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 @@ -177,6 +176,8 @@ 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) @@ -220,7 +221,6 @@ 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,6 +231,8 @@ 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) @@ -262,7 +264,6 @@ 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 @@ -273,6 +274,8 @@ 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) @@ -316,7 +319,6 @@ 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 @@ -327,6 +329,8 @@ 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 5e68127ea9c..16b288c25d8 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import AnythingClientMixinABC, _convert_request +from .._vendor import AnythingClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -149,7 +148,6 @@ 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 @@ -160,6 +158,8 @@ 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,7 +203,6 @@ 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 @@ -214,6 +213,8 @@ 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) @@ -245,7 +246,6 @@ 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,6 +256,8 @@ 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) @@ -299,7 +301,6 @@ 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 @@ -310,6 +311,8 @@ 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) @@ -341,7 +344,6 @@ 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 @@ -352,6 +354,8 @@ 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) @@ -395,7 +399,6 @@ 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 @@ -406,6 +409,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 e923f96ffe5..4c30b70a174 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -151,7 +149,6 @@ 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 @@ -162,6 +159,8 @@ 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) @@ -198,7 +197,6 @@ 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 @@ -209,6 +207,8 @@ 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,7 +245,6 @@ 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 @@ -256,6 +255,8 @@ 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) @@ -340,7 +341,6 @@ 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,6 +351,8 @@ 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) @@ -383,7 +385,6 @@ 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 @@ -394,6 +395,8 @@ 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) @@ -478,7 +481,6 @@ 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 @@ -489,6 +491,8 @@ 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) @@ -521,7 +525,6 @@ 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 @@ -532,6 +535,8 @@ 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) @@ -568,7 +573,6 @@ 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 @@ -579,6 +583,8 @@ 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) @@ -615,7 +621,6 @@ 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 @@ -626,6 +631,8 @@ 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) @@ -710,7 +717,6 @@ 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 @@ -721,6 +727,8 @@ 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) @@ -753,7 +761,6 @@ 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 @@ -764,6 +771,8 @@ 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) @@ -800,7 +809,6 @@ 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 @@ -811,6 +819,8 @@ 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) @@ -847,7 +857,6 @@ 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 @@ -858,6 +867,8 @@ 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) @@ -942,7 +953,6 @@ 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 @@ -953,6 +963,8 @@ 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) @@ -985,7 +997,6 @@ 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 @@ -996,6 +1007,8 @@ 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) @@ -1032,7 +1045,6 @@ 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 @@ -1043,6 +1055,8 @@ 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) @@ -1079,7 +1093,6 @@ 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 @@ -1090,6 +1103,8 @@ 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) @@ -1174,7 +1189,6 @@ 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 @@ -1185,6 +1199,8 @@ 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) @@ -1217,7 +1233,6 @@ 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 @@ -1228,6 +1243,8 @@ 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) @@ -1264,7 +1281,6 @@ 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 @@ -1275,6 +1291,8 @@ 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) @@ -1311,7 +1329,6 @@ 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 @@ -1322,6 +1339,8 @@ 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) @@ -1406,7 +1425,6 @@ 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 @@ -1417,6 +1435,8 @@ 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) @@ -1449,7 +1469,6 @@ 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 @@ -1460,6 +1479,8 @@ 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) @@ -1496,7 +1517,6 @@ 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 @@ -1507,6 +1527,8 @@ 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) @@ -1543,7 +1565,6 @@ 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 @@ -1554,6 +1575,8 @@ 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) @@ -1638,7 +1661,6 @@ 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 @@ -1649,6 +1671,8 @@ 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) @@ -1681,7 +1705,6 @@ 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 @@ -1692,6 +1715,8 @@ 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) @@ -1777,7 +1802,6 @@ 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 @@ -1788,6 +1812,8 @@ 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) @@ -1820,7 +1846,6 @@ 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 @@ -1831,6 +1856,8 @@ 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) @@ -1916,7 +1943,6 @@ 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 @@ -1927,6 +1953,8 @@ 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) @@ -1959,7 +1987,6 @@ 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 @@ -1970,6 +1997,8 @@ 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) @@ -2006,7 +2035,6 @@ 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 @@ -2017,6 +2045,8 @@ 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) @@ -2054,7 +2084,6 @@ 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 @@ -2065,6 +2094,8 @@ 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) @@ -2152,7 +2183,6 @@ 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 @@ -2163,6 +2193,8 @@ 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) @@ -2195,7 +2227,6 @@ 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 @@ -2206,6 +2237,8 @@ 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) @@ -2242,7 +2275,6 @@ 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 @@ -2253,6 +2285,8 @@ 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) @@ -2337,7 +2371,6 @@ 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 @@ -2348,6 +2381,8 @@ 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) @@ -2380,7 +2415,6 @@ 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 @@ -2391,6 +2425,8 @@ 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) @@ -2427,7 +2463,6 @@ 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 @@ -2438,6 +2473,8 @@ 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) @@ -2475,7 +2512,6 @@ 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 @@ -2486,6 +2522,8 @@ 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) @@ -2573,7 +2611,6 @@ 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 @@ -2584,6 +2621,8 @@ 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) @@ -2616,7 +2655,6 @@ 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 @@ -2627,6 +2665,8 @@ 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) @@ -2663,7 +2703,6 @@ 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 @@ -2674,6 +2713,8 @@ 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) @@ -2711,7 +2752,6 @@ 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 @@ -2722,6 +2762,8 @@ 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) @@ -2809,7 +2851,6 @@ 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 @@ -2820,6 +2861,8 @@ 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) @@ -2852,7 +2895,6 @@ 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 @@ -2863,6 +2905,8 @@ 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) @@ -2947,7 +2991,6 @@ 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 @@ -2958,6 +3001,8 @@ 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) @@ -2991,7 +3036,6 @@ 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 @@ -3002,6 +3046,8 @@ 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) @@ -3089,7 +3135,6 @@ 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 @@ -3100,6 +3145,8 @@ 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) @@ -3132,7 +3179,6 @@ 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 @@ -3143,6 +3189,8 @@ 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) @@ -3180,7 +3228,6 @@ 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 @@ -3191,6 +3238,8 @@ 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) @@ -3227,7 +3276,6 @@ 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 @@ -3238,6 +3286,8 @@ 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) @@ -3274,7 +3324,6 @@ 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 @@ -3285,6 +3334,8 @@ 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) @@ -3322,7 +3373,6 @@ 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 @@ -3333,6 +3383,8 @@ 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) @@ -3370,7 +3422,6 @@ 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 @@ -3381,6 +3432,8 @@ 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) @@ -3418,7 +3471,6 @@ 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 @@ -3429,6 +3481,8 @@ 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) @@ -3516,7 +3570,6 @@ 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 @@ -3527,6 +3580,8 @@ 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) @@ -3559,7 +3614,6 @@ 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 @@ -3570,6 +3624,8 @@ 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) @@ -3606,7 +3662,6 @@ 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 @@ -3617,6 +3672,8 @@ 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) @@ -3653,7 +3710,6 @@ 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 @@ -3664,6 +3720,8 @@ 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) @@ -3700,7 +3758,6 @@ 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 @@ -3711,6 +3768,8 @@ 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) @@ -3747,7 +3806,6 @@ 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 @@ -3758,6 +3816,8 @@ 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) @@ -3842,7 +3902,6 @@ 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 @@ -3853,6 +3912,8 @@ 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) @@ -3885,7 +3946,6 @@ 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 @@ -3896,6 +3956,8 @@ 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) @@ -3932,7 +3994,6 @@ 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 @@ -3943,6 +4004,8 @@ 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) @@ -3980,7 +4043,6 @@ 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 @@ -3991,6 +4053,8 @@ 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) @@ -4028,7 +4092,6 @@ 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 @@ -4039,6 +4102,8 @@ 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) @@ -4076,7 +4141,6 @@ 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 @@ -4087,6 +4151,8 @@ 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) @@ -4174,7 +4240,6 @@ 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 @@ -4185,6 +4250,8 @@ 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 3fb751cd1ed..fbc69cb7f08 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -1104,7 +1102,6 @@ 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 @@ -1115,6 +1112,8 @@ 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) @@ -1151,7 +1150,6 @@ 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 @@ -1162,6 +1160,8 @@ 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,7 +1198,6 @@ 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 @@ -1209,6 +1208,8 @@ 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) @@ -1293,7 +1294,6 @@ 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,6 +1304,8 @@ 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) @@ -1336,7 +1338,6 @@ 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 @@ -1347,6 +1348,8 @@ 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) @@ -1431,7 +1434,6 @@ 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 @@ -1442,6 +1444,8 @@ 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) @@ -1474,7 +1478,6 @@ 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 @@ -1485,6 +1488,8 @@ 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) @@ -1521,7 +1526,6 @@ 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 @@ -1532,6 +1536,8 @@ 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) @@ -1568,7 +1574,6 @@ 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 @@ -1579,6 +1584,8 @@ 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) @@ -1663,7 +1670,6 @@ 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 @@ -1674,6 +1680,8 @@ 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) @@ -1706,7 +1714,6 @@ 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 @@ -1717,6 +1724,8 @@ 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) @@ -1753,7 +1762,6 @@ 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 @@ -1764,6 +1772,8 @@ 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) @@ -1800,7 +1810,6 @@ 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 @@ -1811,6 +1820,8 @@ 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) @@ -1895,7 +1906,6 @@ 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 @@ -1906,6 +1916,8 @@ 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) @@ -1938,7 +1950,6 @@ 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 @@ -1949,6 +1960,8 @@ 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) @@ -1985,7 +1998,6 @@ 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 @@ -1996,6 +2008,8 @@ 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) @@ -2032,7 +2046,6 @@ 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 @@ -2043,6 +2056,8 @@ 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) @@ -2127,7 +2142,6 @@ 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 @@ -2138,6 +2152,8 @@ 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) @@ -2170,7 +2186,6 @@ 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 @@ -2181,6 +2196,8 @@ 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) @@ -2217,7 +2234,6 @@ 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 @@ -2228,6 +2244,8 @@ 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) @@ -2264,7 +2282,6 @@ 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 @@ -2275,6 +2292,8 @@ 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) @@ -2359,7 +2378,6 @@ 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 @@ -2370,6 +2388,8 @@ 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) @@ -2402,7 +2422,6 @@ 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 @@ -2413,6 +2432,8 @@ 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) @@ -2449,7 +2470,6 @@ 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 @@ -2460,6 +2480,8 @@ 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) @@ -2496,7 +2518,6 @@ 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 @@ -2507,6 +2528,8 @@ 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) @@ -2591,7 +2614,6 @@ 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 @@ -2602,6 +2624,8 @@ 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) @@ -2634,7 +2658,6 @@ 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 @@ -2645,6 +2668,8 @@ 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) @@ -2730,7 +2755,6 @@ 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 @@ -2741,6 +2765,8 @@ 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) @@ -2773,7 +2799,6 @@ 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 @@ -2784,6 +2809,8 @@ 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) @@ -2869,7 +2896,6 @@ 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 @@ -2880,6 +2906,8 @@ 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) @@ -2912,7 +2940,6 @@ 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 @@ -2923,6 +2950,8 @@ 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) @@ -2959,7 +2988,6 @@ 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 @@ -2970,6 +2998,8 @@ 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) @@ -3007,7 +3037,6 @@ 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 @@ -3018,6 +3047,8 @@ 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) @@ -3105,7 +3136,6 @@ 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 @@ -3116,6 +3146,8 @@ 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) @@ -3148,7 +3180,6 @@ 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 @@ -3159,6 +3190,8 @@ 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) @@ -3195,7 +3228,6 @@ 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 @@ -3206,6 +3238,8 @@ 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) @@ -3290,7 +3324,6 @@ 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 @@ -3301,6 +3334,8 @@ 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) @@ -3333,7 +3368,6 @@ 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 @@ -3344,6 +3378,8 @@ 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) @@ -3380,7 +3416,6 @@ 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 @@ -3391,6 +3426,8 @@ 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) @@ -3428,7 +3465,6 @@ 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 @@ -3439,6 +3475,8 @@ 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) @@ -3526,7 +3564,6 @@ 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 @@ -3537,6 +3574,8 @@ 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) @@ -3569,7 +3608,6 @@ 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 @@ -3580,6 +3618,8 @@ 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) @@ -3616,7 +3656,6 @@ 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 @@ -3627,6 +3666,8 @@ 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) @@ -3664,7 +3705,6 @@ 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 @@ -3675,6 +3715,8 @@ 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) @@ -3762,7 +3804,6 @@ 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 @@ -3773,6 +3814,8 @@ 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) @@ -3805,7 +3848,6 @@ 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 @@ -3816,6 +3858,8 @@ 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) @@ -3900,7 +3944,6 @@ 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 @@ -3911,6 +3954,8 @@ 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) @@ -3944,7 +3989,6 @@ 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 @@ -3955,6 +3999,8 @@ 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) @@ -4042,7 +4088,6 @@ 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 @@ -4053,6 +4098,8 @@ 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) @@ -4085,7 +4132,6 @@ 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 @@ -4096,6 +4142,8 @@ 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) @@ -4133,7 +4181,6 @@ 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 @@ -4144,6 +4191,8 @@ 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) @@ -4180,7 +4229,6 @@ 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 @@ -4191,6 +4239,8 @@ 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) @@ -4227,7 +4277,6 @@ 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 @@ -4238,6 +4287,8 @@ 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) @@ -4275,7 +4326,6 @@ 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 @@ -4286,6 +4336,8 @@ 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) @@ -4323,7 +4375,6 @@ 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 @@ -4334,6 +4385,8 @@ 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) @@ -4371,7 +4424,6 @@ 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 @@ -4382,6 +4434,8 @@ 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) @@ -4469,7 +4523,6 @@ 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 @@ -4480,6 +4533,8 @@ 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) @@ -4512,7 +4567,6 @@ 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 @@ -4523,6 +4577,8 @@ 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) @@ -4559,7 +4615,6 @@ 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 @@ -4570,6 +4625,8 @@ 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) @@ -4606,7 +4663,6 @@ 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 @@ -4617,6 +4673,8 @@ 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) @@ -4653,7 +4711,6 @@ 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 @@ -4664,6 +4721,8 @@ 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) @@ -4700,7 +4759,6 @@ 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 @@ -4711,6 +4769,8 @@ 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) @@ -4795,7 +4855,6 @@ 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 @@ -4806,6 +4865,8 @@ 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) @@ -4838,7 +4899,6 @@ 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 @@ -4849,6 +4909,8 @@ 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) @@ -4885,7 +4947,6 @@ 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 @@ -4896,6 +4957,8 @@ 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) @@ -4933,7 +4996,6 @@ 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 @@ -4944,6 +5006,8 @@ 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) @@ -4981,7 +5045,6 @@ 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 @@ -4992,6 +5055,8 @@ 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) @@ -5029,7 +5094,6 @@ 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 @@ -5040,6 +5104,8 @@ 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) @@ -5127,7 +5193,6 @@ 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 @@ -5138,6 +5203,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 a8c57560ecb..30d742e8ccf 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -151,7 +149,6 @@ 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 @@ -162,6 +159,8 @@ 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) @@ -198,7 +197,6 @@ 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 @@ -209,6 +207,8 @@ 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,7 +245,6 @@ 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 @@ -256,6 +255,8 @@ 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) @@ -340,7 +341,6 @@ 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,6 +351,8 @@ 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) @@ -383,7 +385,6 @@ 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 @@ -394,6 +395,8 @@ 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) @@ -478,7 +481,6 @@ 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 @@ -489,6 +491,8 @@ 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) @@ -521,7 +525,6 @@ 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 @@ -532,6 +535,8 @@ 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) @@ -568,7 +573,6 @@ 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 @@ -579,6 +583,8 @@ 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) @@ -615,7 +621,6 @@ 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 @@ -626,6 +631,8 @@ 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) @@ -710,7 +717,6 @@ 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 @@ -721,6 +727,8 @@ 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) @@ -753,7 +761,6 @@ 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 @@ -764,6 +771,8 @@ 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) @@ -800,7 +809,6 @@ 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 @@ -811,6 +819,8 @@ 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) @@ -847,7 +857,6 @@ 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 @@ -858,6 +867,8 @@ 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) @@ -942,7 +953,6 @@ 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 @@ -953,6 +963,8 @@ 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) @@ -985,7 +997,6 @@ 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 @@ -996,6 +1007,8 @@ 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) @@ -1032,7 +1045,6 @@ 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 @@ -1043,6 +1055,8 @@ 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) @@ -1079,7 +1093,6 @@ 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 @@ -1090,6 +1103,8 @@ 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) @@ -1174,7 +1189,6 @@ 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 @@ -1185,6 +1199,8 @@ 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) @@ -1217,7 +1233,6 @@ 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 @@ -1228,6 +1243,8 @@ 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) @@ -1264,7 +1281,6 @@ 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 @@ -1275,6 +1291,8 @@ 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) @@ -1311,7 +1329,6 @@ 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 @@ -1322,6 +1339,8 @@ 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) @@ -1406,7 +1425,6 @@ 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 @@ -1417,6 +1435,8 @@ 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) @@ -1449,7 +1469,6 @@ 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 @@ -1460,6 +1479,8 @@ 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) @@ -1496,7 +1517,6 @@ 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 @@ -1507,6 +1527,8 @@ 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) @@ -1543,7 +1565,6 @@ 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 @@ -1554,6 +1575,8 @@ 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) @@ -1638,7 +1661,6 @@ 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 @@ -1649,6 +1671,8 @@ 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) @@ -1681,7 +1705,6 @@ 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 @@ -1692,6 +1715,8 @@ 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) @@ -1777,7 +1802,6 @@ 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 @@ -1788,6 +1812,8 @@ 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) @@ -1820,7 +1846,6 @@ 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 @@ -1831,6 +1856,8 @@ 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) @@ -1916,7 +1943,6 @@ 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 @@ -1927,6 +1953,8 @@ 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) @@ -1959,7 +1987,6 @@ 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 @@ -1970,6 +1997,8 @@ 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) @@ -2006,7 +2035,6 @@ 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 @@ -2017,6 +2045,8 @@ 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) @@ -2054,7 +2084,6 @@ 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 @@ -2065,6 +2094,8 @@ 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) @@ -2152,7 +2183,6 @@ 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 @@ -2163,6 +2193,8 @@ 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) @@ -2195,7 +2227,6 @@ 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 @@ -2206,6 +2237,8 @@ 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) @@ -2242,7 +2275,6 @@ 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 @@ -2253,6 +2285,8 @@ 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) @@ -2337,7 +2371,6 @@ 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 @@ -2348,6 +2381,8 @@ 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) @@ -2380,7 +2415,6 @@ 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 @@ -2391,6 +2425,8 @@ 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) @@ -2427,7 +2463,6 @@ 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 @@ -2438,6 +2473,8 @@ 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) @@ -2475,7 +2512,6 @@ 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 @@ -2486,6 +2522,8 @@ 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) @@ -2573,7 +2611,6 @@ 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 @@ -2584,6 +2621,8 @@ 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) @@ -2616,7 +2655,6 @@ 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 @@ -2627,6 +2665,8 @@ 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) @@ -2663,7 +2703,6 @@ 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 @@ -2674,6 +2713,8 @@ 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) @@ -2711,7 +2752,6 @@ 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 @@ -2722,6 +2762,8 @@ 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) @@ -2809,7 +2851,6 @@ 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 @@ -2820,6 +2861,8 @@ 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) @@ -2852,7 +2895,6 @@ 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 @@ -2863,6 +2905,8 @@ 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) @@ -2947,7 +2991,6 @@ 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 @@ -2958,6 +3001,8 @@ 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) @@ -2991,7 +3036,6 @@ 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 @@ -3002,6 +3046,8 @@ 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) @@ -3089,7 +3135,6 @@ 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 @@ -3100,6 +3145,8 @@ 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) @@ -3132,7 +3179,6 @@ 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 @@ -3143,6 +3189,8 @@ 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) @@ -3180,7 +3228,6 @@ 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 @@ -3191,6 +3238,8 @@ 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) @@ -3227,7 +3276,6 @@ 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 @@ -3238,6 +3286,8 @@ 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) @@ -3274,7 +3324,6 @@ 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 @@ -3285,6 +3334,8 @@ 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) @@ -3322,7 +3373,6 @@ 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 @@ -3333,6 +3383,8 @@ 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) @@ -3370,7 +3422,6 @@ 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 @@ -3381,6 +3432,8 @@ 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) @@ -3418,7 +3471,6 @@ 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 @@ -3429,6 +3481,8 @@ 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) @@ -3516,7 +3570,6 @@ 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 @@ -3527,6 +3580,8 @@ 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) @@ -3559,7 +3614,6 @@ 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 @@ -3570,6 +3624,8 @@ 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) @@ -3606,7 +3662,6 @@ 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 @@ -3617,6 +3672,8 @@ 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) @@ -3653,7 +3710,6 @@ 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 @@ -3664,6 +3720,8 @@ 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) @@ -3700,7 +3758,6 @@ 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 @@ -3711,6 +3768,8 @@ 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) @@ -3747,7 +3806,6 @@ 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 @@ -3758,6 +3816,8 @@ 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) @@ -3842,7 +3902,6 @@ 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 @@ -3853,6 +3912,8 @@ 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) @@ -3885,7 +3946,6 @@ 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 @@ -3896,6 +3956,8 @@ 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) @@ -3932,7 +3994,6 @@ 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 @@ -3943,6 +4004,8 @@ 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) @@ -3980,7 +4043,6 @@ 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 @@ -3991,6 +4053,8 @@ 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) @@ -4028,7 +4092,6 @@ 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 @@ -4039,6 +4102,8 @@ 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) @@ -4076,7 +4141,6 @@ 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 @@ -4087,6 +4151,8 @@ 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) @@ -4174,7 +4240,6 @@ 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 @@ -4185,6 +4250,8 @@ 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 9b087ca2058..65ece63c583 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -1104,7 +1102,6 @@ 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 @@ -1115,6 +1112,8 @@ 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) @@ -1151,7 +1150,6 @@ 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 @@ -1162,6 +1160,8 @@ 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,7 +1198,6 @@ 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 @@ -1209,6 +1208,8 @@ 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) @@ -1293,7 +1294,6 @@ 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,6 +1304,8 @@ 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) @@ -1336,7 +1338,6 @@ 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 @@ -1347,6 +1348,8 @@ 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) @@ -1431,7 +1434,6 @@ 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 @@ -1442,6 +1444,8 @@ 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) @@ -1474,7 +1478,6 @@ 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 @@ -1485,6 +1488,8 @@ 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) @@ -1521,7 +1526,6 @@ 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 @@ -1532,6 +1536,8 @@ 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) @@ -1568,7 +1574,6 @@ 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 @@ -1579,6 +1584,8 @@ 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) @@ -1663,7 +1670,6 @@ 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 @@ -1674,6 +1680,8 @@ 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) @@ -1706,7 +1714,6 @@ 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 @@ -1717,6 +1724,8 @@ 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) @@ -1753,7 +1762,6 @@ 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 @@ -1764,6 +1772,8 @@ 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) @@ -1800,7 +1810,6 @@ 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 @@ -1811,6 +1820,8 @@ 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) @@ -1895,7 +1906,6 @@ 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 @@ -1906,6 +1916,8 @@ 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) @@ -1938,7 +1950,6 @@ 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 @@ -1949,6 +1960,8 @@ 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) @@ -1985,7 +1998,6 @@ 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 @@ -1996,6 +2008,8 @@ 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) @@ -2032,7 +2046,6 @@ 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 @@ -2043,6 +2056,8 @@ 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) @@ -2127,7 +2142,6 @@ 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 @@ -2138,6 +2152,8 @@ 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) @@ -2170,7 +2186,6 @@ 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 @@ -2181,6 +2196,8 @@ 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) @@ -2217,7 +2234,6 @@ 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 @@ -2228,6 +2244,8 @@ 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) @@ -2264,7 +2282,6 @@ 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 @@ -2275,6 +2292,8 @@ 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) @@ -2359,7 +2378,6 @@ 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 @@ -2370,6 +2388,8 @@ 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) @@ -2402,7 +2422,6 @@ 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 @@ -2413,6 +2432,8 @@ 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) @@ -2449,7 +2470,6 @@ 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 @@ -2460,6 +2480,8 @@ 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) @@ -2496,7 +2518,6 @@ 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 @@ -2507,6 +2528,8 @@ 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) @@ -2591,7 +2614,6 @@ 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 @@ -2602,6 +2624,8 @@ 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) @@ -2634,7 +2658,6 @@ 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 @@ -2645,6 +2668,8 @@ 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) @@ -2730,7 +2755,6 @@ 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 @@ -2741,6 +2765,8 @@ 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) @@ -2773,7 +2799,6 @@ 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 @@ -2784,6 +2809,8 @@ 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) @@ -2869,7 +2896,6 @@ 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 @@ -2880,6 +2906,8 @@ 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) @@ -2912,7 +2940,6 @@ 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 @@ -2923,6 +2950,8 @@ 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) @@ -2959,7 +2988,6 @@ 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 @@ -2970,6 +2998,8 @@ 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) @@ -3007,7 +3037,6 @@ 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 @@ -3018,6 +3047,8 @@ 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) @@ -3105,7 +3136,6 @@ 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 @@ -3116,6 +3146,8 @@ 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) @@ -3148,7 +3180,6 @@ 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 @@ -3159,6 +3190,8 @@ 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) @@ -3195,7 +3228,6 @@ 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 @@ -3206,6 +3238,8 @@ 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) @@ -3290,7 +3324,6 @@ 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 @@ -3301,6 +3334,8 @@ 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) @@ -3333,7 +3368,6 @@ 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 @@ -3344,6 +3378,8 @@ 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) @@ -3380,7 +3416,6 @@ 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 @@ -3391,6 +3426,8 @@ 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) @@ -3428,7 +3465,6 @@ 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 @@ -3439,6 +3475,8 @@ 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) @@ -3526,7 +3564,6 @@ 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 @@ -3537,6 +3574,8 @@ 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) @@ -3569,7 +3608,6 @@ 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 @@ -3580,6 +3618,8 @@ 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) @@ -3616,7 +3656,6 @@ 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 @@ -3627,6 +3666,8 @@ 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) @@ -3664,7 +3705,6 @@ 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 @@ -3675,6 +3715,8 @@ 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) @@ -3762,7 +3804,6 @@ 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 @@ -3773,6 +3814,8 @@ 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) @@ -3805,7 +3848,6 @@ 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 @@ -3816,6 +3858,8 @@ 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) @@ -3900,7 +3944,6 @@ 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 @@ -3911,6 +3954,8 @@ 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) @@ -3944,7 +3989,6 @@ 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 @@ -3955,6 +3999,8 @@ 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) @@ -4042,7 +4088,6 @@ 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 @@ -4053,6 +4098,8 @@ 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) @@ -4085,7 +4132,6 @@ 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 @@ -4096,6 +4142,8 @@ 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) @@ -4133,7 +4181,6 @@ 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 @@ -4144,6 +4191,8 @@ 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) @@ -4180,7 +4229,6 @@ 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 @@ -4191,6 +4239,8 @@ 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) @@ -4227,7 +4277,6 @@ 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 @@ -4238,6 +4287,8 @@ 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) @@ -4275,7 +4326,6 @@ 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 @@ -4286,6 +4336,8 @@ 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) @@ -4323,7 +4375,6 @@ 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 @@ -4334,6 +4385,8 @@ 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) @@ -4371,7 +4424,6 @@ 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 @@ -4382,6 +4434,8 @@ 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) @@ -4469,7 +4523,6 @@ 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 @@ -4480,6 +4533,8 @@ 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) @@ -4512,7 +4567,6 @@ 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 @@ -4523,6 +4577,8 @@ 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) @@ -4559,7 +4615,6 @@ 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 @@ -4570,6 +4625,8 @@ 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) @@ -4606,7 +4663,6 @@ 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 @@ -4617,6 +4673,8 @@ 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) @@ -4653,7 +4711,6 @@ 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 @@ -4664,6 +4721,8 @@ 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) @@ -4700,7 +4759,6 @@ 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 @@ -4711,6 +4769,8 @@ 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) @@ -4795,7 +4855,6 @@ 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 @@ -4806,6 +4865,8 @@ 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) @@ -4838,7 +4899,6 @@ 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 @@ -4849,6 +4909,8 @@ 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) @@ -4885,7 +4947,6 @@ 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 @@ -4896,6 +4957,8 @@ 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) @@ -4933,7 +4996,6 @@ 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 @@ -4944,6 +5006,8 @@ 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) @@ -4981,7 +5045,6 @@ 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 @@ -4992,6 +5055,8 @@ 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) @@ -5029,7 +5094,6 @@ 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 @@ -5040,6 +5104,8 @@ 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) @@ -5127,7 +5193,6 @@ 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 @@ -5138,6 +5203,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 b216f6ab6b5..c3e8fd4212c 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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 089728539de..6e254733009 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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) @@ -139,7 +138,6 @@ 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 @@ -150,6 +148,8 @@ 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 be598b602d7..46b6e1fc78e 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -96,7 +94,6 @@ 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 @@ -107,6 +104,8 @@ 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 f8b0ff9e181..1ce2a01cd3b 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +115,6 @@ 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 @@ -128,6 +125,8 @@ 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) @@ -166,7 +165,6 @@ 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 @@ -177,6 +175,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 98dd0493957..89b0b7acb14 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -139,7 +138,6 @@ 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 @@ -150,6 +148,8 @@ 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,7 +182,6 @@ 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 @@ -193,6 +192,8 @@ 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) @@ -235,7 +236,6 @@ 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,6 +246,8 @@ 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) @@ -278,7 +280,6 @@ 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 @@ -289,6 +290,8 @@ 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) @@ -325,7 +328,6 @@ 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 @@ -336,6 +338,8 @@ 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 601c4a091f9..7d4cd9e0f28 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +172,6 @@ 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 @@ -185,6 +182,8 @@ 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) @@ -227,7 +226,6 @@ 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 @@ -238,6 +236,8 @@ 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,7 +270,6 @@ 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 @@ -281,6 +280,8 @@ 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) @@ -323,7 +324,6 @@ 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,6 +334,8 @@ 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) @@ -366,7 +368,6 @@ 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 @@ -377,6 +378,8 @@ 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) @@ -413,7 +416,6 @@ 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 @@ -424,6 +426,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 bc083defa5a..b3123f27d88 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -85,7 +83,6 @@ 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 @@ -96,6 +93,8 @@ 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) @@ -132,7 +131,6 @@ 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 @@ -143,6 +141,8 @@ 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,7 +179,6 @@ 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 @@ -190,6 +189,8 @@ 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) @@ -236,7 +237,6 @@ 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,6 +247,8 @@ 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) @@ -279,7 +281,6 @@ 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 @@ -290,6 +291,8 @@ 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 8bc2a8b282b..bfab437ebfb 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -155,7 +153,6 @@ 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 @@ -166,6 +163,8 @@ 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) @@ -202,7 +201,6 @@ 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 @@ -213,6 +211,8 @@ 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,7 +249,6 @@ 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 @@ -260,6 +259,8 @@ 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) @@ -304,7 +305,6 @@ 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,6 +315,8 @@ 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) @@ -347,7 +349,6 @@ 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 @@ -358,6 +359,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 cb57ae50e81..2d095c3a299 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -85,7 +83,6 @@ 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 @@ -96,6 +93,8 @@ 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) @@ -132,7 +131,6 @@ 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 @@ -143,6 +141,8 @@ 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,7 +179,6 @@ 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 @@ -190,6 +189,8 @@ 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) @@ -236,7 +237,6 @@ 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,6 +247,8 @@ 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) @@ -279,7 +281,6 @@ 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 @@ -290,6 +291,8 @@ 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 6265e6f9eb6..11ba7173c5a 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -155,7 +153,6 @@ 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 @@ -166,6 +163,8 @@ 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) @@ -202,7 +201,6 @@ 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 @@ -213,6 +211,8 @@ 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,7 +249,6 @@ 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 @@ -260,6 +259,8 @@ 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) @@ -304,7 +305,6 @@ 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,6 +315,8 @@ 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) @@ -347,7 +349,6 @@ 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 @@ -358,6 +359,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 04f754b7055..c676fa1cc28 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -85,7 +83,6 @@ 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 @@ -96,6 +93,8 @@ 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) @@ -142,7 +141,6 @@ 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 @@ -153,6 +151,8 @@ 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,7 +185,6 @@ 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 @@ -196,6 +195,8 @@ 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) @@ -242,7 +243,6 @@ 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,6 +253,8 @@ 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) @@ -285,7 +287,6 @@ 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 @@ -296,6 +297,8 @@ 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 c082f2ab325..05517577252 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -185,7 +184,6 @@ 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 @@ -196,6 +194,8 @@ 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,7 +228,6 @@ 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 @@ -239,6 +238,8 @@ 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) @@ -275,7 +276,6 @@ 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,6 +286,8 @@ 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) @@ -322,7 +324,6 @@ 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 @@ -333,6 +334,8 @@ 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) @@ -369,7 +372,6 @@ 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 @@ -380,6 +382,8 @@ 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 f456ddd90ea..b5b49f73f9e 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -143,7 +142,6 @@ 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 @@ -154,6 +152,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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) @@ -243,7 +244,6 @@ 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,6 +254,8 @@ 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) @@ -286,7 +288,6 @@ 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 @@ -297,6 +298,8 @@ 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) @@ -333,7 +336,6 @@ 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 @@ -344,6 +346,8 @@ 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 7e7386e10dd..d40e26e319c 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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 20e03b97f05..71192ed5a77 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -80,7 +78,6 @@ 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 @@ -91,6 +88,8 @@ 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) @@ -182,7 +181,6 @@ 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 @@ -193,6 +191,8 @@ 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 7b2d91b5d2c..bc3ec5c2a19 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -80,7 +78,6 @@ 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 @@ -91,6 +88,8 @@ 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) @@ -331,7 +330,6 @@ 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 @@ -342,6 +340,8 @@ 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 0612fdcc65a..6baddadf8b4 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -90,7 +88,6 @@ 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 @@ -101,6 +98,8 @@ 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) @@ -281,7 +280,6 @@ 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 @@ -292,6 +290,8 @@ 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,7 +324,6 @@ 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 @@ -335,6 +334,8 @@ 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) @@ -373,7 +374,6 @@ 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,6 +384,8 @@ 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) @@ -422,7 +424,6 @@ 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 @@ -433,6 +434,8 @@ 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) @@ -470,7 +473,6 @@ 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 @@ -481,6 +483,8 @@ 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) @@ -568,7 +572,6 @@ 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 @@ -579,6 +582,8 @@ 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) @@ -659,7 +664,6 @@ async def put_missing_discriminator( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -670,6 +674,8 @@ 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) @@ -835,7 +841,6 @@ 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 @@ -846,6 +851,8 @@ 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 96e9660f005..68257f54a30 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -104,7 +102,6 @@ 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 @@ -115,6 +112,8 @@ 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) @@ -200,7 +199,6 @@ 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 @@ -211,6 +209,8 @@ 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,7 +243,6 @@ 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 @@ -254,6 +253,8 @@ 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) @@ -339,7 +340,6 @@ 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,6 +350,8 @@ 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) @@ -382,7 +384,6 @@ 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 @@ -393,6 +394,8 @@ 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) @@ -478,7 +481,6 @@ 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 @@ -489,6 +491,8 @@ 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) @@ -521,7 +525,6 @@ 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 @@ -532,6 +535,8 @@ 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) @@ -620,7 +625,6 @@ 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 @@ -631,6 +635,8 @@ 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) @@ -663,7 +669,6 @@ 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 @@ -674,6 +679,8 @@ 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) @@ -759,7 +766,6 @@ 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 @@ -770,6 +776,8 @@ 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) @@ -802,7 +810,6 @@ 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 @@ -813,6 +820,8 @@ 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) @@ -898,7 +907,6 @@ 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 @@ -909,6 +917,8 @@ 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) @@ -941,7 +951,6 @@ 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 @@ -952,6 +961,8 @@ 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) @@ -1037,7 +1048,6 @@ 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 @@ -1048,6 +1058,8 @@ 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) @@ -1080,7 +1092,6 @@ 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 @@ -1091,6 +1102,8 @@ 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) @@ -1178,7 +1191,6 @@ 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 @@ -1189,6 +1201,8 @@ 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) @@ -1221,7 +1235,6 @@ 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 @@ -1232,6 +1245,8 @@ 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) @@ -1319,7 +1334,6 @@ 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 @@ -1330,6 +1344,8 @@ 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) @@ -1362,7 +1378,6 @@ 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 @@ -1373,6 +1388,8 @@ 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) @@ -1419,7 +1436,6 @@ 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 @@ -1430,6 +1446,8 @@ 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) @@ -1462,7 +1480,6 @@ 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 @@ -1473,6 +1490,8 @@ 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) @@ -1519,7 +1538,6 @@ 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 @@ -1530,6 +1548,8 @@ 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 2005b225849..82cc08fd447 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -79,7 +77,6 @@ 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 @@ -90,6 +87,8 @@ 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) @@ -136,7 +135,6 @@ 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 @@ -147,6 +145,8 @@ 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 fcc616dc728..2f5f9d11f10 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -158,7 +156,6 @@ 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 @@ -169,6 +166,8 @@ 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) @@ -215,7 +214,6 @@ 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 @@ -226,6 +224,8 @@ 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,7 +258,6 @@ 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 @@ -269,6 +268,8 @@ 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) @@ -315,7 +316,6 @@ 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,6 +326,8 @@ 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) @@ -358,7 +360,6 @@ 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 @@ -369,6 +370,8 @@ 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 42e8c69f3d7..b27efa9cecb 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -175,7 +173,6 @@ 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 @@ -186,6 +183,8 @@ 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) @@ -273,7 +272,6 @@ 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 @@ -284,6 +282,8 @@ 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,7 +316,6 @@ 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 @@ -327,6 +326,8 @@ 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) @@ -363,7 +364,6 @@ 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,6 +374,8 @@ 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) @@ -410,7 +412,6 @@ 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 @@ -421,6 +422,8 @@ 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) @@ -457,7 +460,6 @@ 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 @@ -468,6 +470,8 @@ 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 cb46112d994..85d629f25da 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -172,7 +170,6 @@ 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 @@ -183,6 +180,8 @@ 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) @@ -229,7 +228,6 @@ 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 @@ -240,6 +238,8 @@ 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,7 +272,6 @@ 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 @@ -283,6 +282,8 @@ 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) @@ -329,7 +330,6 @@ 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,6 +340,8 @@ 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) @@ -372,7 +374,6 @@ 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 @@ -383,6 +384,8 @@ 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) @@ -419,7 +422,6 @@ 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 @@ -430,6 +432,8 @@ 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 648dc9a8b59..77420e0ad98 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +94,6 @@ 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 @@ -107,6 +104,8 @@ 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 f2db021b368..2336b5861b6 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -114,7 +112,6 @@ 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 @@ -125,6 +122,8 @@ 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) @@ -216,7 +215,6 @@ 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 @@ -227,6 +225,8 @@ 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 c7a5caf3309..6506a0da506 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -114,7 +112,6 @@ 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 @@ -125,6 +122,8 @@ 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) @@ -365,7 +364,6 @@ 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 @@ -376,6 +374,8 @@ 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 1efe26ad282..7867c48a5b5 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -221,7 +219,6 @@ 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 @@ -232,6 +229,8 @@ 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) @@ -412,7 +411,6 @@ 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 @@ -423,6 +421,8 @@ 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,7 +455,6 @@ 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 @@ -466,6 +465,8 @@ 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) @@ -504,7 +505,6 @@ 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,6 +515,8 @@ 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) @@ -553,7 +555,6 @@ 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 @@ -564,6 +565,8 @@ 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) @@ -601,7 +604,6 @@ 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 @@ -612,6 +614,8 @@ 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) @@ -699,7 +703,6 @@ 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 @@ -710,6 +713,8 @@ 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) @@ -790,7 +795,6 @@ def put_missing_discriminator( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -801,6 +805,8 @@ 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) @@ -966,7 +972,6 @@ 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 @@ -977,6 +982,8 @@ 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 aed81de0250..822e714a098 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,13 +22,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -425,7 +423,6 @@ 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 @@ -436,6 +433,8 @@ 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) @@ -521,7 +520,6 @@ 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 @@ -532,6 +530,8 @@ 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,7 +564,6 @@ 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 @@ -575,6 +574,8 @@ 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) @@ -660,7 +661,6 @@ 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,6 +671,8 @@ 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) @@ -703,7 +705,6 @@ 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 @@ -714,6 +715,8 @@ 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) @@ -799,7 +802,6 @@ 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 @@ -810,6 +812,8 @@ 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) @@ -842,7 +846,6 @@ 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 @@ -853,6 +856,8 @@ 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) @@ -941,7 +946,6 @@ 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 @@ -952,6 +956,8 @@ 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) @@ -984,7 +990,6 @@ 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 @@ -995,6 +1000,8 @@ 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) @@ -1080,7 +1087,6 @@ 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 @@ -1091,6 +1097,8 @@ 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) @@ -1123,7 +1131,6 @@ 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 @@ -1134,6 +1141,8 @@ 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) @@ -1219,7 +1228,6 @@ 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 @@ -1230,6 +1238,8 @@ 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) @@ -1262,7 +1272,6 @@ 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 @@ -1273,6 +1282,8 @@ 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) @@ -1358,7 +1369,6 @@ 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 @@ -1369,6 +1379,8 @@ 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) @@ -1401,7 +1413,6 @@ 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 @@ -1412,6 +1423,8 @@ 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) @@ -1499,7 +1512,6 @@ 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 @@ -1510,6 +1522,8 @@ 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) @@ -1542,7 +1556,6 @@ 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 @@ -1553,6 +1566,8 @@ 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) @@ -1640,7 +1655,6 @@ 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 @@ -1651,6 +1665,8 @@ 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) @@ -1683,7 +1699,6 @@ 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 @@ -1694,6 +1709,8 @@ 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) @@ -1740,7 +1757,6 @@ 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 @@ -1751,6 +1767,8 @@ 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) @@ -1783,7 +1801,6 @@ 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 @@ -1794,6 +1811,8 @@ 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) @@ -1840,7 +1859,6 @@ 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 @@ -1851,6 +1869,8 @@ 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 8e8cd27c698..e47d0a87044 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -113,7 +111,6 @@ 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 @@ -124,6 +121,8 @@ 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) @@ -170,7 +169,6 @@ 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 @@ -181,6 +179,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 effe32974c4..e0d6dc379e5 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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) @@ -136,7 +135,6 @@ 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 @@ -147,6 +145,8 @@ 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,7 +183,6 @@ 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 @@ -194,6 +193,8 @@ 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) @@ -230,7 +231,6 @@ 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,6 +241,8 @@ 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) @@ -286,7 +288,6 @@ 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 @@ -297,6 +298,8 @@ 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) @@ -329,7 +332,6 @@ 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 @@ -340,6 +342,8 @@ 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) @@ -385,7 +389,6 @@ 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 @@ -396,6 +399,8 @@ 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) @@ -428,7 +433,6 @@ 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 @@ -439,6 +443,8 @@ 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 e99808def7e..57e62492a8d 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -201,7 +199,6 @@ 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 @@ -212,6 +209,8 @@ 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) @@ -248,7 +247,6 @@ 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 @@ -259,6 +257,8 @@ 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,7 +295,6 @@ 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 @@ -306,6 +305,8 @@ 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) @@ -342,7 +343,6 @@ 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,6 +353,8 @@ 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) @@ -398,7 +400,6 @@ 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 @@ -409,6 +410,8 @@ 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) @@ -441,7 +444,6 @@ 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 @@ -452,6 +454,8 @@ 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) @@ -497,7 +501,6 @@ 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 @@ -508,6 +511,8 @@ 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) @@ -540,7 +545,6 @@ 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 @@ -551,6 +555,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 35c96e90bcc..9b0458a06e1 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -103,7 +101,6 @@ 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 @@ -114,6 +111,8 @@ 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) @@ -150,7 +149,6 @@ 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 @@ -161,6 +159,8 @@ 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,7 +197,6 @@ 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 @@ -208,6 +207,8 @@ 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) @@ -244,7 +245,6 @@ 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,6 +255,8 @@ 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) @@ -300,7 +302,6 @@ 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 @@ -311,6 +312,8 @@ 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) @@ -355,7 +358,6 @@ 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 @@ -366,6 +368,8 @@ 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) @@ -398,7 +402,6 @@ 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 @@ -409,6 +412,8 @@ 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) @@ -445,7 +450,6 @@ 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 @@ -456,6 +460,8 @@ 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) @@ -495,7 +501,6 @@ 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 @@ -506,6 +511,8 @@ 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) @@ -551,7 +558,6 @@ 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 @@ -562,6 +568,8 @@ 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) @@ -596,7 +604,6 @@ 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 @@ -607,6 +614,8 @@ 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) @@ -645,7 +654,6 @@ 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 @@ -656,6 +664,8 @@ 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) @@ -701,7 +711,6 @@ 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 @@ -712,6 +721,8 @@ 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) @@ -746,7 +757,6 @@ 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 @@ -757,6 +767,8 @@ 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) @@ -795,7 +807,6 @@ 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 @@ -806,6 +817,8 @@ 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) @@ -851,7 +864,6 @@ 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 @@ -862,6 +874,8 @@ 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) @@ -894,7 +908,6 @@ 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 @@ -905,6 +918,8 @@ 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) @@ -950,7 +965,6 @@ 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 @@ -961,6 +975,8 @@ 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) @@ -993,7 +1009,6 @@ 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 @@ -1004,6 +1019,8 @@ 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) @@ -1049,7 +1066,6 @@ 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 @@ -1060,6 +1076,8 @@ 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) @@ -1092,7 +1110,6 @@ 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 @@ -1103,6 +1120,8 @@ 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) @@ -1139,7 +1158,6 @@ 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 @@ -1150,6 +1168,8 @@ 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 9bf539d2da6..57a7e7f3aeb 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -436,7 +434,6 @@ 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 @@ -447,6 +444,8 @@ 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) @@ -483,7 +482,6 @@ 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 @@ -494,6 +492,8 @@ 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,7 +530,6 @@ 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 @@ -541,6 +540,8 @@ 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) @@ -577,7 +578,6 @@ 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,6 +588,8 @@ 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) @@ -633,7 +635,6 @@ 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 @@ -644,6 +645,8 @@ 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) @@ -688,7 +691,6 @@ 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 @@ -699,6 +701,8 @@ 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) @@ -731,7 +735,6 @@ 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 @@ -742,6 +745,8 @@ 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) @@ -778,7 +783,6 @@ 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 @@ -789,6 +793,8 @@ 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) @@ -828,7 +834,6 @@ 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 @@ -839,6 +844,8 @@ 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) @@ -884,7 +891,6 @@ 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 @@ -895,6 +901,8 @@ 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) @@ -929,7 +937,6 @@ 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 @@ -940,6 +947,8 @@ 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) @@ -978,7 +987,6 @@ 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 @@ -989,6 +997,8 @@ 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) @@ -1034,7 +1044,6 @@ 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 @@ -1045,6 +1054,8 @@ 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) @@ -1079,7 +1090,6 @@ 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 @@ -1090,6 +1100,8 @@ 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) @@ -1128,7 +1140,6 @@ 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 @@ -1139,6 +1150,8 @@ 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) @@ -1184,7 +1197,6 @@ 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 @@ -1195,6 +1207,8 @@ 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) @@ -1227,7 +1241,6 @@ 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 @@ -1238,6 +1251,8 @@ 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) @@ -1283,7 +1298,6 @@ 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 @@ -1294,6 +1308,8 @@ 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) @@ -1326,7 +1342,6 @@ 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 @@ -1337,6 +1352,8 @@ 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) @@ -1382,7 +1399,6 @@ 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 @@ -1393,6 +1409,8 @@ 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) @@ -1425,7 +1443,6 @@ 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 @@ -1436,6 +1453,8 @@ 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) @@ -1472,7 +1491,6 @@ 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 @@ -1483,6 +1501,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 b18050032ff..f5df9992088 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -90,7 +88,6 @@ 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 @@ -101,6 +98,8 @@ 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) @@ -137,7 +136,6 @@ 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 @@ -148,6 +146,8 @@ 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,7 +184,6 @@ 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 @@ -195,6 +194,8 @@ 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) @@ -231,7 +232,6 @@ 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,6 +242,8 @@ 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) @@ -287,7 +289,6 @@ 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 @@ -298,6 +299,8 @@ 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) @@ -330,7 +333,6 @@ 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 @@ -341,6 +343,8 @@ 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) @@ -377,7 +381,6 @@ 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 @@ -388,6 +391,8 @@ 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) @@ -433,7 +438,6 @@ 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 @@ -444,6 +448,8 @@ 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) @@ -476,7 +482,6 @@ 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 @@ -487,6 +492,8 @@ 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 cad7162b770..9c8fa352edf 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -215,7 +213,6 @@ 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 @@ -226,6 +223,8 @@ 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) @@ -262,7 +261,6 @@ 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 @@ -273,6 +271,8 @@ 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,7 +309,6 @@ 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 @@ -320,6 +319,8 @@ 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) @@ -356,7 +357,6 @@ 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,6 +367,8 @@ 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) @@ -412,7 +414,6 @@ 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 @@ -423,6 +424,8 @@ 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) @@ -455,7 +458,6 @@ 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 @@ -466,6 +468,8 @@ 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) @@ -502,7 +506,6 @@ 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 @@ -513,6 +516,8 @@ 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) @@ -558,7 +563,6 @@ 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 @@ -569,6 +573,8 @@ 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) @@ -601,7 +607,6 @@ 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 @@ -612,6 +617,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 bffd52227b3..5d6b4260523 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -147,7 +145,6 @@ 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 @@ -158,6 +155,8 @@ 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) @@ -194,7 +193,6 @@ 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 @@ -205,6 +203,8 @@ 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,7 +289,6 @@ 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 @@ -300,6 +299,8 @@ 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) @@ -332,7 +333,6 @@ 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,6 +343,8 @@ 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) @@ -379,7 +381,6 @@ 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 @@ -390,6 +391,8 @@ 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) @@ -426,7 +429,6 @@ 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 @@ -437,6 +439,8 @@ 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) @@ -473,7 +477,6 @@ 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 @@ -484,6 +487,8 @@ 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) @@ -520,7 +525,6 @@ 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 @@ -531,6 +535,8 @@ 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) @@ -615,7 +621,6 @@ 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 @@ -626,6 +631,8 @@ 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) @@ -658,7 +665,6 @@ 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 @@ -669,6 +675,8 @@ 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) @@ -705,7 +713,6 @@ 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 @@ -716,6 +723,8 @@ 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) @@ -752,7 +761,6 @@ 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 @@ -763,6 +771,8 @@ 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) @@ -847,7 +857,6 @@ 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 @@ -858,6 +867,8 @@ 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) @@ -890,7 +901,6 @@ 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 @@ -901,6 +911,8 @@ 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) @@ -937,7 +949,6 @@ 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 @@ -948,6 +959,8 @@ 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) @@ -984,7 +997,6 @@ 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 @@ -995,6 +1007,8 @@ 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) @@ -1079,7 +1093,6 @@ 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 @@ -1090,6 +1103,8 @@ 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) @@ -1122,7 +1137,6 @@ 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 @@ -1133,6 +1147,8 @@ 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) @@ -1169,7 +1185,6 @@ 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 @@ -1180,6 +1195,8 @@ 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) @@ -1216,7 +1233,6 @@ 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 @@ -1227,6 +1243,8 @@ 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) @@ -1311,7 +1329,6 @@ 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 @@ -1322,6 +1339,8 @@ 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) @@ -1354,7 +1373,6 @@ 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 @@ -1365,6 +1383,8 @@ 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) @@ -1401,7 +1421,6 @@ 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 @@ -1412,6 +1431,8 @@ 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) @@ -1448,7 +1469,6 @@ 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 @@ -1459,6 +1479,8 @@ 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) @@ -1543,7 +1565,6 @@ 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 @@ -1554,6 +1575,8 @@ 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) @@ -1586,7 +1609,6 @@ 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 @@ -1597,6 +1619,8 @@ 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) @@ -1633,7 +1657,6 @@ 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 @@ -1644,6 +1667,8 @@ 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) @@ -1680,7 +1705,6 @@ 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 @@ -1691,6 +1715,8 @@ 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) @@ -1775,7 +1801,6 @@ 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 @@ -1786,6 +1811,8 @@ 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) @@ -1818,7 +1845,6 @@ 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 @@ -1829,6 +1855,8 @@ 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) @@ -1865,7 +1893,6 @@ 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 @@ -1876,6 +1903,8 @@ 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) @@ -1912,7 +1941,6 @@ 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 @@ -1923,6 +1951,8 @@ 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) @@ -2007,7 +2037,6 @@ 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 @@ -2018,6 +2047,8 @@ 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) @@ -2050,7 +2081,6 @@ 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 @@ -2061,6 +2091,8 @@ 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) @@ -2097,7 +2129,6 @@ 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 @@ -2108,6 +2139,8 @@ 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) @@ -2145,7 +2178,6 @@ 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 @@ -2156,6 +2188,8 @@ 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) @@ -2243,7 +2277,6 @@ 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 @@ -2254,6 +2287,8 @@ 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) @@ -2286,7 +2321,6 @@ 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 @@ -2297,6 +2331,8 @@ 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) @@ -2333,7 +2369,6 @@ 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 @@ -2344,6 +2379,8 @@ 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) @@ -2381,7 +2418,6 @@ 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 @@ -2392,6 +2428,8 @@ 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) @@ -2479,7 +2517,6 @@ 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 @@ -2490,6 +2527,8 @@ 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) @@ -2522,7 +2561,6 @@ 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 @@ -2533,6 +2571,8 @@ 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) @@ -2617,7 +2657,6 @@ 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 @@ -2628,6 +2667,8 @@ 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) @@ -2661,7 +2702,6 @@ 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 @@ -2672,6 +2712,8 @@ 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) @@ -2759,7 +2801,6 @@ 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 @@ -2770,6 +2811,8 @@ 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) @@ -2803,7 +2846,6 @@ 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 @@ -2814,6 +2856,8 @@ 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) @@ -2851,7 +2895,6 @@ 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 @@ -2862,6 +2905,8 @@ 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) @@ -2898,7 +2943,6 @@ 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 @@ -2909,6 +2953,8 @@ 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) @@ -2945,7 +2991,6 @@ 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 @@ -2956,6 +3001,8 @@ 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) @@ -2993,7 +3040,6 @@ 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 @@ -3004,6 +3050,8 @@ 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) @@ -3041,7 +3089,6 @@ 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 @@ -3052,6 +3099,8 @@ 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) @@ -3089,7 +3138,6 @@ 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 @@ -3100,6 +3148,8 @@ 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) @@ -3187,7 +3237,6 @@ 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 @@ -3198,6 +3247,8 @@ 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) @@ -3230,7 +3281,6 @@ 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 @@ -3241,6 +3291,8 @@ 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) @@ -3277,7 +3329,6 @@ 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 @@ -3288,6 +3339,8 @@ 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) @@ -3324,7 +3377,6 @@ 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 @@ -3335,6 +3387,8 @@ 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) @@ -3371,7 +3425,6 @@ 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 @@ -3382,6 +3435,8 @@ 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) @@ -3419,7 +3474,6 @@ 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 @@ -3430,6 +3484,8 @@ 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) @@ -3517,7 +3573,6 @@ 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 @@ -3528,6 +3583,8 @@ 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) @@ -3560,7 +3617,6 @@ 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 @@ -3571,6 +3627,8 @@ 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) @@ -3607,7 +3665,6 @@ 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 @@ -3618,6 +3675,8 @@ 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) @@ -3655,7 +3714,6 @@ 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 @@ -3666,6 +3724,8 @@ 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) @@ -3703,7 +3763,6 @@ 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 @@ -3714,6 +3773,8 @@ 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) @@ -3752,7 +3813,6 @@ 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 @@ -3763,6 +3823,8 @@ 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) @@ -3853,7 +3915,6 @@ 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 @@ -3864,6 +3925,8 @@ 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 6279400fe82..9fc0ae1098a 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,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -1039,7 +1037,6 @@ 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 @@ -1050,6 +1047,8 @@ 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) @@ -1086,7 +1085,6 @@ 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 @@ -1097,6 +1095,8 @@ 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,7 +1181,6 @@ 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 @@ -1192,6 +1191,8 @@ 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) @@ -1224,7 +1225,6 @@ 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,6 +1235,8 @@ 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) @@ -1271,7 +1273,6 @@ 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 @@ -1282,6 +1283,8 @@ 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) @@ -1318,7 +1321,6 @@ 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 @@ -1329,6 +1331,8 @@ 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) @@ -1365,7 +1369,6 @@ 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 @@ -1376,6 +1379,8 @@ 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) @@ -1412,7 +1417,6 @@ 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 @@ -1423,6 +1427,8 @@ 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) @@ -1507,7 +1513,6 @@ 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 @@ -1518,6 +1523,8 @@ 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) @@ -1550,7 +1557,6 @@ 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 @@ -1561,6 +1567,8 @@ 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) @@ -1597,7 +1605,6 @@ 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 @@ -1608,6 +1615,8 @@ 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) @@ -1644,7 +1653,6 @@ 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 @@ -1655,6 +1663,8 @@ 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) @@ -1739,7 +1749,6 @@ 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 @@ -1750,6 +1759,8 @@ 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) @@ -1782,7 +1793,6 @@ 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 @@ -1793,6 +1803,8 @@ 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) @@ -1829,7 +1841,6 @@ 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 @@ -1840,6 +1851,8 @@ 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) @@ -1876,7 +1889,6 @@ 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 @@ -1887,6 +1899,8 @@ 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) @@ -1971,7 +1985,6 @@ 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 @@ -1982,6 +1995,8 @@ 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) @@ -2014,7 +2029,6 @@ 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 @@ -2025,6 +2039,8 @@ 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) @@ -2061,7 +2077,6 @@ 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 @@ -2072,6 +2087,8 @@ 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) @@ -2108,7 +2125,6 @@ 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 @@ -2119,6 +2135,8 @@ 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) @@ -2203,7 +2221,6 @@ 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 @@ -2214,6 +2231,8 @@ 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) @@ -2246,7 +2265,6 @@ 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 @@ -2257,6 +2275,8 @@ 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) @@ -2293,7 +2313,6 @@ 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 @@ -2304,6 +2323,8 @@ 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) @@ -2340,7 +2361,6 @@ 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 @@ -2351,6 +2371,8 @@ 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) @@ -2435,7 +2457,6 @@ 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 @@ -2446,6 +2467,8 @@ 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) @@ -2478,7 +2501,6 @@ 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 @@ -2489,6 +2511,8 @@ 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) @@ -2525,7 +2549,6 @@ 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 @@ -2536,6 +2559,8 @@ 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) @@ -2572,7 +2597,6 @@ 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 @@ -2583,6 +2607,8 @@ 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) @@ -2667,7 +2693,6 @@ 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 @@ -2678,6 +2703,8 @@ 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) @@ -2710,7 +2737,6 @@ 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 @@ -2721,6 +2747,8 @@ 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) @@ -2757,7 +2785,6 @@ 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 @@ -2768,6 +2795,8 @@ 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) @@ -2804,7 +2833,6 @@ 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 @@ -2815,6 +2843,8 @@ 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) @@ -2899,7 +2929,6 @@ 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 @@ -2910,6 +2939,8 @@ 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) @@ -2942,7 +2973,6 @@ 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 @@ -2953,6 +2983,8 @@ 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) @@ -2989,7 +3021,6 @@ 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 @@ -3000,6 +3031,8 @@ 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) @@ -3037,7 +3070,6 @@ 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 @@ -3048,6 +3080,8 @@ 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) @@ -3135,7 +3169,6 @@ 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 @@ -3146,6 +3179,8 @@ 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) @@ -3178,7 +3213,6 @@ 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 @@ -3189,6 +3223,8 @@ 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) @@ -3225,7 +3261,6 @@ 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 @@ -3236,6 +3271,8 @@ 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) @@ -3273,7 +3310,6 @@ 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 @@ -3284,6 +3320,8 @@ 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) @@ -3371,7 +3409,6 @@ 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 @@ -3382,6 +3419,8 @@ 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) @@ -3414,7 +3453,6 @@ 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 @@ -3425,6 +3463,8 @@ 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) @@ -3509,7 +3549,6 @@ 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 @@ -3520,6 +3559,8 @@ 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) @@ -3553,7 +3594,6 @@ 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 @@ -3564,6 +3604,8 @@ 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) @@ -3651,7 +3693,6 @@ 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 @@ -3662,6 +3703,8 @@ 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) @@ -3695,7 +3738,6 @@ 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 @@ -3706,6 +3748,8 @@ 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) @@ -3743,7 +3787,6 @@ 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 @@ -3754,6 +3797,8 @@ 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) @@ -3790,7 +3835,6 @@ 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 @@ -3801,6 +3845,8 @@ 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) @@ -3837,7 +3883,6 @@ 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 @@ -3848,6 +3893,8 @@ 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) @@ -3885,7 +3932,6 @@ 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 @@ -3896,6 +3942,8 @@ 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) @@ -3933,7 +3981,6 @@ 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 @@ -3944,6 +3991,8 @@ 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) @@ -3981,7 +4030,6 @@ 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 @@ -3992,6 +4040,8 @@ 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) @@ -4079,7 +4129,6 @@ 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 @@ -4090,6 +4139,8 @@ 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) @@ -4122,7 +4173,6 @@ 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 @@ -4133,6 +4183,8 @@ 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) @@ -4169,7 +4221,6 @@ 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 @@ -4180,6 +4231,8 @@ 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) @@ -4216,7 +4269,6 @@ 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 @@ -4227,6 +4279,8 @@ 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) @@ -4263,7 +4317,6 @@ 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 @@ -4274,6 +4327,8 @@ 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) @@ -4311,7 +4366,6 @@ 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 @@ -4322,6 +4376,8 @@ 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) @@ -4409,7 +4465,6 @@ 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 @@ -4420,6 +4475,8 @@ 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) @@ -4452,7 +4509,6 @@ 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 @@ -4463,6 +4519,8 @@ 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) @@ -4499,7 +4557,6 @@ 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 @@ -4510,6 +4567,8 @@ 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) @@ -4547,7 +4606,6 @@ 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 @@ -4558,6 +4616,8 @@ 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) @@ -4595,7 +4655,6 @@ 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 @@ -4606,6 +4665,8 @@ 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) @@ -4644,7 +4705,6 @@ 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 @@ -4655,6 +4715,8 @@ 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) @@ -4745,7 +4807,6 @@ 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 @@ -4756,6 +4817,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 5a6fdc953fd..62d89fee002 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -85,7 +83,6 @@ 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 @@ -96,6 +93,8 @@ 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) @@ -141,7 +140,6 @@ 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 @@ -152,6 +150,8 @@ 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,7 +184,6 @@ 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 @@ -195,6 +194,8 @@ 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) @@ -231,7 +232,6 @@ 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,6 +242,8 @@ 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 97fec1d0745..5888447d655 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +140,6 @@ 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 @@ -153,6 +150,8 @@ 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) @@ -198,7 +197,6 @@ 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 @@ -209,6 +207,8 @@ 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,7 +241,6 @@ 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 @@ -252,6 +251,8 @@ 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) @@ -288,7 +289,6 @@ 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,6 +299,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 c270ce7e214..85b78369763 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -82,7 +80,6 @@ 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 @@ -93,6 +90,8 @@ 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) @@ -129,7 +128,6 @@ 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 @@ -140,6 +138,8 @@ 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,7 +176,6 @@ 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 @@ -187,6 +186,8 @@ 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 4bd2c99d2be..0dd22995979 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -124,7 +122,6 @@ 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 @@ -135,6 +132,8 @@ 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) @@ -171,7 +170,6 @@ 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 @@ -182,6 +180,8 @@ 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,7 +218,6 @@ 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 @@ -229,6 +228,8 @@ 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 0dafe0e287f..0af9b28f660 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,13 +4,3 @@ # 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 89347b894c9..68c6ce7ba01 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -97,7 +95,6 @@ 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 @@ -108,6 +105,8 @@ 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) @@ -151,7 +150,6 @@ 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 @@ -162,6 +160,8 @@ 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,7 +208,6 @@ 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 @@ -219,6 +218,8 @@ 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 78b62c77516..3fac400ff64 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -143,7 +141,6 @@ 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 @@ -154,6 +151,8 @@ 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) @@ -197,7 +196,6 @@ 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 @@ -208,6 +206,8 @@ 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,7 +254,6 @@ 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 @@ -265,6 +264,8 @@ 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 0dafe0e287f..0af9b28f660 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,13 +4,3 @@ # 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 992d73a395e..11e3cf50f1a 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -122,7 +120,6 @@ 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 @@ -133,6 +130,8 @@ 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) @@ -185,7 +184,6 @@ 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 @@ -196,6 +194,8 @@ 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 87ab98c293b..049ca2b8a70 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +145,6 @@ 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 @@ -158,6 +155,8 @@ 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) @@ -210,7 +209,6 @@ 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 @@ -221,6 +219,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 37829f7ab55..52536259aa1 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -95,7 +93,6 @@ 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 @@ -106,6 +103,8 @@ 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) @@ -142,7 +141,6 @@ 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 @@ -153,6 +151,8 @@ 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,7 +189,6 @@ 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 @@ -200,6 +199,8 @@ 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) @@ -236,7 +237,6 @@ 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,6 +247,8 @@ 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) @@ -283,7 +285,6 @@ 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 @@ -294,6 +295,8 @@ 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) @@ -330,7 +333,6 @@ 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 @@ -341,6 +343,8 @@ 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) @@ -384,7 +388,6 @@ 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 @@ -395,6 +398,8 @@ 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) @@ -434,7 +439,6 @@ 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 @@ -445,6 +449,8 @@ 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) @@ -484,7 +490,6 @@ 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 @@ -495,6 +500,8 @@ 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) @@ -534,7 +541,6 @@ 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 @@ -545,6 +551,8 @@ 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) @@ -577,7 +585,6 @@ 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 @@ -588,6 +595,8 @@ 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) @@ -633,7 +642,6 @@ 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 @@ -644,6 +652,8 @@ 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) @@ -676,7 +686,6 @@ 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 @@ -687,6 +696,8 @@ 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) @@ -723,7 +734,6 @@ 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 @@ -734,6 +744,8 @@ 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 ad9efa9e143..32241086848 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -294,7 +292,6 @@ 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 @@ -305,6 +302,8 @@ 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) @@ -341,7 +340,6 @@ 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 @@ -352,6 +350,8 @@ 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,7 +388,6 @@ 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 @@ -399,6 +398,8 @@ 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) @@ -435,7 +436,6 @@ 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,6 +446,8 @@ 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) @@ -482,7 +484,6 @@ 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 @@ -493,6 +494,8 @@ 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) @@ -529,7 +532,6 @@ 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 @@ -540,6 +542,8 @@ 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) @@ -583,7 +587,6 @@ 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 @@ -594,6 +597,8 @@ 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) @@ -633,7 +638,6 @@ 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 @@ -644,6 +648,8 @@ 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) @@ -683,7 +689,6 @@ 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 @@ -694,6 +699,8 @@ 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) @@ -733,7 +740,6 @@ 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 @@ -744,6 +750,8 @@ 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) @@ -776,7 +784,6 @@ 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 @@ -787,6 +794,8 @@ 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) @@ -832,7 +841,6 @@ 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 @@ -843,6 +851,8 @@ 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) @@ -875,7 +885,6 @@ 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 @@ -886,6 +895,8 @@ 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) @@ -922,7 +933,6 @@ 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 @@ -933,6 +943,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 1c9d563dc9c..0e269688dbe 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -104,7 +102,6 @@ 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 @@ -115,6 +112,8 @@ 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) @@ -151,7 +150,6 @@ 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 @@ -162,6 +160,8 @@ 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,7 +198,6 @@ 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 @@ -209,6 +208,8 @@ 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) @@ -245,7 +246,6 @@ 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,6 +256,8 @@ 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) @@ -301,7 +303,6 @@ 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 @@ -312,6 +313,8 @@ 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) @@ -344,7 +347,6 @@ 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 @@ -355,6 +357,8 @@ 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) @@ -400,7 +404,6 @@ 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 @@ -411,6 +414,8 @@ 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) @@ -443,7 +448,6 @@ 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 @@ -454,6 +458,8 @@ 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) @@ -498,7 +504,6 @@ 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 @@ -509,6 +514,8 @@ 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) @@ -541,7 +548,6 @@ 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 @@ -552,6 +558,8 @@ 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) @@ -596,7 +604,6 @@ 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 @@ -607,6 +614,8 @@ 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) @@ -639,7 +648,6 @@ 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 @@ -650,6 +658,8 @@ 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) @@ -695,7 +705,6 @@ 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 @@ -706,6 +715,8 @@ 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) @@ -738,7 +749,6 @@ 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 @@ -749,6 +759,8 @@ 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) @@ -793,7 +805,6 @@ 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 @@ -804,6 +815,8 @@ 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) @@ -836,7 +849,6 @@ 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 @@ -847,6 +859,8 @@ 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) @@ -891,7 +905,6 @@ 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 @@ -902,6 +915,8 @@ 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) @@ -934,7 +949,6 @@ 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 @@ -945,6 +959,8 @@ 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) @@ -990,7 +1006,6 @@ 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 @@ -1001,6 +1016,8 @@ 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) @@ -1033,7 +1050,6 @@ 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 @@ -1044,6 +1060,8 @@ 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) @@ -1089,7 +1107,6 @@ 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 @@ -1100,6 +1117,8 @@ 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) @@ -1132,7 +1151,6 @@ 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 @@ -1143,6 +1161,8 @@ 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) @@ -1188,7 +1208,6 @@ 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 @@ -1199,6 +1218,8 @@ 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) @@ -1231,7 +1252,6 @@ 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 @@ -1242,6 +1262,8 @@ 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 439a2b0755b..a31c509c8ce 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -452,7 +450,6 @@ 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 @@ -463,6 +460,8 @@ 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) @@ -499,7 +498,6 @@ 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 @@ -510,6 +508,8 @@ 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,7 +546,6 @@ 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 @@ -557,6 +556,8 @@ 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) @@ -593,7 +594,6 @@ 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,6 +604,8 @@ 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) @@ -649,7 +651,6 @@ 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 @@ -660,6 +661,8 @@ 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) @@ -692,7 +695,6 @@ 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 @@ -703,6 +705,8 @@ 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) @@ -748,7 +752,6 @@ 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 @@ -759,6 +762,8 @@ 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) @@ -791,7 +796,6 @@ 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 @@ -802,6 +806,8 @@ 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) @@ -844,7 +850,6 @@ 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 @@ -855,6 +860,8 @@ 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) @@ -887,7 +894,6 @@ 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 @@ -898,6 +904,8 @@ 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) @@ -940,7 +948,6 @@ 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 @@ -951,6 +958,8 @@ 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) @@ -983,7 +992,6 @@ 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 @@ -994,6 +1002,8 @@ 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) @@ -1039,7 +1049,6 @@ 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 @@ -1050,6 +1059,8 @@ 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) @@ -1082,7 +1093,6 @@ 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 @@ -1093,6 +1103,8 @@ 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) @@ -1135,7 +1147,6 @@ 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 @@ -1146,6 +1157,8 @@ 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) @@ -1178,7 +1191,6 @@ 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 @@ -1189,6 +1201,8 @@ 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) @@ -1231,7 +1245,6 @@ 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 @@ -1242,6 +1255,8 @@ 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) @@ -1274,7 +1289,6 @@ 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 @@ -1285,6 +1299,8 @@ 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) @@ -1330,7 +1346,6 @@ 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 @@ -1341,6 +1356,8 @@ 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) @@ -1373,7 +1390,6 @@ 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 @@ -1384,6 +1400,8 @@ 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) @@ -1429,7 +1447,6 @@ 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 @@ -1440,6 +1457,8 @@ 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) @@ -1472,7 +1491,6 @@ 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 @@ -1483,6 +1501,8 @@ 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) @@ -1528,7 +1548,6 @@ 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 @@ -1539,6 +1558,8 @@ 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) @@ -1571,7 +1592,6 @@ 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 @@ -1582,6 +1602,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 4d4a8e2758a..d339184a3dc 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -86,7 +84,6 @@ 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 @@ -97,6 +94,8 @@ 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) @@ -143,7 +142,6 @@ 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 @@ -154,6 +152,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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) @@ -243,7 +244,6 @@ 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,6 +254,8 @@ 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) @@ -286,7 +288,6 @@ 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 @@ -297,6 +298,8 @@ 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) @@ -344,7 +347,6 @@ 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 @@ -355,6 +357,8 @@ 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 ba7fa3a2fa3..a052691d45c 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -93,7 +91,6 @@ 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 @@ -104,6 +101,8 @@ 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) @@ -152,7 +151,6 @@ 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 @@ -163,6 +161,8 @@ 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,7 +195,6 @@ 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 @@ -206,6 +205,8 @@ 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) @@ -248,7 +249,6 @@ 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,6 +259,8 @@ 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) @@ -291,7 +293,6 @@ 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 @@ -302,6 +303,8 @@ 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) @@ -349,7 +352,6 @@ 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 @@ -360,6 +362,8 @@ 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) @@ -394,7 +398,6 @@ 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 @@ -405,6 +408,8 @@ 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) @@ -451,7 +456,6 @@ 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 @@ -462,6 +466,8 @@ 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) @@ -494,7 +500,6 @@ 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 @@ -505,6 +510,8 @@ 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) @@ -541,7 +548,6 @@ 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 @@ -552,6 +558,8 @@ 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) @@ -588,7 +596,6 @@ 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 @@ -599,6 +606,8 @@ 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) @@ -644,7 +653,6 @@ 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 @@ -655,6 +663,8 @@ 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) @@ -687,7 +697,6 @@ 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 @@ -698,6 +707,8 @@ 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 64d22f7a987..5739eae424b 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -176,7 +174,6 @@ 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 @@ -187,6 +184,8 @@ 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) @@ -233,7 +232,6 @@ 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 @@ -244,6 +242,8 @@ 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,7 +276,6 @@ 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 @@ -287,6 +286,8 @@ 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) @@ -333,7 +334,6 @@ 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,6 +344,8 @@ 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) @@ -376,7 +378,6 @@ 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 @@ -387,6 +388,8 @@ 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) @@ -434,7 +437,6 @@ 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 @@ -445,6 +447,8 @@ 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 1ca23dcb839..f9117e22e4d 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -289,7 +287,6 @@ 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 @@ -300,6 +297,8 @@ 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) @@ -348,7 +347,6 @@ 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 @@ -359,6 +357,8 @@ 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,7 +391,6 @@ 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 @@ -402,6 +401,8 @@ 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) @@ -444,7 +445,6 @@ 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,6 +455,8 @@ 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) @@ -487,7 +489,6 @@ 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 @@ -498,6 +499,8 @@ 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) @@ -545,7 +548,6 @@ 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 @@ -556,6 +558,8 @@ 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) @@ -590,7 +594,6 @@ 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 @@ -601,6 +604,8 @@ 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) @@ -647,7 +652,6 @@ 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 @@ -658,6 +662,8 @@ 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) @@ -690,7 +696,6 @@ 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 @@ -701,6 +706,8 @@ 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) @@ -737,7 +744,6 @@ 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 @@ -748,6 +754,8 @@ 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) @@ -784,7 +792,6 @@ 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 @@ -795,6 +802,8 @@ 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) @@ -840,7 +849,6 @@ 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 @@ -851,6 +859,8 @@ 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) @@ -883,7 +893,6 @@ 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 @@ -894,6 +903,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 447e5daedd2..4352f07df19 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -80,7 +78,6 @@ 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 @@ -91,6 +88,8 @@ 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) @@ -134,7 +133,6 @@ 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 @@ -145,6 +143,8 @@ 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 2aa93fd9b29..898db499262 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -114,7 +112,6 @@ 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 @@ -125,6 +122,8 @@ 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) @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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 3b000a3b496..3f1c320adb9 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ClientWithEnumConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 391df2f9b34..031c576fdb5 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,8 +8,6 @@ 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 028edb8ca39..f57ad26a2b1 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -62,7 +60,6 @@ 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 @@ -73,6 +70,8 @@ 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 de8ca6d04f7..13860fb368d 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import ClientWithEnumMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -78,7 +77,6 @@ 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 @@ -89,6 +87,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 db3d8099d93..7981f1108ad 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -106,7 +104,6 @@ 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 @@ -117,6 +114,8 @@ 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) @@ -155,7 +154,6 @@ 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 @@ -166,6 +164,8 @@ 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,7 +204,6 @@ 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 @@ -215,6 +214,8 @@ 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) @@ -253,7 +254,6 @@ 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,6 +264,8 @@ 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) @@ -302,7 +304,6 @@ 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 @@ -313,6 +314,8 @@ 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) @@ -351,7 +354,6 @@ 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 @@ -362,6 +364,8 @@ 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) @@ -399,7 +403,6 @@ 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 @@ -410,6 +413,8 @@ 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) @@ -447,7 +452,6 @@ 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 @@ -458,6 +462,8 @@ 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) @@ -496,7 +502,6 @@ 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 @@ -507,6 +512,8 @@ 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) @@ -545,7 +552,6 @@ 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 @@ -556,6 +562,8 @@ 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) @@ -594,7 +602,6 @@ 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 @@ -605,6 +612,8 @@ 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) @@ -643,7 +652,6 @@ 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 @@ -654,6 +662,8 @@ 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) @@ -692,7 +702,6 @@ 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 @@ -703,6 +712,8 @@ 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) @@ -741,7 +752,6 @@ 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 @@ -752,6 +762,8 @@ 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) @@ -790,7 +802,6 @@ 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 @@ -801,6 +812,8 @@ 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) @@ -839,7 +852,6 @@ 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 @@ -850,6 +862,8 @@ 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) @@ -885,7 +899,6 @@ 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 @@ -896,6 +909,8 @@ 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 8e59a3e773a..278091de20e 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -349,7 +347,6 @@ 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 @@ -360,6 +357,8 @@ 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) @@ -398,7 +397,6 @@ 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 @@ -409,6 +407,8 @@ 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,7 +447,6 @@ 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 @@ -458,6 +457,8 @@ 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) @@ -496,7 +497,6 @@ 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,6 +507,8 @@ 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) @@ -545,7 +547,6 @@ 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 @@ -556,6 +557,8 @@ 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) @@ -594,7 +597,6 @@ 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 @@ -605,6 +607,8 @@ 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) @@ -642,7 +646,6 @@ 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 @@ -653,6 +656,8 @@ 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) @@ -690,7 +695,6 @@ 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 @@ -701,6 +705,8 @@ 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) @@ -739,7 +745,6 @@ 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 @@ -750,6 +755,8 @@ 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) @@ -788,7 +795,6 @@ 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 @@ -799,6 +805,8 @@ 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) @@ -837,7 +845,6 @@ 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 @@ -848,6 +855,8 @@ 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) @@ -886,7 +895,6 @@ 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 @@ -897,6 +905,8 @@ 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) @@ -935,7 +945,6 @@ 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 @@ -946,6 +955,8 @@ 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) @@ -984,7 +995,6 @@ 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 @@ -995,6 +1005,8 @@ 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) @@ -1033,7 +1045,6 @@ 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 @@ -1044,6 +1055,8 @@ 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) @@ -1082,7 +1095,6 @@ 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 @@ -1093,6 +1105,8 @@ 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) @@ -1128,7 +1142,6 @@ 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 @@ -1139,6 +1152,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 9bc8bf896e1..7fed59ce996 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -82,7 +80,6 @@ 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), @@ -97,6 +94,8 @@ 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 470325040a6..28f8d219ce4 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -98,7 +96,6 @@ 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), @@ -113,6 +110,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 21239a0c989..ccf8951d94d 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -91,7 +89,6 @@ 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), @@ -109,6 +106,8 @@ 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 846b2c27f14..5672fc7b3c8 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +120,6 @@ 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), @@ -140,6 +137,8 @@ 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 104755de7de..57b8012132b 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ErrorWithSecretsConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 a650431e341..004d69077c2 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,8 +8,6 @@ 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 d7d7dded9c4..6297f0367a6 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -65,7 +63,6 @@ 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 @@ -76,6 +73,8 @@ 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) @@ -112,7 +111,6 @@ 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 @@ -123,6 +121,8 @@ 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 8319fda66c5..087aa8cbc29 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import ErrorWithSecretsMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -93,7 +92,6 @@ 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 @@ -104,6 +102,8 @@ 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,7 +140,6 @@ 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 @@ -151,6 +150,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 fc4893d2244..abd980486e9 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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) @@ -178,7 +177,6 @@ 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 @@ -189,6 +187,8 @@ 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 b76d3d93158..cd41de2ac68 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +120,6 @@ 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 @@ -133,6 +130,8 @@ 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) @@ -217,7 +216,6 @@ 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 @@ -228,6 +226,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 0e05aea8dd6..9c4a3617bce 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,12 +19,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -115,7 +113,6 @@ 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 @@ -126,6 +123,8 @@ 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) @@ -158,7 +157,6 @@ 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 @@ -169,6 +167,8 @@ 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,7 +206,6 @@ 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 @@ -217,6 +216,8 @@ 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) @@ -249,7 +250,6 @@ 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,6 +260,8 @@ 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) @@ -305,7 +307,6 @@ 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 @@ -316,6 +317,8 @@ 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) @@ -354,7 +357,6 @@ 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 @@ -365,6 +367,8 @@ 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) @@ -410,7 +414,6 @@ 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 @@ -421,6 +424,8 @@ 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) @@ -459,7 +464,6 @@ 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 @@ -470,6 +474,8 @@ 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) @@ -515,7 +521,6 @@ 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 @@ -526,6 +531,8 @@ 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) @@ -564,7 +571,6 @@ 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 @@ -575,6 +581,8 @@ 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) @@ -620,7 +628,6 @@ 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 @@ -631,6 +638,8 @@ 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) @@ -669,7 +678,6 @@ 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 @@ -680,6 +688,8 @@ 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) @@ -725,7 +735,6 @@ 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 @@ -736,6 +745,8 @@ 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) @@ -774,7 +785,6 @@ 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 @@ -785,6 +795,8 @@ 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) @@ -831,7 +843,6 @@ 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 @@ -842,6 +853,8 @@ 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) @@ -880,7 +893,6 @@ 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 @@ -891,6 +903,8 @@ 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) @@ -935,7 +949,6 @@ 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 @@ -946,6 +959,8 @@ 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) @@ -983,7 +998,6 @@ 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 @@ -994,6 +1008,8 @@ 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) @@ -1039,7 +1055,6 @@ 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 @@ -1050,6 +1065,8 @@ 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) @@ -1087,7 +1104,6 @@ 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 @@ -1098,6 +1114,8 @@ 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) @@ -1143,7 +1161,6 @@ 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 @@ -1154,6 +1171,8 @@ 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) @@ -1192,7 +1211,6 @@ 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 @@ -1203,6 +1221,8 @@ 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) @@ -1246,7 +1266,6 @@ 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 @@ -1257,6 +1276,8 @@ 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) @@ -1294,7 +1315,6 @@ 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 @@ -1305,6 +1325,8 @@ 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) @@ -1348,7 +1370,6 @@ 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 @@ -1359,6 +1380,8 @@ 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) @@ -1396,7 +1419,6 @@ 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 @@ -1407,6 +1429,8 @@ 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) @@ -1453,7 +1477,6 @@ 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 @@ -1464,6 +1487,8 @@ 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) @@ -1502,7 +1527,6 @@ 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 @@ -1513,6 +1537,8 @@ 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) @@ -1549,7 +1575,6 @@ 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 @@ -1560,6 +1585,8 @@ 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 2b4adc3891b..c7eaec9f653 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,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -541,7 +539,6 @@ 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 @@ -552,6 +549,8 @@ 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) @@ -584,7 +583,6 @@ 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 @@ -595,6 +593,8 @@ 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,7 +632,6 @@ 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 @@ -643,6 +642,8 @@ 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) @@ -675,7 +676,6 @@ 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,6 +686,8 @@ 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) @@ -731,7 +733,6 @@ 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 @@ -742,6 +743,8 @@ 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) @@ -778,7 +781,6 @@ 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 @@ -789,6 +791,8 @@ 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) @@ -834,7 +838,6 @@ 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 @@ -845,6 +848,8 @@ 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) @@ -881,7 +886,6 @@ 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 @@ -892,6 +896,8 @@ 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) @@ -937,7 +943,6 @@ 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 @@ -948,6 +953,8 @@ 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) @@ -984,7 +991,6 @@ 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 @@ -995,6 +1001,8 @@ 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) @@ -1040,7 +1048,6 @@ 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 @@ -1051,6 +1058,8 @@ 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) @@ -1087,7 +1096,6 @@ 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 @@ -1098,6 +1106,8 @@ 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) @@ -1143,7 +1153,6 @@ 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 @@ -1154,6 +1163,8 @@ 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) @@ -1190,7 +1201,6 @@ 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 @@ -1201,6 +1211,8 @@ 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) @@ -1247,7 +1259,6 @@ 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 @@ -1258,6 +1269,8 @@ 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) @@ -1294,7 +1307,6 @@ 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 @@ -1305,6 +1317,8 @@ 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) @@ -1349,7 +1363,6 @@ 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 @@ -1360,6 +1373,8 @@ 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) @@ -1395,7 +1410,6 @@ 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 @@ -1406,6 +1420,8 @@ 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) @@ -1451,7 +1467,6 @@ 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 @@ -1462,6 +1477,8 @@ 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) @@ -1497,7 +1514,6 @@ 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 @@ -1508,6 +1524,8 @@ 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) @@ -1553,7 +1571,6 @@ 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 @@ -1564,6 +1581,8 @@ 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) @@ -1602,7 +1621,6 @@ 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 @@ -1613,6 +1631,8 @@ 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) @@ -1656,7 +1676,6 @@ 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 @@ -1667,6 +1686,8 @@ 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) @@ -1702,7 +1723,6 @@ 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 @@ -1713,6 +1733,8 @@ 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) @@ -1756,7 +1778,6 @@ 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 @@ -1767,6 +1788,8 @@ 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) @@ -1802,7 +1825,6 @@ 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 @@ -1813,6 +1835,8 @@ 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) @@ -1859,7 +1883,6 @@ 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 @@ -1870,6 +1893,8 @@ 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) @@ -1906,7 +1931,6 @@ 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 @@ -1917,6 +1941,8 @@ 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) @@ -1953,7 +1979,6 @@ 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 @@ -1964,6 +1989,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 47592529acf..d2e8805a4ea 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -106,7 +104,6 @@ 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 @@ -117,6 +114,8 @@ 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) @@ -149,7 +148,6 @@ 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 @@ -160,6 +158,8 @@ 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,7 +192,6 @@ 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 @@ -203,6 +202,8 @@ 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) @@ -248,7 +249,6 @@ 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,6 +259,8 @@ 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) @@ -304,7 +306,6 @@ 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 @@ -315,6 +316,8 @@ 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) @@ -360,7 +363,6 @@ 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 @@ -371,6 +373,8 @@ 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) @@ -416,7 +420,6 @@ 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 @@ -427,6 +430,8 @@ 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) @@ -459,7 +464,6 @@ 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 @@ -470,6 +474,8 @@ 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) @@ -502,7 +508,6 @@ 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 @@ -513,6 +518,8 @@ 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) @@ -545,7 +552,6 @@ 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 @@ -556,6 +562,8 @@ 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) @@ -588,7 +596,6 @@ 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 @@ -599,6 +606,8 @@ 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) @@ -644,7 +653,6 @@ 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 @@ -655,6 +663,8 @@ 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) @@ -700,7 +710,6 @@ 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 @@ -711,6 +720,8 @@ 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) @@ -756,7 +767,6 @@ 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 @@ -767,6 +777,8 @@ 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) @@ -812,7 +824,6 @@ 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 @@ -823,6 +834,8 @@ 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) @@ -868,7 +881,6 @@ 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 @@ -879,6 +891,8 @@ 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) @@ -911,7 +925,6 @@ 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 @@ -922,6 +935,8 @@ 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) @@ -954,7 +969,6 @@ 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 @@ -965,6 +979,8 @@ 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) @@ -997,7 +1013,6 @@ 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 @@ -1008,6 +1023,8 @@ 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) @@ -1040,7 +1057,6 @@ 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 @@ -1051,6 +1067,8 @@ 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) @@ -1096,7 +1114,6 @@ 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 @@ -1107,6 +1124,8 @@ 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) @@ -1152,7 +1171,6 @@ 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 @@ -1163,6 +1181,8 @@ 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) @@ -1208,7 +1228,6 @@ 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 @@ -1219,6 +1238,8 @@ 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) @@ -1251,7 +1272,6 @@ 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 @@ -1262,6 +1282,8 @@ 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) @@ -1307,7 +1329,6 @@ 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 @@ -1318,6 +1339,8 @@ 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) @@ -1350,7 +1373,6 @@ 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 @@ -1361,6 +1383,8 @@ 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 7477da622c9..2015360f1ed 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -82,7 +80,6 @@ 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 @@ -93,6 +90,8 @@ 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) @@ -129,7 +128,6 @@ 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 @@ -140,6 +138,8 @@ 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,7 +175,6 @@ 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 @@ -186,6 +185,8 @@ 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 db535692f02..e9cee30b9db 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -96,7 +94,6 @@ 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 @@ -107,6 +104,8 @@ 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) @@ -143,7 +142,6 @@ 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 @@ -154,6 +152,8 @@ 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,7 +195,6 @@ 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 @@ -206,6 +205,8 @@ 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) @@ -242,7 +243,6 @@ 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,6 +253,8 @@ 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) @@ -303,7 +305,6 @@ 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 @@ -314,6 +315,8 @@ 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) @@ -349,7 +352,6 @@ 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 @@ -360,6 +362,8 @@ 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) @@ -396,7 +400,6 @@ 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 @@ -407,6 +410,8 @@ 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) @@ -457,7 +462,6 @@ 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 @@ -468,6 +472,8 @@ 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) @@ -517,7 +523,6 @@ 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 @@ -528,6 +533,8 @@ 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) @@ -564,7 +571,6 @@ 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 @@ -575,6 +581,8 @@ 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) @@ -611,7 +619,6 @@ 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 @@ -622,6 +629,8 @@ 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) @@ -658,7 +667,6 @@ 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 @@ -669,6 +677,8 @@ 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) @@ -718,7 +728,6 @@ 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 @@ -729,6 +738,8 @@ 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) @@ -778,7 +789,6 @@ 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 @@ -789,6 +799,8 @@ 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) @@ -838,7 +850,6 @@ 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 @@ -849,6 +860,8 @@ 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) @@ -898,7 +911,6 @@ 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 @@ -909,6 +921,8 @@ 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 bf37d0efdbe..036aa3678a4 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -89,7 +87,6 @@ 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 @@ -100,6 +97,8 @@ 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) @@ -145,7 +144,6 @@ 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 @@ -156,6 +154,8 @@ 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,7 +201,6 @@ 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 @@ -212,6 +211,8 @@ 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) @@ -244,7 +245,6 @@ 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,6 +255,8 @@ 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) @@ -287,7 +289,6 @@ 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 @@ -298,6 +299,8 @@ 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) @@ -347,7 +350,6 @@ 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 @@ -358,6 +360,8 @@ 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) @@ -403,7 +407,6 @@ 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 @@ -414,6 +417,8 @@ 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) @@ -459,7 +464,6 @@ 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 @@ -470,6 +474,8 @@ 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) @@ -515,7 +521,6 @@ 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 @@ -526,6 +531,8 @@ 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 09e7fd5758d..acdc6a7a9d6 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -84,7 +82,6 @@ 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 @@ -95,6 +92,8 @@ 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) @@ -127,7 +126,6 @@ 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 @@ -138,6 +136,8 @@ 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,7 +183,6 @@ 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 @@ -194,6 +193,8 @@ 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) @@ -239,7 +240,6 @@ 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,6 +250,8 @@ 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 84896e6dd48..7e2e755e46f 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -99,7 +97,6 @@ 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 @@ -110,6 +107,8 @@ 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) @@ -142,7 +141,6 @@ 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 @@ -153,6 +151,8 @@ 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,7 +189,6 @@ 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 @@ -200,6 +199,8 @@ 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) @@ -249,7 +250,6 @@ 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,6 +260,8 @@ 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) @@ -305,7 +307,6 @@ 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 @@ -316,6 +317,8 @@ 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) @@ -361,7 +364,6 @@ 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 @@ -372,6 +374,8 @@ 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) @@ -417,7 +421,6 @@ 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 @@ -428,6 +431,8 @@ 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) @@ -473,7 +478,6 @@ 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 @@ -484,6 +488,8 @@ 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) @@ -529,7 +535,6 @@ 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 @@ -540,6 +545,8 @@ 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) @@ -585,7 +592,6 @@ 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 @@ -596,6 +602,8 @@ 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) @@ -641,7 +649,6 @@ 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 @@ -652,6 +659,8 @@ 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) @@ -697,7 +706,6 @@ 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 @@ -708,6 +716,8 @@ 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) @@ -753,7 +763,6 @@ 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 @@ -764,6 +773,8 @@ 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) @@ -796,7 +807,6 @@ 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 @@ -807,6 +817,8 @@ 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) @@ -852,7 +864,6 @@ 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 @@ -863,6 +874,8 @@ 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) @@ -908,7 +921,6 @@ 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 @@ -919,6 +931,8 @@ 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) @@ -964,7 +978,6 @@ 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 @@ -975,6 +988,8 @@ 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) @@ -1020,7 +1035,6 @@ 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 @@ -1031,6 +1045,8 @@ 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) @@ -1063,7 +1079,6 @@ 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 @@ -1074,6 +1089,8 @@ 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 fc432aa70a9..865f8106d51 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -115,7 +113,6 @@ 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 @@ -126,6 +123,8 @@ 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) @@ -166,7 +165,6 @@ 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 @@ -177,6 +175,8 @@ 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,7 +217,6 @@ 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 @@ -228,6 +227,8 @@ 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) @@ -268,7 +269,6 @@ 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,6 +279,8 @@ 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) @@ -319,7 +321,6 @@ 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 @@ -330,6 +331,8 @@ 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) @@ -370,7 +373,6 @@ 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 @@ -381,6 +383,8 @@ 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) @@ -423,7 +427,6 @@ 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 @@ -434,6 +437,8 @@ 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) @@ -476,7 +481,6 @@ 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 @@ -487,6 +491,8 @@ 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) @@ -530,7 +536,6 @@ 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 @@ -541,6 +546,8 @@ 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) @@ -587,7 +594,6 @@ 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 @@ -598,6 +604,8 @@ 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) @@ -644,7 +652,6 @@ 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 @@ -655,6 +662,8 @@ 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) @@ -701,7 +710,6 @@ 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 @@ -712,6 +720,8 @@ 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) @@ -757,7 +767,6 @@ 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 @@ -768,6 +777,8 @@ 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) @@ -802,7 +813,6 @@ 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 @@ -813,6 +823,8 @@ 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) @@ -847,7 +859,6 @@ 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 @@ -858,6 +869,8 @@ 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) @@ -892,7 +905,6 @@ 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 @@ -903,6 +915,8 @@ 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) @@ -936,7 +950,6 @@ 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 @@ -947,6 +960,8 @@ 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) @@ -980,7 +995,6 @@ 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 @@ -991,6 +1005,8 @@ 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) @@ -1024,7 +1040,6 @@ 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 @@ -1035,6 +1050,8 @@ 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) @@ -1066,7 +1083,6 @@ 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 @@ -1077,6 +1093,8 @@ 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) @@ -1112,7 +1130,6 @@ 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 @@ -1123,6 +1140,8 @@ 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) @@ -1160,7 +1179,6 @@ 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 @@ -1171,6 +1189,8 @@ 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) @@ -1205,7 +1225,6 @@ 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 @@ -1216,6 +1235,8 @@ 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) @@ -1250,7 +1271,6 @@ 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 @@ -1261,6 +1281,8 @@ 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) @@ -1292,7 +1314,6 @@ 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 @@ -1303,6 +1324,8 @@ 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) @@ -1336,7 +1359,6 @@ 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 @@ -1347,6 +1369,8 @@ 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) @@ -1378,7 +1402,6 @@ 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 @@ -1389,6 +1412,8 @@ 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) @@ -1421,7 +1446,6 @@ 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 @@ -1432,6 +1456,8 @@ 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) @@ -1467,7 +1493,6 @@ 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 @@ -1478,6 +1503,8 @@ 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) @@ -1513,7 +1540,6 @@ 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 @@ -1524,6 +1550,8 @@ 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) @@ -1559,7 +1587,6 @@ 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 @@ -1570,6 +1597,8 @@ 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) @@ -1605,7 +1634,6 @@ 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 @@ -1616,6 +1644,8 @@ 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) @@ -1651,7 +1681,6 @@ 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 @@ -1662,6 +1691,8 @@ 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) @@ -1697,7 +1728,6 @@ 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 @@ -1708,6 +1738,8 @@ 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 d75d6d01e28..b79dfaaa392 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -485,7 +483,6 @@ 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 @@ -496,6 +493,8 @@ 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) @@ -528,7 +527,6 @@ 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 @@ -539,6 +537,8 @@ 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,7 +571,6 @@ 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 @@ -582,6 +581,8 @@ 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) @@ -627,7 +628,6 @@ 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,6 +638,8 @@ 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) @@ -683,7 +685,6 @@ 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 @@ -694,6 +695,8 @@ 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) @@ -739,7 +742,6 @@ 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 @@ -750,6 +752,8 @@ 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) @@ -795,7 +799,6 @@ 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 @@ -806,6 +809,8 @@ 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) @@ -838,7 +843,6 @@ 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 @@ -849,6 +853,8 @@ 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) @@ -881,7 +887,6 @@ 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 @@ -892,6 +897,8 @@ 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) @@ -924,7 +931,6 @@ 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 @@ -935,6 +941,8 @@ 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) @@ -967,7 +975,6 @@ 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 @@ -978,6 +985,8 @@ 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) @@ -1023,7 +1032,6 @@ 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 @@ -1034,6 +1042,8 @@ 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) @@ -1079,7 +1089,6 @@ 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 @@ -1090,6 +1099,8 @@ 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) @@ -1135,7 +1146,6 @@ 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 @@ -1146,6 +1156,8 @@ 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) @@ -1191,7 +1203,6 @@ 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 @@ -1202,6 +1213,8 @@ 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) @@ -1247,7 +1260,6 @@ 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 @@ -1258,6 +1270,8 @@ 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) @@ -1290,7 +1304,6 @@ 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 @@ -1301,6 +1314,8 @@ 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) @@ -1333,7 +1348,6 @@ 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 @@ -1344,6 +1358,8 @@ 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) @@ -1376,7 +1392,6 @@ 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 @@ -1387,6 +1402,8 @@ 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) @@ -1419,7 +1436,6 @@ 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 @@ -1430,6 +1446,8 @@ 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) @@ -1475,7 +1493,6 @@ 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 @@ -1486,6 +1503,8 @@ 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) @@ -1531,7 +1550,6 @@ 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 @@ -1542,6 +1560,8 @@ 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) @@ -1587,7 +1607,6 @@ 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 @@ -1598,6 +1617,8 @@ 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) @@ -1630,7 +1651,6 @@ 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 @@ -1641,6 +1661,8 @@ 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) @@ -1686,7 +1708,6 @@ 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 @@ -1697,6 +1718,8 @@ 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) @@ -1729,7 +1752,6 @@ 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 @@ -1740,6 +1762,8 @@ 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 b64355798c4..c31afab7916 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -124,7 +122,6 @@ 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 @@ -135,6 +132,8 @@ 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) @@ -171,7 +170,6 @@ 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 @@ -182,6 +180,8 @@ 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,7 +217,6 @@ 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 @@ -228,6 +227,8 @@ 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 4460394152a..9bacd9cc4f7 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -327,7 +325,6 @@ 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 @@ -338,6 +335,8 @@ 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) @@ -374,7 +373,6 @@ 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 @@ -385,6 +383,8 @@ 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,7 +426,6 @@ 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 @@ -437,6 +436,8 @@ 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) @@ -473,7 +474,6 @@ 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,6 +484,8 @@ 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) @@ -534,7 +536,6 @@ 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 @@ -545,6 +546,8 @@ 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) @@ -580,7 +583,6 @@ 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 @@ -591,6 +593,8 @@ 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) @@ -627,7 +631,6 @@ 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 @@ -638,6 +641,8 @@ 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) @@ -688,7 +693,6 @@ 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 @@ -699,6 +703,8 @@ 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) @@ -748,7 +754,6 @@ 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 @@ -759,6 +764,8 @@ 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) @@ -795,7 +802,6 @@ 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 @@ -806,6 +812,8 @@ 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) @@ -842,7 +850,6 @@ 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 @@ -853,6 +860,8 @@ 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) @@ -889,7 +898,6 @@ 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 @@ -900,6 +908,8 @@ 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) @@ -949,7 +959,6 @@ 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 @@ -960,6 +969,8 @@ 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) @@ -1009,7 +1020,6 @@ 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 @@ -1020,6 +1030,8 @@ 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) @@ -1069,7 +1081,6 @@ 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 @@ -1080,6 +1091,8 @@ 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) @@ -1129,7 +1142,6 @@ 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 @@ -1140,6 +1152,8 @@ 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 4ffd0a08c7c..40a60c0e578 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -226,7 +224,6 @@ 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 @@ -237,6 +234,8 @@ 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) @@ -282,7 +281,6 @@ 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 @@ -293,6 +291,8 @@ 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,7 +338,6 @@ 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 @@ -349,6 +348,8 @@ 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) @@ -381,7 +382,6 @@ 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,6 +392,8 @@ 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) @@ -424,7 +426,6 @@ def options502(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -435,6 +436,8 @@ 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) @@ -484,7 +487,6 @@ 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 @@ -495,6 +497,8 @@ 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) @@ -540,7 +544,6 @@ 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 @@ -551,6 +554,8 @@ 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) @@ -596,7 +601,6 @@ 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 @@ -607,6 +611,8 @@ 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) @@ -652,7 +658,6 @@ 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 @@ -663,6 +668,8 @@ 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 c685625fba6..e894d973c16 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -144,7 +142,6 @@ 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 @@ -155,6 +152,8 @@ 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) @@ -187,7 +186,6 @@ 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 @@ -198,6 +196,8 @@ 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,7 +243,6 @@ 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 @@ -254,6 +253,8 @@ 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) @@ -299,7 +300,6 @@ 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,6 +310,8 @@ 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 0833c794138..e21677e544b 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -390,7 +388,6 @@ 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 @@ -401,6 +398,8 @@ 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) @@ -433,7 +432,6 @@ def get200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,6 +442,8 @@ 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,7 +480,6 @@ def options200(self, **kwargs: Any) -> bool: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -491,6 +490,8 @@ 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) @@ -540,7 +541,6 @@ 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,6 +551,8 @@ 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) @@ -596,7 +598,6 @@ 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 @@ -607,6 +608,8 @@ 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) @@ -652,7 +655,6 @@ 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 @@ -663,6 +665,8 @@ 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) @@ -708,7 +712,6 @@ 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 @@ -719,6 +722,8 @@ 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) @@ -764,7 +769,6 @@ 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 @@ -775,6 +779,8 @@ 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) @@ -820,7 +826,6 @@ 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 @@ -831,6 +836,8 @@ 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) @@ -876,7 +883,6 @@ 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 @@ -887,6 +893,8 @@ 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) @@ -932,7 +940,6 @@ 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 @@ -943,6 +950,8 @@ 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) @@ -988,7 +997,6 @@ 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 @@ -999,6 +1007,8 @@ 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) @@ -1044,7 +1054,6 @@ 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 @@ -1055,6 +1064,8 @@ 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) @@ -1087,7 +1098,6 @@ 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 @@ -1098,6 +1108,8 @@ 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) @@ -1143,7 +1155,6 @@ 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 @@ -1154,6 +1165,8 @@ 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) @@ -1199,7 +1212,6 @@ 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 @@ -1210,6 +1222,8 @@ 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) @@ -1255,7 +1269,6 @@ 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 @@ -1266,6 +1279,8 @@ 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) @@ -1311,7 +1326,6 @@ 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 @@ -1322,6 +1336,8 @@ 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) @@ -1354,7 +1370,6 @@ 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 @@ -1365,6 +1380,8 @@ 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 2e6effc07f3..3270872cee8 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -542,7 +540,6 @@ 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 @@ -553,6 +550,8 @@ 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) @@ -593,7 +592,6 @@ 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 @@ -604,6 +602,8 @@ 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,7 +644,6 @@ 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 @@ -655,6 +654,8 @@ 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) @@ -695,7 +696,6 @@ 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,6 +706,8 @@ 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) @@ -746,7 +748,6 @@ 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 @@ -757,6 +758,8 @@ 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) @@ -797,7 +800,6 @@ 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 @@ -808,6 +810,8 @@ 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) @@ -850,7 +854,6 @@ 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 @@ -861,6 +864,8 @@ 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) @@ -903,7 +908,6 @@ 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 @@ -914,6 +918,8 @@ 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) @@ -957,7 +963,6 @@ 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 @@ -968,6 +973,8 @@ 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) @@ -1014,7 +1021,6 @@ 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 @@ -1025,6 +1031,8 @@ 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) @@ -1071,7 +1079,6 @@ 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 @@ -1082,6 +1089,8 @@ 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) @@ -1128,7 +1137,6 @@ 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 @@ -1139,6 +1147,8 @@ 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) @@ -1184,7 +1194,6 @@ 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 @@ -1195,6 +1204,8 @@ 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) @@ -1229,7 +1240,6 @@ 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 @@ -1240,6 +1250,8 @@ 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) @@ -1274,7 +1286,6 @@ 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 @@ -1285,6 +1296,8 @@ 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) @@ -1319,7 +1332,6 @@ 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 @@ -1330,6 +1342,8 @@ 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) @@ -1363,7 +1377,6 @@ 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 @@ -1374,6 +1387,8 @@ 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) @@ -1407,7 +1422,6 @@ 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 @@ -1418,6 +1432,8 @@ 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) @@ -1451,7 +1467,6 @@ 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 @@ -1462,6 +1477,8 @@ 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) @@ -1493,7 +1510,6 @@ 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 @@ -1504,6 +1520,8 @@ 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) @@ -1539,7 +1557,6 @@ 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 @@ -1550,6 +1567,8 @@ 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) @@ -1585,7 +1604,6 @@ 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 @@ -1596,6 +1614,8 @@ 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) @@ -1628,7 +1648,6 @@ 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 @@ -1639,6 +1658,8 @@ 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) @@ -1671,7 +1692,6 @@ 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 @@ -1682,6 +1702,8 @@ 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) @@ -1713,7 +1735,6 @@ 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 @@ -1724,6 +1745,8 @@ 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) @@ -1755,7 +1778,6 @@ 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 @@ -1766,6 +1788,8 @@ 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) @@ -1797,7 +1821,6 @@ 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 @@ -1808,6 +1831,8 @@ 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) @@ -1840,7 +1865,6 @@ 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 @@ -1851,6 +1875,8 @@ 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) @@ -1886,7 +1912,6 @@ 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 @@ -1897,6 +1922,8 @@ 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) @@ -1932,7 +1959,6 @@ 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 @@ -1943,6 +1969,8 @@ 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) @@ -1978,7 +2006,6 @@ 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 @@ -1989,6 +2016,8 @@ 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) @@ -2024,7 +2053,6 @@ 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 @@ -2035,6 +2063,8 @@ 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) @@ -2070,7 +2100,6 @@ 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 @@ -2081,6 +2110,8 @@ 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) @@ -2116,7 +2147,6 @@ 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 @@ -2127,6 +2157,8 @@ 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 5da5ef74d1f..f44286f6df3 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import IncorrectReturnedErrorModelConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 1e6fcc92549..890e7156ceb 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,8 +8,6 @@ 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 bd5e5e22ced..a4fefcfbf6a 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -64,7 +62,6 @@ 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 @@ -75,6 +72,8 @@ 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 8aa97c44987..e70dd6893f9 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import IncorrectReturnedErrorModelMixinABC, _convert_request +from .._vendor import IncorrectReturnedErrorModelMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -71,7 +70,6 @@ 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 @@ -82,6 +80,8 @@ 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 e6389a0d4d0..059f572c7b2 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 c4778c60b1c..2e6d0c12365 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,8 +8,6 @@ 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 87fb103d029..af9db13747a 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -123,7 +121,6 @@ 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 @@ -134,6 +131,8 @@ 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) @@ -225,7 +224,6 @@ 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 @@ -236,6 +234,8 @@ 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,7 +277,6 @@ 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 @@ -288,6 +287,8 @@ 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) @@ -331,7 +332,6 @@ 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,6 +342,8 @@ 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) @@ -386,7 +388,6 @@ 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 @@ -397,6 +398,8 @@ 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) @@ -460,7 +463,6 @@ 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 @@ -471,6 +473,8 @@ 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) @@ -513,7 +517,6 @@ 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 @@ -524,6 +527,8 @@ 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 b107faeb026..a7c394c688d 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MediaTypesClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -237,7 +236,6 @@ 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 @@ -248,6 +246,8 @@ 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,7 +339,6 @@ 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 @@ -350,6 +349,8 @@ 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) @@ -391,7 +392,6 @@ 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,6 +402,8 @@ 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) @@ -445,7 +447,6 @@ 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 @@ -456,6 +457,8 @@ 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) @@ -500,7 +503,6 @@ 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 @@ -511,6 +513,8 @@ 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) @@ -572,7 +576,6 @@ 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 @@ -583,6 +586,8 @@ 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) @@ -625,7 +630,6 @@ 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 @@ -636,6 +640,8 @@ 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 e6389a0d4d0..059f572c7b2 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MediaTypesClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 c4778c60b1c..2e6d0c12365 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,8 +8,6 @@ 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 f41eeb48d44..4d5a14d2016 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -123,7 +121,6 @@ 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 @@ -134,6 +131,8 @@ 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) @@ -225,7 +224,6 @@ 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 @@ -236,6 +234,8 @@ 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,7 +277,6 @@ 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 @@ -288,6 +287,8 @@ 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) @@ -331,7 +332,6 @@ 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,6 +342,8 @@ 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) @@ -386,7 +388,6 @@ 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 @@ -397,6 +398,8 @@ 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) @@ -500,7 +503,6 @@ 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 @@ -511,6 +513,8 @@ 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) @@ -553,7 +557,6 @@ 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 @@ -564,6 +567,8 @@ 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 ec862580b68..be2c1fa3231 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MediaTypesClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -237,7 +236,6 @@ 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 @@ -248,6 +246,8 @@ 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,7 +339,6 @@ 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 @@ -350,6 +349,8 @@ 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) @@ -391,7 +392,6 @@ 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,6 +402,8 @@ 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) @@ -445,7 +447,6 @@ 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 @@ -456,6 +457,8 @@ 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) @@ -500,7 +503,6 @@ 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 @@ -511,6 +513,8 @@ 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) @@ -614,7 +618,6 @@ 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 @@ -625,6 +628,8 @@ 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) @@ -667,7 +672,6 @@ 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 @@ -678,6 +682,8 @@ 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 5289f742597..bc7fd4a52a0 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MergePatchJsonClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 b4b7cf93232..0521b5d17da 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,8 +8,6 @@ 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 e9b8b003c40..426d5ac5532 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -70,7 +68,6 @@ 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 @@ -81,6 +78,8 @@ 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 76c659601c4..79b556256c3 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import MergePatchJsonClientMixinABC, _convert_request +from .._vendor import MergePatchJsonClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -89,7 +88,6 @@ 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 @@ -100,6 +98,8 @@ 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 139e656ed38..a9c5cb94413 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 8df7cec19de..a7599da945c 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,8 +8,6 @@ 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 41324a95b67..8f5ca9b2414 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -143,7 +141,6 @@ 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 @@ -154,6 +151,8 @@ 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) @@ -189,7 +188,6 @@ 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 @@ -200,6 +198,8 @@ 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,7 +304,6 @@ 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 @@ -315,6 +314,8 @@ 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) @@ -351,7 +352,6 @@ 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,6 +362,8 @@ 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) @@ -463,7 +465,6 @@ 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 @@ -474,6 +475,8 @@ 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) @@ -509,7 +512,6 @@ 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 @@ -520,6 +522,8 @@ 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) @@ -627,7 +631,6 @@ 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 @@ -638,6 +641,8 @@ 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) @@ -673,7 +678,6 @@ 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 @@ -684,6 +688,8 @@ 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) @@ -785,7 +791,6 @@ async def put_simple_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -796,6 +801,8 @@ 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) @@ -875,7 +882,6 @@ async def post_flattened_simple_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -886,6 +892,8 @@ 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) @@ -963,7 +971,6 @@ 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 @@ -974,6 +981,8 @@ 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 15b42e73523..add61d5ed54 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import AutoRestResourceFlatteningTestServiceMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -315,7 +314,6 @@ 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 @@ -326,6 +324,8 @@ 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,7 +361,6 @@ 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 @@ -372,6 +371,8 @@ 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) @@ -476,7 +477,6 @@ 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,6 +487,8 @@ 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) @@ -523,7 +525,6 @@ 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 @@ -534,6 +535,8 @@ 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) @@ -635,7 +638,6 @@ 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 @@ -646,6 +648,8 @@ 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) @@ -681,7 +685,6 @@ 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 @@ -692,6 +695,8 @@ 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) @@ -799,7 +804,6 @@ 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 @@ -810,6 +814,8 @@ 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) @@ -845,7 +851,6 @@ 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 @@ -856,6 +861,8 @@ 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) @@ -957,7 +964,6 @@ def put_simple_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -968,6 +974,8 @@ 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) @@ -1047,7 +1055,6 @@ def post_flattened_simple_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1058,6 +1065,8 @@ 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) @@ -1135,7 +1144,6 @@ def put_simple_product_with_grouping( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1146,6 +1154,8 @@ 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 0c3f73c1af8..ab12708447c 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import MultipleInheritanceServiceClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 f62abf36f85..22e0b34b3f3 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,8 +8,6 @@ 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 cce0e11e655..883690a1e8d 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -77,7 +75,6 @@ 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 @@ -88,6 +85,8 @@ 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) @@ -167,7 +166,6 @@ 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 @@ -178,6 +176,8 @@ 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,7 +213,6 @@ 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 @@ -224,6 +223,8 @@ 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) @@ -268,7 +269,6 @@ 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,6 +279,8 @@ 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) @@ -314,7 +316,6 @@ 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 @@ -325,6 +326,8 @@ 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) @@ -404,7 +407,6 @@ 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 @@ -415,6 +417,8 @@ 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) @@ -450,7 +454,6 @@ 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 @@ -461,6 +464,8 @@ 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) @@ -542,7 +547,6 @@ 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 @@ -553,6 +557,8 @@ 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) @@ -589,7 +595,6 @@ 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 @@ -600,6 +605,8 @@ 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) @@ -684,7 +691,6 @@ 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 @@ -695,6 +701,8 @@ 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 302509da94c..ca8bba2f740 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,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import MultipleInheritanceServiceClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -223,7 +222,6 @@ 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 @@ -234,6 +232,8 @@ 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,7 +313,6 @@ 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 @@ -324,6 +323,8 @@ 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) @@ -359,7 +360,6 @@ 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,6 +370,8 @@ 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) @@ -414,7 +416,6 @@ 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 @@ -425,6 +426,8 @@ 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) @@ -460,7 +463,6 @@ 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 @@ -471,6 +473,8 @@ 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) @@ -550,7 +554,6 @@ 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 @@ -561,6 +564,8 @@ 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) @@ -596,7 +601,6 @@ 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 @@ -607,6 +611,8 @@ 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) @@ -688,7 +694,6 @@ 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 @@ -699,6 +704,8 @@ 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) @@ -735,7 +742,6 @@ 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 @@ -746,6 +752,8 @@ 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) @@ -830,7 +838,6 @@ 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 @@ -841,6 +848,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 68bf635cf8a..4b115578546 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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) @@ -134,7 +133,6 @@ 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 @@ -145,6 +143,8 @@ 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 2cc594802b6..096aef49d38 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -88,7 +86,6 @@ 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 @@ -99,6 +96,8 @@ 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) @@ -134,7 +133,6 @@ 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 @@ -145,6 +143,8 @@ 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 099418af4f2..824179de458 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +120,6 @@ 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 @@ -133,6 +130,8 @@ 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) @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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 4f03dc0e17d..6ee8a564715 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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,7 +120,6 @@ 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 @@ -133,6 +130,8 @@ 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) @@ -168,7 +167,6 @@ 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 @@ -179,6 +177,8 @@ 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 5bf024b7798..38f277f20f4 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ObjectTypeClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 f313807443d..97ff8285a95 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,8 +8,6 @@ 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 2b0b5de7b5b..bbc6d8669ba 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -64,7 +62,6 @@ 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 @@ -75,6 +72,8 @@ 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) @@ -120,7 +119,6 @@ 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 @@ -131,6 +129,8 @@ 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 948c62621ba..44b05d10099 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import ObjectTypeClientMixinABC, _convert_request +from .._vendor import ObjectTypeClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -97,7 +96,6 @@ def get(self, **kwargs: Any) -> JSON: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -108,6 +106,8 @@ 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,7 +153,6 @@ 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 @@ -164,6 +163,8 @@ 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 d756d07f319..dc910ddc7e5 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AnythingClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 2007e9f7a76..29d65bdd121 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,8 +8,6 @@ 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 c6d091f4a40..f2671ee3f00 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -70,7 +68,6 @@ 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 @@ -81,6 +78,8 @@ 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) @@ -124,7 +123,6 @@ 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 @@ -135,6 +133,8 @@ 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,7 +166,6 @@ 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 @@ -177,6 +176,8 @@ 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) @@ -220,7 +221,6 @@ 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,6 +231,8 @@ 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) @@ -262,7 +264,6 @@ 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 @@ -273,6 +274,8 @@ 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) @@ -316,7 +319,6 @@ 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 @@ -327,6 +329,8 @@ 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 5e68127ea9c..16b288c25d8 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,13 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from .._serialization import Serializer -from .._vendor import AnythingClientMixinABC, _convert_request +from .._vendor import AnythingClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -149,7 +148,6 @@ 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 @@ -160,6 +158,8 @@ 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,7 +203,6 @@ 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 @@ -214,6 +213,8 @@ 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) @@ -245,7 +246,6 @@ 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,6 +256,8 @@ 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) @@ -299,7 +301,6 @@ 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 @@ -310,6 +311,8 @@ 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) @@ -341,7 +344,6 @@ 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 @@ -352,6 +354,8 @@ 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) @@ -395,7 +399,6 @@ 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 @@ -406,6 +409,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 905e75e3b53..acaba671f66 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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): @@ -95,7 +93,6 @@ 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 @@ -106,6 +103,8 @@ 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 fbf104dcb0d..75c698a544c 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -118,7 +116,6 @@ 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 @@ -129,6 +126,8 @@ 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 6038f7aee92..3aa95cca6e2 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ParmaterizedEndpointClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 54fe7210a6f..c8495a15c6f 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,8 +8,6 @@ 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 e1fe0052b05..bef061cb6d4 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -61,7 +59,6 @@ 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), } @@ -75,6 +72,8 @@ 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 6aff1fb8f56..2812639cd79 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import ParmaterizedEndpointClientMixinABC, _convert_request +from .._vendor import ParmaterizedEndpointClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,7 +69,6 @@ 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), } @@ -84,6 +82,8 @@ 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 5576189da06..3809d97ecea 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutoRestReportServiceConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 52ad4a50f69..ebe95d1ea53 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,8 +8,6 @@ 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 e83dbf0e725..e6c69dc647f 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -70,7 +68,6 @@ 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 @@ -81,6 +78,8 @@ 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) @@ -122,7 +121,6 @@ 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 @@ -133,6 +131,8 @@ 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 84cb88e4a2c..1e8d850fcb8 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import AutoRestReportServiceMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,7 +107,6 @@ 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 @@ -119,6 +117,8 @@ 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,7 +160,6 @@ 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 @@ -171,6 +170,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 d6657feda81..bcec8cd4664 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -114,7 +112,6 @@ 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 @@ -125,6 +122,8 @@ 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) @@ -166,7 +165,6 @@ 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 @@ -177,6 +175,8 @@ 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,7 +219,6 @@ 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 @@ -230,6 +229,8 @@ 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) @@ -274,7 +275,6 @@ 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,6 +285,8 @@ 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) @@ -328,7 +330,6 @@ 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 @@ -339,6 +340,8 @@ 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) @@ -384,7 +387,6 @@ 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 @@ -395,6 +397,8 @@ 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) @@ -433,7 +437,6 @@ 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 @@ -444,6 +447,8 @@ 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) @@ -481,7 +486,6 @@ 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 @@ -492,6 +496,8 @@ 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) @@ -534,7 +540,6 @@ 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 @@ -545,6 +550,8 @@ 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) @@ -589,7 +596,6 @@ 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 @@ -600,6 +606,8 @@ 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) @@ -643,7 +651,6 @@ 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 @@ -654,6 +661,8 @@ 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) @@ -699,7 +708,6 @@ 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 @@ -710,6 +718,8 @@ 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) @@ -748,7 +758,6 @@ 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 @@ -759,6 +768,8 @@ 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) @@ -796,7 +807,6 @@ 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 @@ -807,6 +817,8 @@ 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) @@ -890,7 +902,6 @@ 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 @@ -901,6 +912,8 @@ 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) @@ -984,7 +997,6 @@ 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 @@ -995,6 +1007,8 @@ 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) @@ -1038,7 +1052,6 @@ 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 @@ -1049,6 +1062,8 @@ 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) @@ -1094,7 +1109,6 @@ 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 @@ -1105,6 +1119,8 @@ 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) @@ -1188,7 +1204,6 @@ 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 @@ -1199,6 +1214,8 @@ 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) @@ -1282,7 +1299,6 @@ 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 @@ -1293,6 +1309,8 @@ 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) @@ -1336,7 +1354,6 @@ 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 @@ -1347,6 +1364,8 @@ 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) @@ -1392,7 +1411,6 @@ 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 @@ -1403,6 +1421,8 @@ 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) @@ -1441,7 +1461,6 @@ 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 @@ -1452,6 +1471,8 @@ 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) @@ -1489,7 +1510,6 @@ 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 @@ -1500,6 +1520,8 @@ 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 322bc41c59a..063f8985317 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -93,7 +91,6 @@ 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 @@ -104,6 +101,8 @@ 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) @@ -141,7 +140,6 @@ 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 @@ -152,6 +150,8 @@ 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,7 +189,6 @@ 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 @@ -200,6 +199,8 @@ 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) @@ -244,7 +245,6 @@ 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,6 +255,8 @@ 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) @@ -296,7 +298,6 @@ 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 @@ -307,6 +308,8 @@ 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) @@ -340,7 +343,6 @@ 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 @@ -351,6 +353,8 @@ 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) @@ -384,7 +388,6 @@ 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 @@ -395,6 +398,8 @@ 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) @@ -428,7 +433,6 @@ 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 @@ -439,6 +443,8 @@ 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 669edcff3d5..86c9150fab2 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -509,7 +507,6 @@ 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 @@ -520,6 +517,8 @@ 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) @@ -561,7 +560,6 @@ 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 @@ -572,6 +570,8 @@ 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,7 +614,6 @@ 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 @@ -625,6 +624,8 @@ 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) @@ -669,7 +670,6 @@ 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,6 +680,8 @@ 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) @@ -723,7 +725,6 @@ 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 @@ -734,6 +735,8 @@ 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) @@ -779,7 +782,6 @@ 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 @@ -790,6 +792,8 @@ 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) @@ -828,7 +832,6 @@ 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 @@ -839,6 +842,8 @@ 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) @@ -876,7 +881,6 @@ 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 @@ -887,6 +891,8 @@ 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) @@ -929,7 +935,6 @@ 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 @@ -940,6 +945,8 @@ 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) @@ -984,7 +991,6 @@ 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 @@ -995,6 +1001,8 @@ 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) @@ -1038,7 +1046,6 @@ 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 @@ -1049,6 +1056,8 @@ 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) @@ -1094,7 +1103,6 @@ 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 @@ -1105,6 +1113,8 @@ 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) @@ -1143,7 +1153,6 @@ 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 @@ -1154,6 +1163,8 @@ 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) @@ -1191,7 +1202,6 @@ 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 @@ -1202,6 +1212,8 @@ 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) @@ -1285,7 +1297,6 @@ 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 @@ -1296,6 +1307,8 @@ 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) @@ -1379,7 +1392,6 @@ 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 @@ -1390,6 +1402,8 @@ 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) @@ -1433,7 +1447,6 @@ 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 @@ -1444,6 +1457,8 @@ 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) @@ -1489,7 +1504,6 @@ 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 @@ -1500,6 +1514,8 @@ 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) @@ -1583,7 +1599,6 @@ 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 @@ -1594,6 +1609,8 @@ 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) @@ -1677,7 +1694,6 @@ 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 @@ -1688,6 +1704,8 @@ 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) @@ -1731,7 +1749,6 @@ 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 @@ -1742,6 +1759,8 @@ 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) @@ -1787,7 +1806,6 @@ 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 @@ -1798,6 +1816,8 @@ 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) @@ -1836,7 +1856,6 @@ 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 @@ -1847,6 +1866,8 @@ 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) @@ -1884,7 +1905,6 @@ 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 @@ -1895,6 +1915,8 @@ 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 8a1fc1311fa..d0c97128911 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -233,7 +231,6 @@ 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 @@ -244,6 +241,8 @@ 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) @@ -281,7 +280,6 @@ 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 @@ -292,6 +290,8 @@ 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,7 +329,6 @@ 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 @@ -340,6 +339,8 @@ 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) @@ -384,7 +385,6 @@ 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,6 +395,8 @@ 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) @@ -436,7 +438,6 @@ 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 @@ -447,6 +448,8 @@ 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) @@ -480,7 +483,6 @@ 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 @@ -491,6 +493,8 @@ 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) @@ -524,7 +528,6 @@ 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 @@ -535,6 +538,8 @@ 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) @@ -568,7 +573,6 @@ 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 @@ -579,6 +583,8 @@ 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 3cde08fb119..d403fc63b46 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ReservedWordsClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 6546cfae4fe..2d710d6e319 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,8 +8,6 @@ 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 80f0522c1a7..b25abef8731 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -83,7 +81,6 @@ 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 @@ -94,6 +91,8 @@ 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 21aa0b2793d..717fdddcb48 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -78,7 +76,6 @@ 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 @@ -89,6 +86,8 @@ 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) @@ -131,7 +130,6 @@ 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 @@ -142,6 +140,8 @@ 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,7 +192,6 @@ 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 @@ -203,6 +202,8 @@ 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) @@ -251,7 +252,6 @@ 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,6 +262,8 @@ 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) @@ -311,7 +313,6 @@ async def operation_with_url( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -322,6 +323,8 @@ 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) @@ -361,7 +364,6 @@ 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 @@ -372,6 +374,8 @@ 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 96cc06cee8f..30aa18e93a9 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import ReservedWordsClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,7 +103,6 @@ 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 @@ -115,6 +113,8 @@ 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 d552dca394f..3edb11a518e 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,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import ReservedWordsClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -183,7 +182,6 @@ 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 @@ -194,6 +192,8 @@ 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,7 +236,6 @@ 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 @@ -247,6 +246,8 @@ 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) @@ -297,7 +298,6 @@ 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,6 +308,8 @@ 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) @@ -356,7 +358,6 @@ 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 @@ -367,6 +368,8 @@ 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) @@ -416,7 +419,6 @@ def operation_with_url( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -427,6 +429,8 @@ 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) @@ -466,7 +470,6 @@ 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 @@ -477,6 +480,8 @@ 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 7fdee8b3dfe..307a2440f73 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutorestSecurityAadConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 8925dce2632..8e6e310bac2 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,8 +8,6 @@ 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 0304a1f2a03..10cf8a5f34b 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -61,7 +59,6 @@ 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 @@ -72,6 +69,8 @@ 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 24eddfea9e1..54b7e97bd34 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import AutorestSecurityAadMixinABC, _convert_request +from .._vendor import AutorestSecurityAadMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,7 +69,6 @@ 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,6 +79,8 @@ 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 11635e217a0..bc2ebad1a2d 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import SecurityAadSwaggerCredentialFlagConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 085e406b6f9..f93d4cba9e3 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,8 +8,6 @@ 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 7c1dfe85f48..d2edbb1411e 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -63,7 +61,6 @@ 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 @@ -74,6 +71,8 @@ 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 eb3a227cf9f..54666a09a7d 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import SecurityAadSwaggerCredentialFlagMixinABC, _convert_request +from .._vendor import SecurityAadSwaggerCredentialFlagMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -72,7 +71,6 @@ 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 @@ -83,6 +81,8 @@ 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 c8a5025a2fb..9fb96a324c5 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutorestSecurityKeyConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 b2d14534fb2..7b331844629 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,8 +8,6 @@ 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 578b86aa291..46ed9526712 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -61,7 +59,6 @@ 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 @@ -72,6 +69,8 @@ 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 3cd7e76329b..dc7f39fc366 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import AutorestSecurityKeyMixinABC, _convert_request +from .._vendor import AutorestSecurityKeyMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -70,7 +69,6 @@ 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,6 +79,8 @@ 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 528e40858f1..4a233605917 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import SecurityKeySwaggerCredentialFlagConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 939606c8825..c9bea806ed6 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,8 +8,6 @@ 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 bd4b7ed8f32..9bcf8560fee 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,11 +18,9 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -63,7 +61,6 @@ 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 @@ -74,6 +71,8 @@ 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 cacd3d7cc0d..4d90c61cf77 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,12 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from .._serialization import Serializer -from .._vendor import SecurityKeySwaggerCredentialFlagMixinABC, _convert_request +from .._vendor import SecurityKeySwaggerCredentialFlagMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -72,7 +71,6 @@ 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 @@ -83,6 +81,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 62a1cb5ee11..c45256242fd 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -108,7 +106,6 @@ 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 @@ -119,6 +116,8 @@ 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) @@ -176,7 +175,6 @@ 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 @@ -187,6 +185,8 @@ 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,7 +244,6 @@ 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 @@ -255,6 +254,8 @@ 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) @@ -311,7 +312,6 @@ 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,6 +322,8 @@ 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 3aca9d7ca9c..8361adddc19 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,12 +19,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -109,7 +107,6 @@ 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 @@ -120,6 +117,8 @@ 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) @@ -154,7 +153,6 @@ 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 @@ -165,6 +163,8 @@ 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,7 +199,6 @@ 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 @@ -210,6 +209,8 @@ 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) @@ -246,7 +247,6 @@ 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,6 +257,8 @@ 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) @@ -291,7 +293,6 @@ 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 @@ -302,6 +303,8 @@ 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) @@ -336,7 +339,6 @@ 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 @@ -347,6 +349,8 @@ 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) @@ -381,7 +385,6 @@ 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 @@ -392,6 +395,8 @@ 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) @@ -426,7 +431,6 @@ 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 @@ -437,6 +441,8 @@ 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) @@ -471,7 +477,6 @@ 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 @@ -482,6 +487,8 @@ 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) @@ -516,7 +523,6 @@ 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 @@ -527,6 +533,8 @@ 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) @@ -561,7 +569,6 @@ 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 @@ -572,6 +579,8 @@ 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) @@ -606,7 +615,6 @@ 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 @@ -617,6 +625,8 @@ 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) @@ -653,7 +663,6 @@ 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 @@ -664,6 +673,8 @@ 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) @@ -698,7 +709,6 @@ 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 @@ -709,6 +719,8 @@ 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) @@ -746,7 +758,6 @@ 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 @@ -757,6 +768,8 @@ 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) @@ -795,7 +808,6 @@ 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 @@ -806,6 +818,8 @@ 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) @@ -844,7 +858,6 @@ 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 @@ -855,6 +868,8 @@ 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) @@ -892,7 +907,6 @@ 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 @@ -903,6 +917,8 @@ 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) @@ -937,7 +953,6 @@ 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 @@ -948,6 +963,8 @@ 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) @@ -985,7 +1002,6 @@ 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 @@ -996,6 +1012,8 @@ 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) @@ -1030,7 +1048,6 @@ 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 @@ -1041,6 +1058,8 @@ 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) @@ -1079,7 +1098,6 @@ 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 @@ -1090,6 +1108,8 @@ 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) @@ -1124,7 +1144,6 @@ 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 @@ -1135,6 +1154,8 @@ 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) @@ -1172,7 +1193,6 @@ 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 @@ -1183,6 +1203,8 @@ 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) @@ -1220,7 +1242,6 @@ 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 @@ -1231,6 +1252,8 @@ 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) @@ -1270,7 +1293,6 @@ 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 @@ -1281,6 +1303,8 @@ 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) @@ -1318,7 +1342,6 @@ 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 @@ -1329,6 +1352,8 @@ 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 f6b4e309981..70b26351c2e 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -118,7 +116,6 @@ 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 @@ -129,6 +126,8 @@ 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) @@ -163,7 +162,6 @@ 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 @@ -174,6 +172,8 @@ 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,7 +211,6 @@ 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 @@ -222,6 +221,8 @@ 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) @@ -256,7 +257,6 @@ 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,6 +267,8 @@ 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) @@ -303,7 +305,6 @@ 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 @@ -314,6 +315,8 @@ 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) @@ -351,7 +354,6 @@ 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 @@ -362,6 +364,8 @@ 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) @@ -396,7 +400,6 @@ 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 @@ -407,6 +410,8 @@ 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) @@ -441,7 +446,6 @@ 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 @@ -452,6 +456,8 @@ 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) @@ -489,7 +495,6 @@ 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 @@ -500,6 +505,8 @@ 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) @@ -534,7 +541,6 @@ 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 @@ -545,6 +551,8 @@ 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) @@ -579,7 +587,6 @@ 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 @@ -590,6 +597,8 @@ 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) @@ -627,7 +636,6 @@ 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 @@ -638,6 +646,8 @@ 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) @@ -672,7 +682,6 @@ 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 @@ -683,6 +692,8 @@ 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) @@ -717,7 +728,6 @@ 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 @@ -728,6 +738,8 @@ 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) @@ -765,7 +777,6 @@ 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 @@ -776,6 +787,8 @@ 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) @@ -812,7 +825,6 @@ 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 @@ -823,6 +835,8 @@ 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) @@ -859,7 +873,6 @@ 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 @@ -870,6 +883,8 @@ 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) @@ -904,7 +919,6 @@ 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 @@ -915,6 +929,8 @@ 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) @@ -952,7 +968,6 @@ 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 @@ -963,6 +978,8 @@ 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) @@ -1001,7 +1018,6 @@ 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 @@ -1012,6 +1028,8 @@ 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) @@ -1050,7 +1068,6 @@ 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 @@ -1061,6 +1078,8 @@ 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) @@ -1099,7 +1118,6 @@ 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 @@ -1110,6 +1128,8 @@ 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) @@ -1144,7 +1164,6 @@ 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 @@ -1155,6 +1174,8 @@ 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) @@ -1192,7 +1213,6 @@ 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 @@ -1203,6 +1223,8 @@ 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) @@ -1237,7 +1259,6 @@ 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 @@ -1248,6 +1269,8 @@ 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) @@ -1285,7 +1308,6 @@ 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 @@ -1296,6 +1318,8 @@ 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) @@ -1332,7 +1356,6 @@ 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 @@ -1343,6 +1366,8 @@ 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) @@ -1380,7 +1405,6 @@ 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 @@ -1391,6 +1415,8 @@ 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) @@ -1430,7 +1456,6 @@ 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 @@ -1441,6 +1466,8 @@ 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) @@ -1478,7 +1505,6 @@ 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 @@ -1489,6 +1515,8 @@ 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) @@ -1527,7 +1555,6 @@ 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 @@ -1538,6 +1565,8 @@ 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) @@ -1577,7 +1606,6 @@ 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 @@ -1588,6 +1616,8 @@ 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) @@ -1627,7 +1657,6 @@ 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 @@ -1638,6 +1667,8 @@ 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) @@ -1677,7 +1708,6 @@ 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 @@ -1688,6 +1718,8 @@ 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) @@ -1727,7 +1759,6 @@ 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 @@ -1738,6 +1769,8 @@ 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 2773bb8ec5b..05b846b6487 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,13 +20,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -275,7 +273,6 @@ 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 @@ -286,6 +283,8 @@ 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) @@ -343,7 +342,6 @@ 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 @@ -354,6 +352,8 @@ 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,7 +411,6 @@ 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 @@ -422,6 +421,8 @@ 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) @@ -478,7 +479,6 @@ 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,6 +489,8 @@ 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 035cc79e6b0..d19d2392b76 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -620,7 +618,6 @@ 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 @@ -631,6 +628,8 @@ 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) @@ -665,7 +664,6 @@ 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 @@ -676,6 +674,8 @@ 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,7 +710,6 @@ 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 @@ -721,6 +720,8 @@ 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) @@ -755,7 +756,6 @@ 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,6 +766,8 @@ 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) @@ -800,7 +802,6 @@ 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 @@ -811,6 +812,8 @@ 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) @@ -845,7 +848,6 @@ 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 @@ -856,6 +858,8 @@ 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) @@ -890,7 +894,6 @@ 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 @@ -901,6 +904,8 @@ 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) @@ -935,7 +940,6 @@ 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 @@ -946,6 +950,8 @@ 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) @@ -980,7 +986,6 @@ 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 @@ -991,6 +996,8 @@ 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) @@ -1025,7 +1032,6 @@ 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 @@ -1036,6 +1042,8 @@ 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) @@ -1070,7 +1078,6 @@ 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 @@ -1081,6 +1088,8 @@ 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) @@ -1115,7 +1124,6 @@ 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 @@ -1126,6 +1134,8 @@ 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) @@ -1162,7 +1172,6 @@ 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 @@ -1173,6 +1182,8 @@ 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) @@ -1207,7 +1218,6 @@ 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 @@ -1218,6 +1228,8 @@ 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) @@ -1253,7 +1265,6 @@ 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 @@ -1264,6 +1275,8 @@ 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) @@ -1302,7 +1315,6 @@ 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 @@ -1313,6 +1325,8 @@ 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) @@ -1351,7 +1365,6 @@ 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 @@ -1362,6 +1375,8 @@ 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) @@ -1399,7 +1414,6 @@ 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 @@ -1410,6 +1424,8 @@ 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) @@ -1444,7 +1460,6 @@ 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 @@ -1455,6 +1470,8 @@ 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) @@ -1490,7 +1507,6 @@ 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 @@ -1501,6 +1517,8 @@ 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) @@ -1535,7 +1553,6 @@ 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 @@ -1546,6 +1563,8 @@ 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) @@ -1584,7 +1603,6 @@ 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 @@ -1595,6 +1613,8 @@ 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) @@ -1629,7 +1649,6 @@ 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 @@ -1640,6 +1659,8 @@ 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) @@ -1677,7 +1698,6 @@ 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 @@ -1688,6 +1708,8 @@ 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) @@ -1725,7 +1747,6 @@ 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 @@ -1736,6 +1757,8 @@ 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) @@ -1775,7 +1798,6 @@ 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 @@ -1786,6 +1808,8 @@ 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) @@ -1823,7 +1847,6 @@ 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 @@ -1834,6 +1857,8 @@ 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 fefbaf3b55e..5b5518aa69f 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,13 +21,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -762,7 +760,6 @@ 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 @@ -773,6 +770,8 @@ 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) @@ -807,7 +806,6 @@ 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 @@ -818,6 +816,8 @@ 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,7 +855,6 @@ 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 @@ -866,6 +865,8 @@ 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) @@ -900,7 +901,6 @@ 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,6 +911,8 @@ 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) @@ -945,7 +947,6 @@ 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 @@ -956,6 +957,8 @@ 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) @@ -993,7 +996,6 @@ 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 @@ -1004,6 +1006,8 @@ 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) @@ -1038,7 +1042,6 @@ 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 @@ -1049,6 +1052,8 @@ 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) @@ -1083,7 +1088,6 @@ 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 @@ -1094,6 +1098,8 @@ 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) @@ -1131,7 +1137,6 @@ 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 @@ -1142,6 +1147,8 @@ 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) @@ -1176,7 +1183,6 @@ 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 @@ -1187,6 +1193,8 @@ 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) @@ -1221,7 +1229,6 @@ 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 @@ -1232,6 +1239,8 @@ 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) @@ -1269,7 +1278,6 @@ 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 @@ -1280,6 +1288,8 @@ 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) @@ -1314,7 +1324,6 @@ 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 @@ -1325,6 +1334,8 @@ 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) @@ -1359,7 +1370,6 @@ 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 @@ -1370,6 +1380,8 @@ 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) @@ -1407,7 +1419,6 @@ 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 @@ -1418,6 +1429,8 @@ 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) @@ -1454,7 +1467,6 @@ 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 @@ -1465,6 +1477,8 @@ 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) @@ -1501,7 +1515,6 @@ 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 @@ -1512,6 +1525,8 @@ 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) @@ -1546,7 +1561,6 @@ 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 @@ -1557,6 +1571,8 @@ 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) @@ -1594,7 +1610,6 @@ 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 @@ -1605,6 +1620,8 @@ 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) @@ -1643,7 +1660,6 @@ 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 @@ -1654,6 +1670,8 @@ 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) @@ -1692,7 +1710,6 @@ 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 @@ -1703,6 +1720,8 @@ 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) @@ -1741,7 +1760,6 @@ 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 @@ -1752,6 +1770,8 @@ 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) @@ -1786,7 +1806,6 @@ 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 @@ -1797,6 +1816,8 @@ 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) @@ -1834,7 +1855,6 @@ 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 @@ -1845,6 +1865,8 @@ 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) @@ -1879,7 +1901,6 @@ 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 @@ -1890,6 +1911,8 @@ 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) @@ -1927,7 +1950,6 @@ 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 @@ -1938,6 +1960,8 @@ 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) @@ -1974,7 +1998,6 @@ 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 @@ -1985,6 +2008,8 @@ 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) @@ -2022,7 +2047,6 @@ 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 @@ -2033,6 +2057,8 @@ 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) @@ -2072,7 +2098,6 @@ 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 @@ -2083,6 +2108,8 @@ 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) @@ -2120,7 +2147,6 @@ 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 @@ -2131,6 +2157,8 @@ 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) @@ -2169,7 +2197,6 @@ 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 @@ -2180,6 +2207,8 @@ 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) @@ -2219,7 +2248,6 @@ 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 @@ -2230,6 +2258,8 @@ 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) @@ -2269,7 +2299,6 @@ 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 @@ -2280,6 +2309,8 @@ 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) @@ -2319,7 +2350,6 @@ 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 @@ -2330,6 +2360,8 @@ 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) @@ -2369,7 +2401,6 @@ 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 @@ -2380,6 +2411,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 3d5ae26e52f..2374956f354 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -87,7 +85,6 @@ 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 @@ -98,6 +95,8 @@ 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) @@ -136,7 +135,6 @@ 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 @@ -147,6 +145,8 @@ 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,7 +186,6 @@ 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 @@ -197,6 +196,8 @@ 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 586565c7247..17badce0a55 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -150,7 +148,6 @@ 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 @@ -161,6 +158,8 @@ 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) @@ -199,7 +198,6 @@ 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 @@ -210,6 +208,8 @@ 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,7 +249,6 @@ 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 @@ -260,6 +259,8 @@ 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 02205ff13b6..296ecb35e57 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,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutoRestValidationTestConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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 985521f58ba..3d120f48d9e 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,8 +8,6 @@ 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 1b62947d993..801457e7285 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,13 +19,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -81,7 +79,6 @@ async def validation_of_method_parameters( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -92,6 +89,8 @@ 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) @@ -211,7 +210,6 @@ async def validation_of_body( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -222,6 +220,8 @@ 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,7 +260,6 @@ 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 @@ -271,6 +270,8 @@ 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) @@ -355,7 +356,6 @@ 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,6 +366,8 @@ 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 75ca9b1158d..66acd37bd9a 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,13 +21,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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, _convert_request +from .._vendor import AutoRestValidationTestMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -175,7 +174,6 @@ 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 @@ -186,6 +184,8 @@ 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,7 +305,6 @@ def validation_of_body( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -316,6 +315,8 @@ 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) @@ -354,7 +355,6 @@ 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,6 +365,8 @@ 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) @@ -449,7 +451,6 @@ def post_with_constant_in_body( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,6 +461,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 f689b8b480b..7dccd1e7525 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,13 +18,11 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -114,7 +112,6 @@ 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 @@ -125,6 +122,8 @@ 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) @@ -169,7 +168,6 @@ 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 @@ -180,6 +178,8 @@ 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,7 +211,6 @@ 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 @@ -222,6 +221,8 @@ 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) @@ -266,7 +267,6 @@ 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,6 +277,8 @@ 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) @@ -308,7 +310,6 @@ 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 @@ -319,6 +320,8 @@ 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) @@ -364,7 +367,6 @@ 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 @@ -375,6 +377,8 @@ 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) @@ -407,7 +411,6 @@ 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 @@ -418,6 +421,8 @@ 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) @@ -462,7 +467,6 @@ 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 @@ -473,6 +477,8 @@ 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) @@ -505,7 +511,6 @@ 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 @@ -516,6 +521,8 @@ 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) @@ -550,7 +557,6 @@ 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 @@ -561,6 +567,8 @@ 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) @@ -605,7 +613,6 @@ 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 @@ -616,6 +623,8 @@ 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) @@ -647,7 +656,6 @@ 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 @@ -658,6 +666,8 @@ 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) @@ -702,7 +712,6 @@ 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 @@ -713,6 +722,8 @@ 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) @@ -744,7 +755,6 @@ 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 @@ -755,6 +765,8 @@ 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) @@ -800,7 +812,6 @@ 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 @@ -811,6 +822,8 @@ 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) @@ -842,7 +855,6 @@ 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 @@ -853,6 +865,8 @@ 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) @@ -898,7 +912,6 @@ 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 @@ -909,6 +922,8 @@ 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) @@ -940,7 +955,6 @@ 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 @@ -951,6 +965,8 @@ 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) @@ -996,7 +1012,6 @@ 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 @@ -1007,6 +1022,8 @@ 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) @@ -1038,7 +1055,6 @@ 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 @@ -1049,6 +1065,8 @@ 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) @@ -1093,7 +1111,6 @@ 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 @@ -1104,6 +1121,8 @@ 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) @@ -1137,7 +1156,6 @@ 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 @@ -1148,6 +1166,8 @@ 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) @@ -1187,7 +1207,6 @@ 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 @@ -1198,6 +1217,8 @@ 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) @@ -1246,7 +1267,6 @@ 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 @@ -1257,6 +1277,8 @@ 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) @@ -1292,7 +1314,6 @@ 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 @@ -1303,6 +1324,8 @@ 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) @@ -1354,7 +1377,6 @@ 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 @@ -1365,6 +1387,8 @@ 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) @@ -1400,7 +1424,6 @@ 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 @@ -1411,6 +1434,8 @@ 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) @@ -1457,7 +1482,6 @@ 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 @@ -1468,6 +1492,8 @@ 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) @@ -1499,7 +1525,6 @@ 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 @@ -1510,6 +1535,8 @@ 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) @@ -1546,7 +1573,6 @@ 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 @@ -1557,6 +1583,8 @@ 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) @@ -1592,7 +1620,6 @@ 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 @@ -1603,6 +1630,8 @@ 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) @@ -1649,7 +1678,6 @@ 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 @@ -1660,6 +1688,8 @@ 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) @@ -1692,7 +1722,6 @@ 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 @@ -1703,6 +1732,8 @@ 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) @@ -1749,7 +1780,6 @@ 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 @@ -1760,6 +1790,8 @@ 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 ef8109a990b..9e11b0ad5c2 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -607,7 +605,6 @@ 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 @@ -618,6 +615,8 @@ 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) @@ -662,7 +661,6 @@ 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 @@ -673,6 +671,8 @@ 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,7 +704,6 @@ 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 @@ -715,6 +714,8 @@ 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) @@ -759,7 +760,6 @@ 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,6 +770,8 @@ 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) @@ -801,7 +803,6 @@ 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 @@ -812,6 +813,8 @@ 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) @@ -857,7 +860,6 @@ 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 @@ -868,6 +870,8 @@ 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) @@ -900,7 +904,6 @@ 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 @@ -911,6 +914,8 @@ 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) @@ -955,7 +960,6 @@ 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 @@ -966,6 +970,8 @@ 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) @@ -998,7 +1004,6 @@ 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 @@ -1009,6 +1014,8 @@ 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) @@ -1043,7 +1050,6 @@ 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 @@ -1054,6 +1060,8 @@ 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) @@ -1098,7 +1106,6 @@ 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 @@ -1109,6 +1116,8 @@ 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) @@ -1140,7 +1149,6 @@ 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 @@ -1151,6 +1159,8 @@ 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) @@ -1195,7 +1205,6 @@ 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 @@ -1206,6 +1215,8 @@ 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) @@ -1237,7 +1248,6 @@ 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 @@ -1248,6 +1258,8 @@ 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) @@ -1293,7 +1305,6 @@ 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 @@ -1304,6 +1315,8 @@ 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) @@ -1335,7 +1348,6 @@ 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 @@ -1346,6 +1358,8 @@ 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) @@ -1391,7 +1405,6 @@ 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 @@ -1402,6 +1415,8 @@ 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) @@ -1433,7 +1448,6 @@ 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 @@ -1444,6 +1458,8 @@ 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) @@ -1489,7 +1505,6 @@ 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 @@ -1500,6 +1515,8 @@ 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) @@ -1531,7 +1548,6 @@ 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 @@ -1542,6 +1558,8 @@ 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) @@ -1586,7 +1604,6 @@ 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 @@ -1597,6 +1614,8 @@ 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) @@ -1630,7 +1649,6 @@ 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 @@ -1641,6 +1659,8 @@ 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) @@ -1680,7 +1700,6 @@ 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 @@ -1691,6 +1710,8 @@ 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) @@ -1739,7 +1760,6 @@ 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 @@ -1750,6 +1770,8 @@ 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) @@ -1785,7 +1807,6 @@ 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 @@ -1796,6 +1817,8 @@ 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) @@ -1847,7 +1870,6 @@ 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 @@ -1858,6 +1880,8 @@ 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) @@ -1893,7 +1917,6 @@ 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 @@ -1904,6 +1927,8 @@ 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) @@ -1950,7 +1975,6 @@ 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 @@ -1961,6 +1985,8 @@ 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) @@ -1992,7 +2018,6 @@ 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 @@ -2003,6 +2028,8 @@ 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) @@ -2039,7 +2066,6 @@ 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 @@ -2050,6 +2076,8 @@ 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) @@ -2085,7 +2113,6 @@ 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 @@ -2096,6 +2123,8 @@ 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) @@ -2142,7 +2171,6 @@ 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 @@ -2153,6 +2181,8 @@ 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) @@ -2185,7 +2215,6 @@ 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 @@ -2196,6 +2225,8 @@ 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) @@ -2242,7 +2273,6 @@ 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 @@ -2253,6 +2283,8 @@ 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 deleted file mode 100644 index 0dafe0e287f..00000000000 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 9e579d9a259..1bcbfe01560 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,12 +18,10 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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, @@ -92,7 +90,6 @@ 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 @@ -103,6 +100,8 @@ 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) @@ -149,7 +148,6 @@ 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 @@ -160,6 +158,8 @@ 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,7 +209,6 @@ 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 @@ -220,6 +219,8 @@ 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 7c1fdb8fa49..d29920cfa70 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,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 @@ -149,7 +147,6 @@ 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 @@ -160,6 +157,8 @@ 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) @@ -206,7 +205,6 @@ 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 @@ -217,6 +215,8 @@ 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,7 +266,6 @@ 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 @@ -277,6 +276,8 @@ 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)