Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion examples/notebooks/collections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,73 @@
"source": [
"impresso.collections.items(test_collection_id)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create, Rename, Delete a collection"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import uuid\n",
"\n",
"new_collection = impresso.collections.create(\n",
" title=f\"Test {uuid.uuid4()}\",\n",
" description=\"This is a test collection.\",\n",
")\n",
"new_collection"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"impresso.collections.get(new_collection.pydantic.id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"new_collection = impresso.collections.rename(new_collection.pydantic.id, f\"Renamed {uuid.uuid4()}\")\n",
"new_collection"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"impresso.collections.delete(new_collection.pydantic.id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" impresso.collections.get(new_collection.pydantic.id)\n",
"except Exception as e:\n",
" print(f\"Collection not found, as expected. Error: {e}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/admin/admin_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/admin/admin_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/collections/create_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/collections/find_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/collections/get_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
28 changes: 16 additions & 12 deletions impresso/api_client/api/collections/remove_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.collection_remove_response import CollectionRemoveResponse
from ...models.error import Error
from ...models.remove_collection_response import RemoveCollectionResponse
from ...types import Response


Expand All @@ -23,9 +23,9 @@ def _get_kwargs(

def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, RemoveCollectionResponse]]:
) -> Optional[Union[CollectionRemoveResponse, Error]]:
if response.status_code == HTTPStatus.OK:
response_200 = RemoveCollectionResponse.from_dict(response.json())
response_200 = CollectionRemoveResponse.from_dict(response.json())

return response_200
if response.status_code == HTTPStatus.UNAUTHORIZED:
Expand Down Expand Up @@ -56,6 +56,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand All @@ -64,7 +68,7 @@ def _parse_response(

def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Error, RemoveCollectionResponse]]:
) -> Response[Union[CollectionRemoveResponse, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -77,7 +81,7 @@ def sync_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, RemoveCollectionResponse]]:
) -> Response[Union[CollectionRemoveResponse, Error]]:
"""Remove a collection

Args:
Expand All @@ -88,7 +92,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, RemoveCollectionResponse]]
Response[Union[CollectionRemoveResponse, Error]]
"""

kwargs = _get_kwargs(
Expand All @@ -106,7 +110,7 @@ def sync(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, RemoveCollectionResponse]]:
) -> Optional[Union[CollectionRemoveResponse, Error]]:
"""Remove a collection

Args:
Expand All @@ -117,7 +121,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, RemoveCollectionResponse]
Union[CollectionRemoveResponse, Error]
"""

return sync_detailed(
Expand All @@ -130,7 +134,7 @@ async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, RemoveCollectionResponse]]:
) -> Response[Union[CollectionRemoveResponse, Error]]:
"""Remove a collection

Args:
Expand All @@ -141,7 +145,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, RemoveCollectionResponse]]
Response[Union[CollectionRemoveResponse, Error]]
"""

kwargs = _get_kwargs(
Expand All @@ -157,7 +161,7 @@ async def asyncio(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, RemoveCollectionResponse]]:
) -> Optional[Union[CollectionRemoveResponse, Error]]:
"""Remove a collection

Args:
Expand All @@ -168,7 +172,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, RemoveCollectionResponse]
Union[CollectionRemoveResponse, Error]
"""

return (
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/collections/update_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/content_items/get_content_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/data_providers/find_data_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/data_providers/get_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/entities/find_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/entities/get_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/experiments/find_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/images/find_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/images/get_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/media_sources/find_media_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 4 additions & 0 deletions impresso/api_client/api/media_sources/get_media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _parse_response(
response_500 = Error.from_dict(response.json())

return response_500
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
Loading
Loading