From d643fde9171b4b4063cfa4db9888d112d10c9b83 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 22 Jun 2023 14:38:42 +0200 Subject: [PATCH] Updated to PhotosAPI v3.0 --- .../api/default/album_create_albums_post.py | 7 ++++--- .../api/default/album_delete_album_id_delete.py | 7 ++++--- photosapi_client/api/default/album_find_albums_get.py | 7 ++++--- .../api/default/album_patch_albums_id_patch.py | 7 ++++--- .../api/default/album_put_albums_id_put.py | 7 ++++--- .../api/default/login_for_access_token_token_post.py | 7 ++++--- .../api/default/photo_delete_photos_id_delete.py | 7 ++++--- .../api/default/photo_find_albums_album_photos_get.py | 7 ++++--- .../api/default/photo_get_photos_id_get.py | 10 ++++------ .../default/photo_get_token_token_photo_token_get.py | 7 ++++--- .../api/default/photo_move_photos_id_put.py | 7 ++++--- .../api/default/photo_patch_photos_id_patch.py | 7 ++++--- .../default/photo_upload_albums_album_photos_post.py | 7 ++++--- .../api/default/user_confirm_users_user_confirm_get.py | 7 ++++--- .../default/user_confirm_users_user_confirm_patch.py | 7 ++++--- photosapi_client/api/default/user_create_users_post.py | 7 ++++--- .../api/default/user_delete_users_me_delete.py | 7 ++++--- photosapi_client/api/default/user_me_users_me_get.py | 7 ++++--- .../api/default/video_delete_videos_id_delete.py | 7 ++++--- .../api/default/video_find_albums_album_videos_get.py | 7 ++++--- .../api/default/video_get_videos_id_get.py | 10 ++++------ .../api/default/video_move_videos_id_put.py | 7 ++++--- .../api/default/video_patch_videos_id_patch.py | 7 ++++--- .../default/video_upload_albums_album_videos_post.py | 7 ++++--- photosapi_client/client.py | 2 ++ photosapi_client/errors.py | 6 +++++- photosapi_client/types.py | 4 ++-- setup.py | 2 +- 28 files changed, 106 insertions(+), 82 deletions(-) diff --git a/photosapi_client/api/default/album_create_albums_post.py b/photosapi_client/api/default/album_create_albums_post.py index 4b884dd..39507a3 100644 --- a/photosapi_client/api/default/album_create_albums_post.py +++ b/photosapi_client/api/default/album_create_albums_post.py @@ -34,6 +34,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -54,7 +55,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -123,7 +124,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Album, Any, HTTPValidationError]] + Union[Album, Any, HTTPValidationError] """ return sync_detailed( @@ -186,7 +187,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Album, Any, HTTPValidationError]] + Union[Album, Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/album_delete_album_id_delete.py b/photosapi_client/api/default/album_delete_album_id_delete.py index f2547f2..bac5cc4 100644 --- a/photosapi_client/api/default/album_delete_album_id_delete.py +++ b/photosapi_client/api/default/album_delete_album_id_delete.py @@ -25,6 +25,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } @@ -40,7 +41,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -104,7 +105,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -161,7 +162,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/album_find_albums_get.py b/photosapi_client/api/default/album_find_albums_get.py index cd3b9e8..de55a69 100644 --- a/photosapi_client/api/default/album_find_albums_get.py +++ b/photosapi_client/api/default/album_find_albums_get.py @@ -31,6 +31,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -47,7 +48,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -113,7 +114,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, SearchResultsAlbum]] + Union[HTTPValidationError, SearchResultsAlbum] """ return sync_detailed( @@ -170,7 +171,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, SearchResultsAlbum]] + Union[HTTPValidationError, SearchResultsAlbum] """ return ( diff --git a/photosapi_client/api/default/album_patch_albums_id_patch.py b/photosapi_client/api/default/album_patch_albums_id_patch.py index 753b318..4591fb6 100644 --- a/photosapi_client/api/default/album_patch_albums_id_patch.py +++ b/photosapi_client/api/default/album_patch_albums_id_patch.py @@ -38,6 +38,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -60,7 +61,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -141,7 +142,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[AlbumModified, Any, HTTPValidationError]] + Union[AlbumModified, Any, HTTPValidationError] """ return sync_detailed( @@ -216,7 +217,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[AlbumModified, Any, HTTPValidationError]] + Union[AlbumModified, Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/album_put_albums_id_put.py b/photosapi_client/api/default/album_put_albums_id_put.py index a06af05..b40677f 100644 --- a/photosapi_client/api/default/album_put_albums_id_put.py +++ b/photosapi_client/api/default/album_put_albums_id_put.py @@ -38,6 +38,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -60,7 +61,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -141,7 +142,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[AlbumModified, Any, HTTPValidationError]] + Union[AlbumModified, Any, HTTPValidationError] """ return sync_detailed( @@ -216,7 +217,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[AlbumModified, Any, HTTPValidationError]] + Union[AlbumModified, Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/login_for_access_token_token_post.py b/photosapi_client/api/default/login_for_access_token_token_post.py index b3c08fb..252b6ea 100644 --- a/photosapi_client/api/default/login_for_access_token_token_post.py +++ b/photosapi_client/api/default/login_for_access_token_token_post.py @@ -27,6 +27,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "data": form_data.to_dict(), } @@ -44,7 +45,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -98,7 +99,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Token]] + Union[Any, HTTPValidationError, Token] """ return sync_detailed( @@ -145,7 +146,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Token]] + Union[Any, HTTPValidationError, Token] """ return ( diff --git a/photosapi_client/api/default/photo_delete_photos_id_delete.py b/photosapi_client/api/default/photo_delete_photos_id_delete.py index cec5287..949a660 100644 --- a/photosapi_client/api/default/photo_delete_photos_id_delete.py +++ b/photosapi_client/api/default/photo_delete_photos_id_delete.py @@ -25,6 +25,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } @@ -40,7 +41,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -104,7 +105,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -161,7 +162,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/photo_find_albums_album_photos_get.py b/photosapi_client/api/default/photo_find_albums_album_photos_get.py index 44475d0..e22c3c8 100644 --- a/photosapi_client/api/default/photo_find_albums_album_photos_get.py +++ b/photosapi_client/api/default/photo_find_albums_album_photos_get.py @@ -52,6 +52,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -74,7 +75,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni response_422 = cast(Any, None) return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -178,7 +179,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, SearchResultsPhoto]] + Union[Any, SearchResultsPhoto] """ return sync_detailed( @@ -283,7 +284,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, SearchResultsPhoto]] + Union[Any, SearchResultsPhoto] """ return ( 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 89e38b2..456afbe 100644 --- a/photosapi_client/api/default/photo_get_photos_id_get.py +++ b/photosapi_client/api/default/photo_get_photos_id_get.py @@ -25,13 +25,11 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == HTTPStatus.OK: - response_200 = cast(Any, response.json()) - return response_200 if response.status_code == HTTPStatus.NOT_FOUND: response_404 = cast(Any, None) return response_404 @@ -40,7 +38,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -104,7 +102,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -161,7 +159,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/photo_get_token_token_photo_token_get.py b/photosapi_client/api/default/photo_get_token_token_photo_token_get.py index 6448275..d72f445 100644 --- a/photosapi_client/api/default/photo_get_token_token_photo_token_get.py +++ b/photosapi_client/api/default/photo_get_token_token_photo_token_get.py @@ -31,6 +31,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -50,7 +51,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -119,7 +120,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -182,7 +183,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/photo_move_photos_id_put.py b/photosapi_client/api/default/photo_move_photos_id_put.py index ada0b43..7908115 100644 --- a/photosapi_client/api/default/photo_move_photos_id_put.py +++ b/photosapi_client/api/default/photo_move_photos_id_put.py @@ -32,6 +32,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -51,7 +52,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -122,7 +123,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, PhotoPublic]] + Union[Any, HTTPValidationError, PhotoPublic] """ return sync_detailed( @@ -185,7 +186,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, PhotoPublic]] + Union[Any, HTTPValidationError, PhotoPublic] """ return ( diff --git a/photosapi_client/api/default/photo_patch_photos_id_patch.py b/photosapi_client/api/default/photo_patch_photos_id_patch.py index 6575b76..ee017b1 100644 --- a/photosapi_client/api/default/photo_patch_photos_id_patch.py +++ b/photosapi_client/api/default/photo_patch_photos_id_patch.py @@ -32,6 +32,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -51,7 +52,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -122,7 +123,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, PhotoPublic]] + Union[Any, HTTPValidationError, PhotoPublic] """ return sync_detailed( @@ -185,7 +186,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, PhotoPublic]] + Union[Any, HTTPValidationError, PhotoPublic] """ return ( diff --git a/photosapi_client/api/default/photo_upload_albums_album_photos_post.py b/photosapi_client/api/default/photo_upload_albums_album_photos_post.py index 21c2df9..1880208 100644 --- a/photosapi_client/api/default/photo_upload_albums_album_photos_post.py +++ b/photosapi_client/api/default/photo_upload_albums_album_photos_post.py @@ -42,6 +42,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "files": multipart_multipart_data, "params": params, } @@ -63,7 +64,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -147,7 +148,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Photo]] + Union[Any, HTTPValidationError, Photo] """ return sync_detailed( @@ -228,7 +229,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Photo]] + Union[Any, HTTPValidationError, Photo] """ return ( diff --git a/photosapi_client/api/default/user_confirm_users_user_confirm_get.py b/photosapi_client/api/default/user_confirm_users_user_confirm_get.py index 07e0e83..4eb10b8 100644 --- a/photosapi_client/api/default/user_confirm_users_user_confirm_get.py +++ b/photosapi_client/api/default/user_confirm_users_user_confirm_get.py @@ -31,6 +31,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -47,7 +48,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -112,7 +113,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -171,7 +172,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/user_confirm_users_user_confirm_patch.py b/photosapi_client/api/default/user_confirm_users_user_confirm_patch.py index 5d1897c..457aab0 100644 --- a/photosapi_client/api/default/user_confirm_users_user_confirm_patch.py +++ b/photosapi_client/api/default/user_confirm_users_user_confirm_patch.py @@ -31,6 +31,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -47,7 +48,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -112,7 +113,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -171,7 +172,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/user_create_users_post.py b/photosapi_client/api/default/user_create_users_post.py index 90d44b0..6f001f5 100644 --- a/photosapi_client/api/default/user_create_users_post.py +++ b/photosapi_client/api/default/user_create_users_post.py @@ -26,6 +26,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "data": form_data.to_dict(), } @@ -42,7 +43,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -96,7 +97,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -143,7 +144,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/user_delete_users_me_delete.py b/photosapi_client/api/default/user_delete_users_me_delete.py index 14097f4..aa91ce6 100644 --- a/photosapi_client/api/default/user_delete_users_me_delete.py +++ b/photosapi_client/api/default/user_delete_users_me_delete.py @@ -26,6 +26,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "data": form_data.to_dict(), } @@ -42,7 +43,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -96,7 +97,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -143,7 +144,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/user_me_users_me_get.py b/photosapi_client/api/default/user_me_users_me_get.py index dffed35..54d7dd7 100644 --- a/photosapi_client/api/default/user_me_users_me_get.py +++ b/photosapi_client/api/default/user_me_users_me_get.py @@ -24,6 +24,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } @@ -33,7 +34,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Use return response_200 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -84,7 +85,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[User] + User """ return sync_detailed( @@ -127,7 +128,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[User] + User """ return ( diff --git a/photosapi_client/api/default/video_delete_videos_id_delete.py b/photosapi_client/api/default/video_delete_videos_id_delete.py index d388c6b..15e3ac0 100644 --- a/photosapi_client/api/default/video_delete_videos_id_delete.py +++ b/photosapi_client/api/default/video_delete_videos_id_delete.py @@ -25,6 +25,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } @@ -40,7 +41,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -104,7 +105,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -161,7 +162,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/video_find_albums_album_videos_get.py b/photosapi_client/api/default/video_find_albums_album_videos_get.py index fa5885c..127f988 100644 --- a/photosapi_client/api/default/video_find_albums_album_videos_get.py +++ b/photosapi_client/api/default/video_find_albums_album_videos_get.py @@ -43,6 +43,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -65,7 +66,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni response_422 = cast(Any, None) return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -154,7 +155,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, SearchResultsVideo]] + Union[Any, SearchResultsVideo] """ return sync_detailed( @@ -241,7 +242,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, SearchResultsVideo]] + Union[Any, SearchResultsVideo] """ 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 da0115e..79146b7 100644 --- a/photosapi_client/api/default/video_get_videos_id_get.py +++ b/photosapi_client/api/default/video_get_videos_id_get.py @@ -25,13 +25,11 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, } def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == HTTPStatus.OK: - response_200 = cast(Any, response.json()) - return response_200 if response.status_code == HTTPStatus.NOT_FOUND: response_404 = cast(Any, None) return response_404 @@ -40,7 +38,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -104,7 +102,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return sync_detailed( @@ -161,7 +159,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError]] + Union[Any, HTTPValidationError] """ return ( diff --git a/photosapi_client/api/default/video_move_videos_id_put.py b/photosapi_client/api/default/video_move_videos_id_put.py index 61a416a..14c08be 100644 --- a/photosapi_client/api/default/video_move_videos_id_put.py +++ b/photosapi_client/api/default/video_move_videos_id_put.py @@ -32,6 +32,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -51,7 +52,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -122,7 +123,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, VideoPublic]] + Union[Any, HTTPValidationError, VideoPublic] """ return sync_detailed( @@ -185,7 +186,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, VideoPublic]] + Union[Any, HTTPValidationError, VideoPublic] """ return ( diff --git a/photosapi_client/api/default/video_patch_videos_id_patch.py b/photosapi_client/api/default/video_patch_videos_id_patch.py index dd4e037..a2e32aa 100644 --- a/photosapi_client/api/default/video_patch_videos_id_patch.py +++ b/photosapi_client/api/default/video_patch_videos_id_patch.py @@ -32,6 +32,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "params": params, } @@ -51,7 +52,7 @@ def _parse_response( return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -122,7 +123,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, VideoPublic]] + Union[Any, HTTPValidationError, VideoPublic] """ return sync_detailed( @@ -185,7 +186,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, VideoPublic]] + Union[Any, HTTPValidationError, VideoPublic] """ return ( diff --git a/photosapi_client/api/default/video_upload_albums_album_videos_post.py b/photosapi_client/api/default/video_upload_albums_album_videos_post.py index 99b7382..b89078b 100644 --- a/photosapi_client/api/default/video_upload_albums_album_videos_post.py +++ b/photosapi_client/api/default/video_upload_albums_album_videos_post.py @@ -36,6 +36,7 @@ def _get_kwargs( "headers": headers, "cookies": cookies, "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, "files": multipart_multipart_data, "params": params, } @@ -54,7 +55,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni return response_422 if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") + raise errors.UnexpectedStatus(response.status_code, response.content) else: return None @@ -128,7 +129,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Video]] + Union[Any, HTTPValidationError, Video] """ return sync_detailed( @@ -197,7 +198,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, HTTPValidationError, Video]] + Union[Any, HTTPValidationError, Video] """ return ( diff --git a/photosapi_client/client.py b/photosapi_client/client.py index 99aeffa..2f45c65 100644 --- a/photosapi_client/client.py +++ b/photosapi_client/client.py @@ -18,6 +18,7 @@ class Client: but can be set to False for testing purposes. raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. + follow_redirects: Whether or not to follow redirects. Default value is False. """ base_url: str @@ -26,6 +27,7 @@ class Client: timeout: float = attr.ib(5.0, kw_only=True) verify_ssl: Union[str, bool, ssl.SSLContext] = attr.ib(True, kw_only=True) raise_on_unexpected_status: bool = attr.ib(False, kw_only=True) + follow_redirects: bool = attr.ib(False, kw_only=True) def get_headers(self) -> Dict[str, str]: """Get headers to be used in all endpoints""" diff --git a/photosapi_client/errors.py b/photosapi_client/errors.py index a508e13..426f8a2 100644 --- a/photosapi_client/errors.py +++ b/photosapi_client/errors.py @@ -4,7 +4,11 @@ class UnexpectedStatus(Exception): """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" - ... + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__(f"Unexpected status code: {status_code}") __all__ = ["UnexpectedStatus"] diff --git a/photosapi_client/types.py b/photosapi_client/types.py index 230efea..599eeb9 100644 --- a/photosapi_client/types.py +++ b/photosapi_client/types.py @@ -1,12 +1,12 @@ """ Contains some shared types for properties """ from http import HTTPStatus -from typing import BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar import attr class Unset: - def __bool__(self) -> bool: + def __bool__(self) -> Literal[False]: return False diff --git a/setup.py b/setup.py index 5c3c7c4..8f9382d 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.2.0", + version="0.3.0", description="A client library for accessing Photos API", long_description=long_description, long_description_content_type="text/markdown",