diff --git a/photosapi_client/api/default/photo_get_photos_id_get.py b/photosapi_client/api/default/photo_get_photos_id_get.py index 456afbe..98c3fa9 100644 --- a/photosapi_client/api/default/photo_get_photos_id_get.py +++ b/photosapi_client/api/default/photo_get_photos_id_get.py @@ -1,4 +1,5 @@ from http import HTTPStatus +from io import BytesIO from typing import Any, Dict, Optional, Union, cast import httpx @@ -6,7 +7,7 @@ import httpx from ... import errors from ...client import AuthenticatedClient, Client from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import File, Response def _get_kwargs( @@ -29,7 +30,11 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, File, HTTPValidationError]]: + if response.status_code == HTTPStatus.OK: + response_200 = File(payload=BytesIO(response.content)) + + return response_200 if response.status_code == HTTPStatus.NOT_FOUND: response_404 = cast(Any, None) return response_404 @@ -43,7 +48,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, File, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,7 +61,7 @@ def sync_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Union[Any, File, HTTPValidationError]]: """Photo Get Get a photo by id @@ -69,7 +74,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Union[Any, File, HTTPValidationError]] """ kwargs = _get_kwargs( @@ -89,7 +94,7 @@ def sync( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Optional[Union[Any, File, HTTPValidationError]]: """Photo Get Get a photo by id @@ -102,7 +107,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, HTTPValidationError] + Union[Any, File, HTTPValidationError] """ return sync_detailed( @@ -115,7 +120,7 @@ async def asyncio_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Union[Any, File, HTTPValidationError]]: """Photo Get Get a photo by id @@ -128,7 +133,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Union[Any, File, HTTPValidationError]] """ kwargs = _get_kwargs( @@ -146,7 +151,7 @@ async def asyncio( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Optional[Union[Any, File, HTTPValidationError]]: """Photo Get Get a photo by id @@ -159,7 +164,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, HTTPValidationError] + Union[Any, File, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/video_get_videos_id_get.py b/photosapi_client/api/default/video_get_videos_id_get.py index 79146b7..9cd9701 100644 --- a/photosapi_client/api/default/video_get_videos_id_get.py +++ b/photosapi_client/api/default/video_get_videos_id_get.py @@ -1,4 +1,5 @@ from http import HTTPStatus +from io import BytesIO from typing import Any, Dict, Optional, Union, cast import httpx @@ -6,7 +7,7 @@ import httpx from ... import errors from ...client import AuthenticatedClient, Client from ...models.http_validation_error import HTTPValidationError -from ...types import Response +from ...types import File, Response def _get_kwargs( @@ -29,7 +30,11 @@ def _get_kwargs( } -def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, File, HTTPValidationError]]: + if response.status_code == HTTPStatus.OK: + response_200 = File(payload=BytesIO(response.content)) + + return response_200 if response.status_code == HTTPStatus.NOT_FOUND: response_404 = cast(Any, None) return response_404 @@ -43,7 +48,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return None -def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, File, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,7 +61,7 @@ def sync_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Union[Any, File, HTTPValidationError]]: """Video Get Get a video by id @@ -69,7 +74,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Union[Any, File, HTTPValidationError]] """ kwargs = _get_kwargs( @@ -89,7 +94,7 @@ def sync( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Optional[Union[Any, File, HTTPValidationError]]: """Video Get Get a video by id @@ -102,7 +107,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, HTTPValidationError] + Union[Any, File, HTTPValidationError] """ return sync_detailed( @@ -115,7 +120,7 @@ async def asyncio_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Any, HTTPValidationError]]: +) -> Response[Union[Any, File, HTTPValidationError]]: """Video Get Get a video by id @@ -128,7 +133,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Response[Union[Any, File, HTTPValidationError]] """ kwargs = _get_kwargs( @@ -146,7 +151,7 @@ async def asyncio( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Any, HTTPValidationError]]: +) -> Optional[Union[Any, File, HTTPValidationError]]: """Video Get Get a video by id @@ -159,7 +164,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, HTTPValidationError] + Union[Any, File, HTTPValidationError] """ return ( diff --git a/setup.py b/setup.py index 8f9382d..e9fc3e9 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8") setup( name="PhotosAPI_Client", - version="0.3.0", + version="0.4.0", description="A client library for accessing Photos API", long_description=long_description, long_description_content_type="text/markdown",