Skip to content

Commit

Permalink
expose kwargs decompress for binary response (#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
msyyc committed Jul 9, 2024
1 parent edede52 commit c2d5b70
Show file tree
Hide file tree
Showing 47 changed files with 553 additions and 311 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/add-kwargs-decompress-2024-6-4-15-43-46.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: feature
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Expose kwargs `decompress` for API whose response type is binary
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ async def _test_lro_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -158,10 +159,10 @@ async def _test_lro_initial(
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

if response.status_code == 200:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if response.status_code == 204:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -293,6 +294,7 @@ async def _test_lro_and_paging_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -305,7 +307,7 @@ async def _test_lro_and_paging_initial(
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def _test_lro_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -236,10 +237,10 @@ def _test_lro_initial(
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

if response.status_code == 200:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if response.status_code == 204:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -368,6 +369,7 @@ def _test_lro_and_paging_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -380,7 +382,7 @@ def _test_lro_and_paging_initial(
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,7 @@ async def _get_multiple_pages_lro_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -1579,7 +1580,7 @@ async def _get_multiple_pages_lro_initial(
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,7 @@ def _get_multiple_pages_lro_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -2038,7 +2039,7 @@ def _get_multiple_pages_lro_initial(
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async def _put_async_retry_succeeded_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -117,7 +118,7 @@ async def _put_async_retry_succeeded_initial(
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -269,6 +270,7 @@ async def _put201_creating_succeeded200_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -282,10 +284,10 @@ async def _put201_creating_succeeded200_initial(
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

if response.status_code == 200:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -429,6 +431,7 @@ async def _post202_retry200_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -445,7 +448,7 @@ async def _post202_retry200_initial(
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -579,6 +582,7 @@ async def _post_async_retry_succeeded_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -598,7 +602,7 @@ async def _post_async_retry_succeeded_initial(
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async def _put201_creating_succeeded200_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -114,10 +115,10 @@ async def _put201_creating_succeeded200_initial(
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

if response.status_code == 200:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

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

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -258,6 +259,7 @@ async def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-t
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -277,7 +279,7 @@ async def _put_async_relative_retry_succeeded_initial( # pylint: disable=name-t
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -411,6 +413,7 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -425,13 +428,13 @@ async def _delete_provisioning202_accepted200_succeeded_initial( # pylint: disa

response_headers = {}
if response.status_code == 200:
deserialized = response.stream_download(self._client._pipeline)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -508,6 +511,7 @@ async def _delete202_retry200_initial(self, **kwargs: Any) -> AsyncIterator[byte
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -524,7 +528,7 @@ async def _delete202_retry200_initial(self, **kwargs: Any) -> AsyncIterator[byte
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -595,6 +599,7 @@ async def _delete_async_relative_retry_succeeded_initial( # pylint: disable=nam
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -614,7 +619,7 @@ async def _delete_async_relative_retry_succeeded_initial( # pylint: disable=nam
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -702,6 +707,7 @@ async def _post202_retry200_initial(
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -718,7 +724,7 @@ async def _post202_retry200_initial(
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down Expand Up @@ -849,6 +855,7 @@ async def _post_async_relative_retry_succeeded_initial( # pylint: disable=name-
)
_request.url = self._client.format_url(_request.url)

_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
Expand All @@ -868,7 +875,7 @@ async def _post_async_relative_retry_succeeded_initial( # pylint: disable=name-
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

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

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
Expand Down
Loading

0 comments on commit c2d5b70

Please sign in to comment.