Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
37fb483ddf | |||
dc55b70536 | |||
c88eab236b | |||
f661f86533 | |||
18b5b998a8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,3 +21,4 @@ dmypy.json
|
||||
|
||||
/coverage.xml
|
||||
/.coverage
|
||||
.vscode
|
20
README.md
20
README.md
@@ -1,11 +1,11 @@
|
||||
# PhotosAPI_Client
|
||||
A client library for accessing END PLAY Photos
|
||||
A client library for accessing Photos API
|
||||
|
||||
## Usage
|
||||
First, create a client:
|
||||
|
||||
```python
|
||||
from PhotosAPI_Client import Client
|
||||
from photosapi_client import Client
|
||||
|
||||
client = Client(base_url="https://api.example.com")
|
||||
```
|
||||
@@ -13,7 +13,7 @@ client = Client(base_url="https://api.example.com")
|
||||
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
||||
|
||||
```python
|
||||
from PhotosAPI_Client import AuthenticatedClient
|
||||
from photosapi_client import AuthenticatedClient
|
||||
|
||||
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
||||
```
|
||||
@@ -21,9 +21,9 @@ client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSec
|
||||
Now call your endpoint and use your models:
|
||||
|
||||
```python
|
||||
from PhotosAPI_Client.models import MyDataModel
|
||||
from PhotosAPI_Client.api.my_tag import get_my_data_model
|
||||
from PhotosAPI_Client.types import Response
|
||||
from photosapi_client.models import MyDataModel
|
||||
from photosapi_client.api.my_tag import get_my_data_model
|
||||
from photosapi_client.types import Response
|
||||
|
||||
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
||||
# or if you need more info (e.g. status_code)
|
||||
@@ -33,9 +33,9 @@ response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
||||
Or do the same thing with an async version:
|
||||
|
||||
```python
|
||||
from PhotosAPI_Client.models import MyDataModel
|
||||
from PhotosAPI_Client.api.my_tag import get_my_data_model
|
||||
from PhotosAPI_Client.types import Response
|
||||
from photosapi_client.models import MyDataModel
|
||||
from photosapi_client.api.my_tag import get_my_data_model
|
||||
from photosapi_client.types import Response
|
||||
|
||||
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
||||
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
||||
@@ -72,7 +72,7 @@ Things to know:
|
||||
|
||||
1. All path/query params, and bodies become method arguments.
|
||||
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
||||
1. Any endpoint which did not have a tag will be in `PhotosAPI_Client.api.default`
|
||||
1. Any endpoint which did not have a tag will be in `photosapi_client.api.default`
|
||||
|
||||
## Building / publishing this Client
|
||||
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
||||
|
@@ -15,6 +15,7 @@ def _get_kwargs(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
lat: Union[Unset, None, float] = UNSET,
|
||||
@@ -31,6 +32,8 @@ def _get_kwargs(
|
||||
|
||||
params["caption"] = caption
|
||||
|
||||
params["token"] = token
|
||||
|
||||
params["page"] = page
|
||||
|
||||
params["page_size"] = page_size
|
||||
@@ -61,6 +64,9 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
|
||||
if response.status_code == HTTPStatus.BAD_REQUEST:
|
||||
response_400 = cast(Any, None)
|
||||
return response_400
|
||||
if response.status_code == HTTPStatus.UNAUTHORIZED:
|
||||
response_401 = cast(Any, None)
|
||||
return response_401
|
||||
if response.status_code == HTTPStatus.NOT_FOUND:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
@@ -88,6 +94,7 @@ def sync_detailed(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
lat: Union[Unset, None, float] = UNSET,
|
||||
@@ -96,12 +103,13 @@ def sync_detailed(
|
||||
) -> Response[Union[Any, SearchResultsPhoto]]:
|
||||
"""Photo Find
|
||||
|
||||
Find a photo by filename
|
||||
Find a photo by filename, caption, location or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
lat (Union[Unset, None, float]):
|
||||
@@ -121,6 +129,7 @@ def sync_detailed(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
lat=lat,
|
||||
@@ -142,6 +151,7 @@ def sync(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
lat: Union[Unset, None, float] = UNSET,
|
||||
@@ -150,12 +160,13 @@ def sync(
|
||||
) -> Optional[Union[Any, SearchResultsPhoto]]:
|
||||
"""Photo Find
|
||||
|
||||
Find a photo by filename
|
||||
Find a photo by filename, caption, location or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
lat (Union[Unset, None, float]):
|
||||
@@ -175,6 +186,7 @@ def sync(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
lat=lat,
|
||||
@@ -189,6 +201,7 @@ async def asyncio_detailed(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
lat: Union[Unset, None, float] = UNSET,
|
||||
@@ -197,12 +210,13 @@ async def asyncio_detailed(
|
||||
) -> Response[Union[Any, SearchResultsPhoto]]:
|
||||
"""Photo Find
|
||||
|
||||
Find a photo by filename
|
||||
Find a photo by filename, caption, location or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
lat (Union[Unset, None, float]):
|
||||
@@ -222,6 +236,7 @@ async def asyncio_detailed(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
lat=lat,
|
||||
@@ -241,6 +256,7 @@ async def asyncio(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
lat: Union[Unset, None, float] = UNSET,
|
||||
@@ -249,12 +265,13 @@ async def asyncio(
|
||||
) -> Optional[Union[Any, SearchResultsPhoto]]:
|
||||
"""Photo Find
|
||||
|
||||
Find a photo by filename
|
||||
Find a photo by filename, caption, location or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
lat (Union[Unset, None, float]):
|
||||
@@ -275,6 +292,7 @@ async def asyncio(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
lat=lat,
|
@@ -15,6 +15,7 @@ def _get_kwargs(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
) -> Dict[str, Any]:
|
||||
@@ -28,6 +29,8 @@ def _get_kwargs(
|
||||
|
||||
params["caption"] = caption
|
||||
|
||||
params["token"] = token
|
||||
|
||||
params["page"] = page
|
||||
|
||||
params["page_size"] = page_size
|
||||
@@ -52,6 +55,9 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
|
||||
if response.status_code == HTTPStatus.BAD_REQUEST:
|
||||
response_400 = cast(Any, None)
|
||||
return response_400
|
||||
if response.status_code == HTTPStatus.UNAUTHORIZED:
|
||||
response_401 = cast(Any, None)
|
||||
return response_401
|
||||
if response.status_code == HTTPStatus.NOT_FOUND:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
@@ -79,17 +85,19 @@ def sync_detailed(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
) -> Response[Union[Any, SearchResultsVideo]]:
|
||||
"""Video Find
|
||||
|
||||
Find a video by filename
|
||||
Find a video by filename, caption or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
|
||||
@@ -106,6 +114,7 @@ def sync_detailed(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
)
|
||||
@@ -124,17 +133,19 @@ def sync(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
) -> Optional[Union[Any, SearchResultsVideo]]:
|
||||
"""Video Find
|
||||
|
||||
Find a video by filename
|
||||
Find a video by filename, caption or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
|
||||
@@ -151,6 +162,7 @@ def sync(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
).parsed
|
||||
@@ -162,17 +174,19 @@ async def asyncio_detailed(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
) -> Response[Union[Any, SearchResultsVideo]]:
|
||||
"""Video Find
|
||||
|
||||
Find a video by filename
|
||||
Find a video by filename, caption or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
|
||||
@@ -189,6 +203,7 @@ async def asyncio_detailed(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
)
|
||||
@@ -205,17 +220,19 @@ async def asyncio(
|
||||
client: AuthenticatedClient,
|
||||
q: Union[Unset, None, str] = UNSET,
|
||||
caption: Union[Unset, None, str] = UNSET,
|
||||
token: Union[Unset, None, str] = UNSET,
|
||||
page: Union[Unset, None, int] = 1,
|
||||
page_size: Union[Unset, None, int] = 100,
|
||||
) -> Optional[Union[Any, SearchResultsVideo]]:
|
||||
"""Video Find
|
||||
|
||||
Find a video by filename
|
||||
Find a video by filename, caption or token
|
||||
|
||||
Args:
|
||||
album (str):
|
||||
q (Union[Unset, None, str]):
|
||||
caption (Union[Unset, None, str]):
|
||||
token (Union[Unset, None, str]):
|
||||
page (Union[Unset, None, int]): Default: 1.
|
||||
page_size (Union[Unset, None, int]): Default: 100.
|
||||
|
||||
@@ -233,6 +250,7 @@ async def asyncio(
|
||||
client=client,
|
||||
q=q,
|
||||
caption=caption,
|
||||
token=token,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
)
|
6
setup.py
6
setup.py
@@ -7,12 +7,12 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
|
||||
|
||||
setup(
|
||||
name="PhotosAPI_Client",
|
||||
version="0.1",
|
||||
description="A client library for accessing END PLAY Photos",
|
||||
version="0.2.0",
|
||||
description="A client library for accessing Photos API",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
packages=find_packages(),
|
||||
python_requires=">=3.7, <4",
|
||||
install_requires=["httpx >= 0.15.0, < 0.24.0", "attrs >= 21.3.0", "python-dateutil >= 2.8.0, < 3"],
|
||||
package_data={"PhotosAPI_Client": ["py.typed"]},
|
||||
package_data={"photosapi_client": ["py.typed"]},
|
||||
)
|
||||
|
Reference in New Issue
Block a user