272 lines
8.7 KiB
Python
272 lines
8.7 KiB
Python
from http import HTTPStatus
|
|
from typing import Any, Dict, Optional, Union, cast
|
|
|
|
import httpx
|
|
|
|
from ... import errors
|
|
from ...client import AuthenticatedClient, Client
|
|
from ...models.entry_find_locations_location_entries_get_garbage_type_type_0 import (
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0,
|
|
)
|
|
from ...models.search_results_collection_entry import SearchResultsCollectionEntry
|
|
from ...types import UNSET, Response, Unset
|
|
|
|
|
|
def _get_kwargs(
|
|
location: int,
|
|
*,
|
|
garbage_type: Union[
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset
|
|
] = UNSET,
|
|
date_start: Union[Unset, str] = "2024-04-13T15:39:14.714927",
|
|
date_end: Union[Unset, str] = "2024-05-13T15:39:14.714945",
|
|
page: Union[Unset, int] = 1,
|
|
page_size: Union[Unset, int] = 100,
|
|
) -> Dict[str, Any]:
|
|
|
|
params: Dict[str, Any] = {}
|
|
|
|
json_garbage_type: Union[None, Unset, int]
|
|
if isinstance(garbage_type, Unset):
|
|
json_garbage_type = UNSET
|
|
elif isinstance(garbage_type, EntryFindLocationsLocationEntriesGetGarbageTypeType0):
|
|
json_garbage_type = garbage_type.value
|
|
else:
|
|
json_garbage_type = garbage_type
|
|
params["garbage_type"] = json_garbage_type
|
|
|
|
params["date_start"] = date_start
|
|
|
|
params["date_end"] = date_end
|
|
|
|
params["page"] = page
|
|
|
|
params["page_size"] = page_size
|
|
|
|
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
|
|
_kwargs: Dict[str, Any] = {
|
|
"method": "get",
|
|
"url": "/locations/{location}/entries".format(
|
|
location=location,
|
|
),
|
|
"params": params,
|
|
}
|
|
|
|
return _kwargs
|
|
|
|
|
|
def _parse_response(
|
|
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
) -> Optional[Union[Any, SearchResultsCollectionEntry]]:
|
|
if response.status_code == HTTPStatus.OK:
|
|
response_200 = SearchResultsCollectionEntry.from_dict(response.json())
|
|
|
|
return response_200
|
|
if response.status_code == HTTPStatus.BAD_REQUEST:
|
|
response_400 = cast(Any, None)
|
|
return response_400
|
|
if response.status_code == HTTPStatus.NOT_FOUND:
|
|
response_404 = cast(Any, None)
|
|
return response_404
|
|
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
|
|
response_422 = cast(Any, None)
|
|
return response_422
|
|
if client.raise_on_unexpected_status:
|
|
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
else:
|
|
return None
|
|
|
|
|
|
def _build_response(
|
|
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
) -> Response[Union[Any, SearchResultsCollectionEntry]]:
|
|
return Response(
|
|
status_code=HTTPStatus(response.status_code),
|
|
content=response.content,
|
|
headers=response.headers,
|
|
parsed=_parse_response(client=client, response=response),
|
|
)
|
|
|
|
|
|
def sync_detailed(
|
|
location: int,
|
|
*,
|
|
client: Union[AuthenticatedClient, Client],
|
|
garbage_type: Union[
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset
|
|
] = UNSET,
|
|
date_start: Union[Unset, str] = "2024-04-13T15:39:14.714927",
|
|
date_end: Union[Unset, str] = "2024-05-13T15:39:14.714945",
|
|
page: Union[Unset, int] = 1,
|
|
page_size: Union[Unset, int] = 100,
|
|
) -> Response[Union[Any, SearchResultsCollectionEntry]]:
|
|
"""Entry Find
|
|
|
|
Find entries by date(s) or type
|
|
|
|
Args:
|
|
location (int):
|
|
garbage_type (Union[EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset]):
|
|
date_start (Union[Unset, str]): Default: '2024-04-13T15:39:14.714927'.
|
|
date_end (Union[Unset, str]): Default: '2024-05-13T15:39:14.714945'.
|
|
page (Union[Unset, int]): Default: 1.
|
|
page_size (Union[Unset, int]): Default: 100.
|
|
|
|
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.
|
|
|
|
Returns:
|
|
Response[Union[Any, SearchResultsCollectionEntry]]
|
|
"""
|
|
|
|
kwargs = _get_kwargs(
|
|
location=location,
|
|
garbage_type=garbage_type,
|
|
date_start=date_start,
|
|
date_end=date_end,
|
|
page=page,
|
|
page_size=page_size,
|
|
)
|
|
|
|
response = client.get_httpx_client().request(
|
|
**kwargs,
|
|
)
|
|
|
|
return _build_response(client=client, response=response)
|
|
|
|
|
|
def sync(
|
|
location: int,
|
|
*,
|
|
client: Union[AuthenticatedClient, Client],
|
|
garbage_type: Union[
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset
|
|
] = UNSET,
|
|
date_start: Union[Unset, str] = "2024-04-13T15:39:14.714927",
|
|
date_end: Union[Unset, str] = "2024-05-13T15:39:14.714945",
|
|
page: Union[Unset, int] = 1,
|
|
page_size: Union[Unset, int] = 100,
|
|
) -> Optional[Union[Any, SearchResultsCollectionEntry]]:
|
|
"""Entry Find
|
|
|
|
Find entries by date(s) or type
|
|
|
|
Args:
|
|
location (int):
|
|
garbage_type (Union[EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset]):
|
|
date_start (Union[Unset, str]): Default: '2024-04-13T15:39:14.714927'.
|
|
date_end (Union[Unset, str]): Default: '2024-05-13T15:39:14.714945'.
|
|
page (Union[Unset, int]): Default: 1.
|
|
page_size (Union[Unset, int]): Default: 100.
|
|
|
|
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.
|
|
|
|
Returns:
|
|
Union[Any, SearchResultsCollectionEntry]
|
|
"""
|
|
|
|
return sync_detailed(
|
|
location=location,
|
|
client=client,
|
|
garbage_type=garbage_type,
|
|
date_start=date_start,
|
|
date_end=date_end,
|
|
page=page,
|
|
page_size=page_size,
|
|
).parsed
|
|
|
|
|
|
async def asyncio_detailed(
|
|
location: int,
|
|
*,
|
|
client: Union[AuthenticatedClient, Client],
|
|
garbage_type: Union[
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset
|
|
] = UNSET,
|
|
date_start: Union[Unset, str] = "2024-04-13T15:39:14.714927",
|
|
date_end: Union[Unset, str] = "2024-05-13T15:39:14.714945",
|
|
page: Union[Unset, int] = 1,
|
|
page_size: Union[Unset, int] = 100,
|
|
) -> Response[Union[Any, SearchResultsCollectionEntry]]:
|
|
"""Entry Find
|
|
|
|
Find entries by date(s) or type
|
|
|
|
Args:
|
|
location (int):
|
|
garbage_type (Union[EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset]):
|
|
date_start (Union[Unset, str]): Default: '2024-04-13T15:39:14.714927'.
|
|
date_end (Union[Unset, str]): Default: '2024-05-13T15:39:14.714945'.
|
|
page (Union[Unset, int]): Default: 1.
|
|
page_size (Union[Unset, int]): Default: 100.
|
|
|
|
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.
|
|
|
|
Returns:
|
|
Response[Union[Any, SearchResultsCollectionEntry]]
|
|
"""
|
|
|
|
kwargs = _get_kwargs(
|
|
location=location,
|
|
garbage_type=garbage_type,
|
|
date_start=date_start,
|
|
date_end=date_end,
|
|
page=page,
|
|
page_size=page_size,
|
|
)
|
|
|
|
response = await client.get_async_httpx_client().request(**kwargs)
|
|
|
|
return _build_response(client=client, response=response)
|
|
|
|
|
|
async def asyncio(
|
|
location: int,
|
|
*,
|
|
client: Union[AuthenticatedClient, Client],
|
|
garbage_type: Union[
|
|
EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset
|
|
] = UNSET,
|
|
date_start: Union[Unset, str] = "2024-04-13T15:39:14.714927",
|
|
date_end: Union[Unset, str] = "2024-05-13T15:39:14.714945",
|
|
page: Union[Unset, int] = 1,
|
|
page_size: Union[Unset, int] = 100,
|
|
) -> Optional[Union[Any, SearchResultsCollectionEntry]]:
|
|
"""Entry Find
|
|
|
|
Find entries by date(s) or type
|
|
|
|
Args:
|
|
location (int):
|
|
garbage_type (Union[EntryFindLocationsLocationEntriesGetGarbageTypeType0, None, Unset]):
|
|
date_start (Union[Unset, str]): Default: '2024-04-13T15:39:14.714927'.
|
|
date_end (Union[Unset, str]): Default: '2024-05-13T15:39:14.714945'.
|
|
page (Union[Unset, int]): Default: 1.
|
|
page_size (Union[Unset, int]): Default: 100.
|
|
|
|
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.
|
|
|
|
Returns:
|
|
Union[Any, SearchResultsCollectionEntry]
|
|
"""
|
|
|
|
return (
|
|
await asyncio_detailed(
|
|
location=location,
|
|
client=client,
|
|
garbage_type=garbage_type,
|
|
date_start=date_start,
|
|
date_end=date_end,
|
|
page=page,
|
|
page_size=page_size,
|
|
)
|
|
).parsed
|