Compare commits

...

5 Commits
master ... dev

Author SHA1 Message Date
4195edfcd2
Fixed tasks 2024-03-12 13:59:23 +01:00
d76107222b
Extra . removed 2024-03-12 13:07:11 +01:00
99a19a3688
Update library README 2024-03-12 13:06:37 +01:00
35aa61a83a
Updated to PhotosAPI v0.6.0 2024-03-12 12:57:10 +01:00
3ab55ca96f
Project restructure 2024-03-12 12:42:52 +01:00
66 changed files with 1592 additions and 1190 deletions

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ dmypy.json
/coverage.xml
/.coverage
.vscode
.vscode/*
!.vscode/tasks.json

53
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,53 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"linux": {
"command": "bash",
"args": [
"./.venv/bin/python -m build ./PhotosAPI_Client"
]
},
"windows": {
"command": ".\\.venv\\Scripts\\python -m build .\\PhotosAPI_Client"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Generate",
"type": "shell",
"linux": {
"command": "bash",
"args": [
"./.venv/bin/activate && ./.venv/bin/openapi-python-client generate --config ./config.yaml --url \"https://photos.end-play.xyz/openapi.json\""
]
},
"windows": {
"command": ".\\.venv\\Scripts\\activate.ps1; .\\.venv\\Scripts\\openapi-python-client generate --config .\\config.yaml --url \"https://photos.end-play.xyz/openapi.json\""
},
"problemMatcher": []
},
{
"label": "Update",
"type": "shell",
"linux": {
"command": "bash",
"args": [
"./.venv/bin/activate && ./.venv/bin/openapi-python-client update --config ./config.yaml --url \"https://photos.end-play.xyz/openapi.json\""
]
},
"windows": {
"command": ".\\.venv\\Scripts\\activate.ps1; .\\.venv\\Scripts\\openapi-python-client update --config .\\config.yaml --url \"https://photos.end-play.xyz/openapi.json\""
},
"problemMatcher": []
}
]
}

23
PhotosAPI_Client/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
__pycache__/
build/
dist/
*.egg-info/
.pytest_cache/
# pyenv
.python-version
# Environments
.env
.venv
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# JetBrains
.idea/
/coverage.xml
/.coverage

View File

@ -0,0 +1,78 @@
# PhotosAPI_Client
A client library for accessing Photos API
## Usage
First, create a client:
```python
from photosapi_client import Client
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
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
```
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
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
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
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
```python
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl="/path/to/certificate_bundle.pem",
)
```
You can also disable certificate validation altogether, but beware that **this is a security risk**.
```python
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl=False
)
```
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info.
Things to know:
1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `asyncio`: Like `sync` but async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
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`

View File

@ -1,4 +1,5 @@
""" A client library for accessing END PLAY Photos """
from .client import AuthenticatedClient, Client
__all__ = (

View File

@ -12,34 +12,30 @@ from ...types import UNSET, Response
def _get_kwargs(
*,
client: AuthenticatedClient,
name: str,
title: str,
) -> Dict[str, Any]:
url = "{}/albums".format(client.base_url)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
params: Dict[str, Any] = {}
params["name"] = name
params["title"] = title
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
_kwargs: Dict[str, Any] = {
"method": "post",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/albums",
"params": params,
}
return _kwargs
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Album, Any, HTTPValidationError]]:
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Album, Any, HTTPValidationError]]:
if response.status_code == HTTPStatus.OK:
response_200 = Album.from_dict(response.json())
@ -60,7 +56,9 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
return None
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Album, Any, HTTPValidationError]]:
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Album, Any, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@ -92,13 +90,11 @@ def sync_detailed(
"""
kwargs = _get_kwargs(
client=client,
name=name,
title=title,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -157,13 +153,11 @@ async def asyncio_detailed(
"""
kwargs = _get_kwargs(
client=client,
name=name,
title=title,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View File

@ -11,25 +11,21 @@ from ...types import Response
def _get_kwargs(
id: str,
*,
client: AuthenticatedClient,
) -> Dict[str, Any]:
url = "{}/album/{id}".format(client.base_url, id=id)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
return {
_kwargs: Dict[str, Any] = {
"method": "delete",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/album/{id}".format(
id=id,
),
}
return _kwargs
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, HTTPValidationError]]:
if response.status_code == HTTPStatus.NO_CONTENT:
response_204 = cast(Any, None)
return response_204
@ -46,7 +42,9 @@ 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: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@ -77,11 +75,9 @@ def sync_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -136,11 +132,9 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View File

@ -12,32 +12,26 @@ from ...types import UNSET, Response
def _get_kwargs(
*,
client: AuthenticatedClient,
q: str,
) -> Dict[str, Any]:
url = "{}/albums".format(client.base_url)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
params: Dict[str, Any] = {}
params["q"] = q
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
_kwargs: Dict[str, Any] = {
"method": "get",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/albums",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[HTTPValidationError, SearchResultsAlbum]]:
if response.status_code == HTTPStatus.OK:
response_200 = SearchResultsAlbum.from_dict(response.json())
@ -54,7 +48,7 @@ def _parse_response(
def _build_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[HTTPValidationError, SearchResultsAlbum]]:
return Response(
status_code=HTTPStatus(response.status_code),
@ -85,12 +79,10 @@ def sync_detailed(
"""
kwargs = _get_kwargs(
client=client,
q=q,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -144,12 +136,10 @@ async def asyncio_detailed(
"""
kwargs = _get_kwargs(
client=client,
q=q,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View File

@ -13,38 +13,49 @@ from ...types import UNSET, Response, Unset
def _get_kwargs(
id: str,
*,
client: AuthenticatedClient,
name: Union[Unset, None, str] = UNSET,
title: Union[Unset, None, str] = UNSET,
cover: Union[Unset, None, str] = UNSET,
name: Union[None, Unset, str] = UNSET,
title: Union[None, Unset, str] = UNSET,
cover: Union[None, Unset, str] = UNSET,
) -> Dict[str, Any]:
url = "{}/albums/{id}".format(client.base_url, id=id)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
params: Dict[str, Any] = {}
params["name"] = name
params["title"] = title
json_name: Union[None, Unset, str]
if isinstance(name, Unset):
json_name = UNSET
else:
json_name = name
params["name"] = json_name
params["cover"] = cover
json_title: Union[None, Unset, str]
if isinstance(title, Unset):
json_title = UNSET
else:
json_title = title
params["title"] = json_title
json_cover: Union[None, Unset, str]
if isinstance(cover, Unset):
json_cover = UNSET
else:
json_cover = cover
params["cover"] = json_cover
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
_kwargs: Dict[str, Any] = {
"method": "patch",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/albums/{id}".format(
id=id,
),
"params": params,
}
return _kwargs
def _parse_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[AlbumModified, Any, HTTPValidationError]]:
if response.status_code == HTTPStatus.OK:
response_200 = AlbumModified.from_dict(response.json())
@ -67,7 +78,7 @@ def _parse_response(
def _build_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[AlbumModified, Any, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
@ -81,9 +92,9 @@ def sync_detailed(
id: str,
*,
client: AuthenticatedClient,
name: Union[Unset, None, str] = UNSET,
title: Union[Unset, None, str] = UNSET,
cover: Union[Unset, None, str] = UNSET,
name: Union[None, Unset, str] = UNSET,
title: Union[None, Unset, str] = UNSET,
cover: Union[None, Unset, str] = UNSET,
) -> Response[Union[AlbumModified, Any, HTTPValidationError]]:
"""Album Patch
@ -91,9 +102,9 @@ def sync_detailed(
Args:
id (str):
name (Union[Unset, None, str]):
title (Union[Unset, None, str]):
cover (Union[Unset, None, str]):
name (Union[None, Unset, str]):
title (Union[None, Unset, str]):
cover (Union[None, Unset, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -105,14 +116,12 @@ def sync_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
name=name,
title=title,
cover=cover,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -123,9 +132,9 @@ def sync(
id: str,
*,
client: AuthenticatedClient,
name: Union[Unset, None, str] = UNSET,
title: Union[Unset, None, str] = UNSET,
cover: Union[Unset, None, str] = UNSET,
name: Union[None, Unset, str] = UNSET,
title: Union[None, Unset, str] = UNSET,
cover: Union[None, Unset, str] = UNSET,
) -> Optional[Union[AlbumModified, Any, HTTPValidationError]]:
"""Album Patch
@ -133,9 +142,9 @@ def sync(
Args:
id (str):
name (Union[Unset, None, str]):
title (Union[Unset, None, str]):
cover (Union[Unset, None, str]):
name (Union[None, Unset, str]):
title (Union[None, Unset, str]):
cover (Union[None, Unset, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -158,9 +167,9 @@ async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
name: Union[Unset, None, str] = UNSET,
title: Union[Unset, None, str] = UNSET,
cover: Union[Unset, None, str] = UNSET,
name: Union[None, Unset, str] = UNSET,
title: Union[None, Unset, str] = UNSET,
cover: Union[None, Unset, str] = UNSET,
) -> Response[Union[AlbumModified, Any, HTTPValidationError]]:
"""Album Patch
@ -168,9 +177,9 @@ async def asyncio_detailed(
Args:
id (str):
name (Union[Unset, None, str]):
title (Union[Unset, None, str]):
cover (Union[Unset, None, str]):
name (Union[None, Unset, str]):
title (Union[None, Unset, str]):
cover (Union[None, Unset, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -182,14 +191,12 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
name=name,
title=title,
cover=cover,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
@ -198,9 +205,9 @@ async def asyncio(
id: str,
*,
client: AuthenticatedClient,
name: Union[Unset, None, str] = UNSET,
title: Union[Unset, None, str] = UNSET,
cover: Union[Unset, None, str] = UNSET,
name: Union[None, Unset, str] = UNSET,
title: Union[None, Unset, str] = UNSET,
cover: Union[None, Unset, str] = UNSET,
) -> Optional[Union[AlbumModified, Any, HTTPValidationError]]:
"""Album Patch
@ -208,9 +215,9 @@ async def asyncio(
Args:
id (str):
name (Union[Unset, None, str]):
title (Union[Unset, None, str]):
cover (Union[Unset, None, str]):
name (Union[None, Unset, str]):
title (Union[None, Unset, str]):
cover (Union[None, Unset, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

View File

@ -13,17 +13,13 @@ from ...types import UNSET, Response
def _get_kwargs(
id: str,
*,
client: AuthenticatedClient,
name: str,
title: str,
cover: str,
) -> Dict[str, Any]:
url = "{}/albums/{id}".format(client.base_url, id=id)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
params: Dict[str, Any] = {}
params["name"] = name
params["title"] = title
@ -32,19 +28,19 @@ def _get_kwargs(
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
_kwargs: Dict[str, Any] = {
"method": "put",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/albums/{id}".format(
id=id,
),
"params": params,
}
return _kwargs
def _parse_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[AlbumModified, Any, HTTPValidationError]]:
if response.status_code == HTTPStatus.OK:
response_200 = AlbumModified.from_dict(response.json())
@ -67,7 +63,7 @@ def _parse_response(
def _build_response(
*, client: Client, response: httpx.Response
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[AlbumModified, Any, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
@ -105,14 +101,12 @@ def sync_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
name=name,
title=title,
cover=cover,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -182,14 +176,12 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
name=name,
title=title,
cover=cover,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View File

@ -4,7 +4,7 @@ from typing import Any, Dict, Optional, Union, cast
import httpx
from ... import errors
from ...client import Client
from ...client import AuthenticatedClient, Client
from ...models.body_login_for_access_token_token_post import BodyLoginForAccessTokenTokenPost
from ...models.http_validation_error import HTTPValidationError
from ...models.token import Token
@ -13,26 +13,27 @@ from ...types import Response
def _get_kwargs(
*,
client: Client,
form_data: BodyLoginForAccessTokenTokenPost,
body: BodyLoginForAccessTokenTokenPost,
) -> Dict[str, Any]:
url = "{}/token".format(client.base_url)
headers: Dict[str, Any] = {}
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
return {
_kwargs: Dict[str, Any] = {
"method": "post",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"data": form_data.to_dict(),
"url": "/token",
}
_body = body.to_dict()
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError, Token]]:
_kwargs["data"] = _body
headers["Content-Type"] = "application/x-www-form-urlencoded"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, HTTPValidationError, Token]]:
if response.status_code == HTTPStatus.OK:
response_200 = Token.from_dict(response.json())
@ -50,7 +51,9 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
return None
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError, Token]]:
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, HTTPValidationError, Token]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@ -61,11 +64,14 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Uni
def sync_detailed(
*,
client: Client,
form_data: BodyLoginForAccessTokenTokenPost,
client: Union[AuthenticatedClient, Client],
body: BodyLoginForAccessTokenTokenPost,
) -> Response[Union[Any, HTTPValidationError, Token]]:
"""Login For Access Token
Args:
body (BodyLoginForAccessTokenTokenPost):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
@ -75,12 +81,10 @@ def sync_detailed(
"""
kwargs = _get_kwargs(
client=client,
form_data=form_data,
body=body,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -89,11 +93,14 @@ def sync_detailed(
def sync(
*,
client: Client,
form_data: BodyLoginForAccessTokenTokenPost,
client: Union[AuthenticatedClient, Client],
body: BodyLoginForAccessTokenTokenPost,
) -> Optional[Union[Any, HTTPValidationError, Token]]:
"""Login For Access Token
Args:
body (BodyLoginForAccessTokenTokenPost):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
@ -104,17 +111,20 @@ def sync(
return sync_detailed(
client=client,
form_data=form_data,
body=body,
).parsed
async def asyncio_detailed(
*,
client: Client,
form_data: BodyLoginForAccessTokenTokenPost,
client: Union[AuthenticatedClient, Client],
body: BodyLoginForAccessTokenTokenPost,
) -> Response[Union[Any, HTTPValidationError, Token]]:
"""Login For Access Token
Args:
body (BodyLoginForAccessTokenTokenPost):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
@ -124,23 +134,24 @@ async def asyncio_detailed(
"""
kwargs = _get_kwargs(
client=client,
form_data=form_data,
body=body,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: Client,
form_data: BodyLoginForAccessTokenTokenPost,
client: Union[AuthenticatedClient, Client],
body: BodyLoginForAccessTokenTokenPost,
) -> Optional[Union[Any, HTTPValidationError, Token]]:
"""Login For Access Token
Args:
body (BodyLoginForAccessTokenTokenPost):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
@ -152,6 +163,6 @@ async def asyncio(
return (
await asyncio_detailed(
client=client,
form_data=form_data,
body=body,
)
).parsed

View File

@ -11,25 +11,21 @@ from ...types import Response
def _get_kwargs(
id: str,
*,
client: AuthenticatedClient,
) -> Dict[str, Any]:
url = "{}/photos/{id}".format(client.base_url, id=id)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
return {
_kwargs: Dict[str, Any] = {
"method": "delete",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/photos/{id}".format(
id=id,
),
}
return _kwargs
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, HTTPValidationError]]:
if response.status_code == HTTPStatus.NO_CONTENT:
response_204 = cast(Any, None)
return response_204
@ -46,7 +42,9 @@ 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: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@ -77,11 +75,9 @@ def sync_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -136,11 +132,9 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
id=id,
client=client,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View File

@ -12,52 +12,80 @@ from ...types import UNSET, Response, Unset
def _get_kwargs(
album: str,
*,
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,
lng: Union[Unset, None, float] = UNSET,
radius: Union[Unset, None, int] = UNSET,
q: Union[None, Unset, str] = UNSET,
caption: Union[None, Unset, str] = UNSET,
token: Union[None, Unset, str] = UNSET,
page: Union[Unset, int] = 1,
page_size: Union[Unset, int] = 100,
lat: Union[None, Unset, float] = UNSET,
lng: Union[None, Unset, float] = UNSET,
radius: Union[None, Unset, int] = UNSET,
) -> Dict[str, Any]:
url = "{}/albums/{album}/photos".format(client.base_url, album=album)
headers: Dict[str, str] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
params: Dict[str, Any] = {}
params["q"] = q
params["caption"] = caption
json_q: Union[None, Unset, str]
if isinstance(q, Unset):
json_q = UNSET
else:
json_q = q
params["q"] = json_q
params["token"] = token
json_caption: Union[None, Unset, str]
if isinstance(caption, Unset):
json_caption = UNSET
else:
json_caption = caption
params["caption"] = json_caption
json_token: Union[None, Unset, str]
if isinstance(token, Unset):
json_token = UNSET
else:
json_token = token
params["token"] = json_token
params["page"] = page
params["page_size"] = page_size
params["lat"] = lat
json_lat: Union[None, Unset, float]
if isinstance(lat, Unset):
json_lat = UNSET
else:
json_lat = lat
params["lat"] = json_lat
params["lng"] = lng
json_lng: Union[None, Unset, float]
if isinstance(lng, Unset):
json_lng = UNSET
else:
json_lng = lng
params["lng"] = json_lng
params["radius"] = radius
json_radius: Union[None, Unset, int]
if isinstance(radius, Unset):
json_radius = UNSET
else:
json_radius = radius
params["radius"] = json_radius
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
_kwargs: Dict[str, Any] = {
"method": "get",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"url": "/albums/{album}/photos".format(
album=album,
),
"params": params,
}
return _kwargs
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, SearchResultsPhoto]]:
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, SearchResultsPhoto]]:
if response.status_code == HTTPStatus.OK:
response_200 = SearchResultsPhoto.from_dict(response.json())
@ -80,7 +108,9 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
return None
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, SearchResultsPhoto]]:
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, SearchResultsPhoto]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@ -93,14 +123,14 @@ def sync_detailed(
album: str,
*,
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,
lng: Union[Unset, None, float] = UNSET,
radius: Union[Unset, None, int] = UNSET,
q: Union[None, Unset, str] = UNSET,
caption: Union[None, Unset, str] = UNSET,
token: Union[None, Unset, str] = UNSET,
page: Union[Unset, int] = 1,
page_size: Union[Unset, int] = 100,
lat: Union[None, Unset, float] = UNSET,
lng: Union[None, Unset, float] = UNSET,
radius: Union[None, Unset, int] = UNSET,
) -> Response[Union[Any, SearchResultsPhoto]]:
"""Photo Find
@ -108,14 +138,14 @@ def sync_detailed(
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]):
lng (Union[Unset, None, float]):
radius (Union[Unset, None, int]):
q (Union[None, Unset, str]):
caption (Union[None, Unset, str]):
token (Union[None, Unset, str]):
page (Union[Unset, int]): Default: 1.
page_size (Union[Unset, int]): Default: 100.
lat (Union[None, Unset, float]):
lng (Union[None, Unset, float]):
radius (Union[None, Unset, int]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -127,7 +157,6 @@ def sync_detailed(
kwargs = _get_kwargs(
album=album,
client=client,
q=q,
caption=caption,
token=token,
@ -138,8 +167,7 @@ def sync_detailed(
radius=radius,
)
response = httpx.request(
verify=client.verify_ssl,
response = client.get_httpx_client().request(
**kwargs,
)
@ -150,14 +178,14 @@ def sync(
album: str,
*,
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,
lng: Union[Unset, None, float] = UNSET,
radius: Union[Unset, None, int] = UNSET,
q: Union[None, Unset, str] = UNSET,
caption: Union[None, Unset, str] = UNSET,
token: Union[None, Unset, str] = UNSET,
page: Union[Unset, int] = 1,
page_size: Union[Unset, int] = 100,
lat: Union[None, Unset, float] = UNSET,
lng: Union[None, Unset, float] = UNSET,
radius: Union[None, Unset, int] = UNSET,
) -> Optional[Union[Any, SearchResultsPhoto]]:
"""Photo Find
@ -165,14 +193,14 @@ def sync(
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]):
lng (Union[Unset, None, float]):
radius (Union[Unset, None, int]):
q (Union[None, Unset, str]):
caption (Union[None, Unset, str]):
token (Union[None, Unset, str]):
page (Union[Unset, int]): Default: 1.
page_size (Union[Unset, int]): Default: 100.
lat (Union[None, Unset, float]):
lng (Union[None, Unset, float]):
radius (Union[None, Unset, int]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -200,14 +228,14 @@ async def asyncio_detailed(
album: str,
*,
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,
lng: Union[Unset, None, float] = UNSET,
radius: Union[Unset, None, int] = UNSET,
q: Union[None, Unset, str] = UNSET,
caption: Union[None, Unset, str] = UNSET,
token: Union[None, Unset, str] = UNSET,
page: Union[Unset, int] = 1,
page_size: Union[Unset, int] = 100,
lat: Union[None, Unset, float] = UNSET,
lng: Union[None, Unset, float] = UNSET,
radius: Union[None, Unset, int] = UNSET,
) -> Response[Union[Any, SearchResultsPhoto]]:
"""Photo Find
@ -215,14 +243,14 @@ async def asyncio_detailed(
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]):
lng (Union[Unset, None, float]):
radius (Union[Unset, None, int]):
q (Union[None, Unset, str]):
caption (Union[None, Unset, str]):
token (Union[None, Unset, str]):
page (Union[Unset, int]): Default: 1.
page_size (Union[Unset, int]): Default: 100.
lat (Union[None, Unset, float]):
lng (Union[None, Unset, float]):
radius (Union[None, Unset, int]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@ -234,7 +262,6 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
album=album,