diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 00008ff61..b30b9a4d0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,8 +4,8 @@ Changelog Next ---- -2024.09.03.1 ------------- +* Move ``Response`` from ``vws.exceptions.response`` to ``vws.types``. +* Add ``raw`` field to ``Response``. 2024.09.03 ------------ diff --git a/docs/source/api-reference.rst b/docs/source/api-reference.rst index 3ffbc13da..5b7027550 100644 --- a/docs/source/api-reference.rst +++ b/docs/source/api-reference.rst @@ -12,3 +12,7 @@ API Reference .. automodule:: vws.include_target_data :undoc-members: :members: + +.. automodule:: vws.types + :undoc-members: + :members: diff --git a/docs/source/exceptions.rst b/docs/source/exceptions.rst index f23ab02b8..f48730bfd 100644 --- a/docs/source/exceptions.rst +++ b/docs/source/exceptions.rst @@ -36,10 +36,3 @@ Custom exceptions :show-inheritance: :inherited-members: Exception :exclude-members: errno, filename, filename2, strerror - -Response --------- - -.. automodule:: vws.exceptions.response - :undoc-members: - :members: diff --git a/src/vws/exceptions/base_exceptions.py b/src/vws/exceptions/base_exceptions.py index 9dde05ee2..ad1116708 100644 --- a/src/vws/exceptions/base_exceptions.py +++ b/src/vws/exceptions/base_exceptions.py @@ -5,7 +5,7 @@ from beartype import beartype -from .response import Response +from vws.types import Response @beartype diff --git a/src/vws/exceptions/custom_exceptions.py b/src/vws/exceptions/custom_exceptions.py index d036d8750..cb237abd8 100644 --- a/src/vws/exceptions/custom_exceptions.py +++ b/src/vws/exceptions/custom_exceptions.py @@ -6,7 +6,7 @@ from beartype import beartype -from .response import Response +from vws.types import Response @beartype diff --git a/src/vws/query.py b/src/vws/query.py index fc42a3ff5..17382d600 100644 --- a/src/vws/query.py +++ b/src/vws/query.py @@ -25,9 +25,9 @@ RequestEntityTooLargeError, ServerError, ) -from vws.exceptions.response import Response from vws.include_target_data import CloudRecoIncludeTargetData from vws.reports import QueryResult, TargetData +from vws.types import Response _ImageType = io.BytesIO | BinaryIO @@ -154,6 +154,7 @@ def query( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, + raw=requests_response.raw, ) if response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE: diff --git a/src/vws/exceptions/response.py b/src/vws/types.py similarity index 81% rename from src/vws/exceptions/response.py rename to src/vws/types.py index 0b3eced88..3e5e49aaa 100644 --- a/src/vws/exceptions/response.py +++ b/src/vws/types.py @@ -1,4 +1,4 @@ -"""Responses for exceptions.""" +"""Responses for requests to VWS and VWQ.""" from dataclasses import dataclass @@ -17,3 +17,4 @@ class Response: status_code: int headers: dict[str, str] request_body: bytes | str | None + raw: bytes diff --git a/src/vws/vws.py b/src/vws/vws.py index 6f622773f..2acc2ca07 100644 --- a/src/vws/vws.py +++ b/src/vws/vws.py @@ -46,8 +46,7 @@ TargetStatuses, TargetSummaryReport, ) - -from .exceptions.response import Response +from vws.types import Response _ImageType = io.BytesIO | BinaryIO @@ -126,6 +125,7 @@ def _target_api_request( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, + raw=requests_response.raw, )