diff --git a/examples/notebooks/collections.ipynb b/examples/notebooks/collections.ipynb index d72e672..0c0e598 100644 --- a/examples/notebooks/collections.ipynb +++ b/examples/notebooks/collections.ipynb @@ -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" }, diff --git a/impresso/api_client/api/admin/admin_find.py b/impresso/api_client/api/admin/admin_find.py index 6121a63..b7438a3 100644 --- a/impresso/api_client/api/admin/admin_find.py +++ b/impresso/api_client/api/admin/admin_find.py @@ -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: diff --git a/impresso/api_client/api/admin/admin_patch.py b/impresso/api_client/api/admin/admin_patch.py index b166c61..5a98bc2 100644 --- a/impresso/api_client/api/admin/admin_patch.py +++ b/impresso/api_client/api/admin/admin_patch.py @@ -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: diff --git a/impresso/api_client/api/collections/add_collectable_items_from_filters.py b/impresso/api_client/api/collections/add_collectable_items_from_filters.py index 0001464..4ea8846 100644 --- a/impresso/api_client/api/collections/add_collectable_items_from_filters.py +++ b/impresso/api_client/api/collections/add_collectable_items_from_filters.py @@ -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: diff --git a/impresso/api_client/api/collections/create_collection.py b/impresso/api_client/api/collections/create_collection.py index 6cc627c..7accadd 100644 --- a/impresso/api_client/api/collections/create_collection.py +++ b/impresso/api_client/api/collections/create_collection.py @@ -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: diff --git a/impresso/api_client/api/collections/find_collections.py b/impresso/api_client/api/collections/find_collections.py index 1af0e33..2d84f8b 100644 --- a/impresso/api_client/api/collections/find_collections.py +++ b/impresso/api_client/api/collections/find_collections.py @@ -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: diff --git a/impresso/api_client/api/collections/get_collection.py b/impresso/api_client/api/collections/get_collection.py index fc2c6e9..bea6d37 100644 --- a/impresso/api_client/api/collections/get_collection.py +++ b/impresso/api_client/api/collections/get_collection.py @@ -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: diff --git a/impresso/api_client/api/collections/patch_collections_collection_id_items.py b/impresso/api_client/api/collections/patch_collections_collection_id_items.py index 5484ae7..acdf494 100644 --- a/impresso/api_client/api/collections/patch_collections_collection_id_items.py +++ b/impresso/api_client/api/collections/patch_collections_collection_id_items.py @@ -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: diff --git a/impresso/api_client/api/collections/remove_collection.py b/impresso/api_client/api/collections/remove_collection.py index 5e14335..3779efd 100644 --- a/impresso/api_client/api/collections/remove_collection.py +++ b/impresso/api_client/api/collections/remove_collection.py @@ -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 @@ -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: @@ -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: @@ -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, @@ -77,7 +81,7 @@ def sync_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Error, RemoveCollectionResponse]]: +) -> Response[Union[CollectionRemoveResponse, Error]]: """Remove a collection Args: @@ -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( @@ -106,7 +110,7 @@ def sync( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Error, RemoveCollectionResponse]]: +) -> Optional[Union[CollectionRemoveResponse, Error]]: """Remove a collection Args: @@ -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( @@ -130,7 +134,7 @@ async def asyncio_detailed( id: str, *, client: AuthenticatedClient, -) -> Response[Union[Error, RemoveCollectionResponse]]: +) -> Response[Union[CollectionRemoveResponse, Error]]: """Remove a collection Args: @@ -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( @@ -157,7 +161,7 @@ async def asyncio( id: str, *, client: AuthenticatedClient, -) -> Optional[Union[Error, RemoveCollectionResponse]]: +) -> Optional[Union[CollectionRemoveResponse, Error]]: """Remove a collection Args: @@ -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 ( diff --git a/impresso/api_client/api/collections/update_collection.py b/impresso/api_client/api/collections/update_collection.py index 5c441a3..ed7721e 100644 --- a/impresso/api_client/api/collections/update_collection.py +++ b/impresso/api_client/api/collections/update_collection.py @@ -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: diff --git a/impresso/api_client/api/content_items/get_content_item.py b/impresso/api_client/api/content_items/get_content_item.py index 80564d3..e00dec5 100644 --- a/impresso/api_client/api/content_items/get_content_item.py +++ b/impresso/api_client/api/content_items/get_content_item.py @@ -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: diff --git a/impresso/api_client/api/data_providers/find_data_providers.py b/impresso/api_client/api/data_providers/find_data_providers.py index 1624038..b83392c 100644 --- a/impresso/api_client/api/data_providers/find_data_providers.py +++ b/impresso/api_client/api/data_providers/find_data_providers.py @@ -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: diff --git a/impresso/api_client/api/data_providers/get_data_provider.py b/impresso/api_client/api/data_providers/get_data_provider.py index 808c4de..ed31b47 100644 --- a/impresso/api_client/api/data_providers/get_data_provider.py +++ b/impresso/api_client/api/data_providers/get_data_provider.py @@ -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: diff --git a/impresso/api_client/api/entities/find_entities.py b/impresso/api_client/api/entities/find_entities.py index 8e15d3b..16eb1e3 100644 --- a/impresso/api_client/api/entities/find_entities.py +++ b/impresso/api_client/api/entities/find_entities.py @@ -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: diff --git a/impresso/api_client/api/entities/get_entity.py b/impresso/api_client/api/entities/get_entity.py index a59f2a3..bdf3a05 100644 --- a/impresso/api_client/api/entities/get_entity.py +++ b/impresso/api_client/api/entities/get_entity.py @@ -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: diff --git a/impresso/api_client/api/experiments/find_experiments.py b/impresso/api_client/api/experiments/find_experiments.py index 61901bf..e0cb24d 100644 --- a/impresso/api_client/api/experiments/find_experiments.py +++ b/impresso/api_client/api/experiments/find_experiments.py @@ -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: diff --git a/impresso/api_client/api/experiments/interact_with_experiment.py b/impresso/api_client/api/experiments/interact_with_experiment.py index 2088e33..d3f15d3 100644 --- a/impresso/api_client/api/experiments/interact_with_experiment.py +++ b/impresso/api_client/api/experiments/interact_with_experiment.py @@ -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: diff --git a/impresso/api_client/api/images/find_images.py b/impresso/api_client/api/images/find_images.py index 2ecc8c7..9699ea9 100644 --- a/impresso/api_client/api/images/find_images.py +++ b/impresso/api_client/api/images/find_images.py @@ -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: diff --git a/impresso/api_client/api/images/get_image.py b/impresso/api_client/api/images/get_image.py index 5d41a43..707c1ad 100644 --- a/impresso/api_client/api/images/get_image.py +++ b/impresso/api_client/api/images/get_image.py @@ -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: diff --git a/impresso/api_client/api/media_sources/find_media_sources.py b/impresso/api_client/api/media_sources/find_media_sources.py index 1f89cfa..d4b1e20 100644 --- a/impresso/api_client/api/media_sources/find_media_sources.py +++ b/impresso/api_client/api/media_sources/find_media_sources.py @@ -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: diff --git a/impresso/api_client/api/media_sources/get_media_source.py b/impresso/api_client/api/media_sources/get_media_source.py index 04fcbb3..56a392d 100644 --- a/impresso/api_client/api/media_sources/get_media_source.py +++ b/impresso/api_client/api/media_sources/get_media_source.py @@ -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: diff --git a/impresso/api_client/api/search/search.py b/impresso/api_client/api/search/search.py index b48faef..439a1a9 100644 --- a/impresso/api_client/api/search/search.py +++ b/impresso/api_client/api/search/search.py @@ -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: diff --git a/impresso/api_client/api/search_facets/get_images_facet.py b/impresso/api_client/api/search_facets/get_images_facet.py index 96f3cdd..83c1997 100644 --- a/impresso/api_client/api/search_facets/get_images_facet.py +++ b/impresso/api_client/api/search_facets/get_images_facet.py @@ -92,6 +92,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: diff --git a/impresso/api_client/api/search_facets/get_search_facet.py b/impresso/api_client/api/search_facets/get_search_facet.py index b4e92b3..559aabd 100644 --- a/impresso/api_client/api/search_facets/get_search_facet.py +++ b/impresso/api_client/api/search_facets/get_search_facet.py @@ -92,6 +92,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: diff --git a/impresso/api_client/api/search_facets/get_tr_clusters_facet.py b/impresso/api_client/api/search_facets/get_tr_clusters_facet.py index 6c1e0a1..2936b58 100644 --- a/impresso/api_client/api/search_facets/get_tr_clusters_facet.py +++ b/impresso/api_client/api/search_facets/get_tr_clusters_facet.py @@ -92,6 +92,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: diff --git a/impresso/api_client/api/search_facets/get_tr_passages_facet.py b/impresso/api_client/api/search_facets/get_tr_passages_facet.py index 87d09e3..1968a01 100644 --- a/impresso/api_client/api/search_facets/get_tr_passages_facet.py +++ b/impresso/api_client/api/search_facets/get_tr_passages_facet.py @@ -92,6 +92,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: diff --git a/impresso/api_client/api/text_reuse_clusters/find_text_reuse_clusters.py b/impresso/api_client/api/text_reuse_clusters/find_text_reuse_clusters.py index 965fd57..f02dc6e 100644 --- a/impresso/api_client/api/text_reuse_clusters/find_text_reuse_clusters.py +++ b/impresso/api_client/api/text_reuse_clusters/find_text_reuse_clusters.py @@ -93,6 +93,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: diff --git a/impresso/api_client/api/text_reuse_clusters/get_text_reuse_cluster.py b/impresso/api_client/api/text_reuse_clusters/get_text_reuse_cluster.py index c51459d..b5e32eb 100644 --- a/impresso/api_client/api/text_reuse_clusters/get_text_reuse_cluster.py +++ b/impresso/api_client/api/text_reuse_clusters/get_text_reuse_cluster.py @@ -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: diff --git a/impresso/api_client/api/text_reuse_passages/find_text_reuse_passages.py b/impresso/api_client/api/text_reuse_passages/find_text_reuse_passages.py index c8ecbeb..09d1b2e 100644 --- a/impresso/api_client/api/text_reuse_passages/find_text_reuse_passages.py +++ b/impresso/api_client/api/text_reuse_passages/find_text_reuse_passages.py @@ -90,6 +90,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: diff --git a/impresso/api_client/api/text_reuse_passages/get_text_reuse_passage.py b/impresso/api_client/api/text_reuse_passages/get_text_reuse_passage.py index e50c72c..ece4149 100644 --- a/impresso/api_client/api/text_reuse_passages/get_text_reuse_passage.py +++ b/impresso/api_client/api/text_reuse_passages/get_text_reuse_passage.py @@ -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: diff --git a/impresso/api_client/api/tools/perform_image_embedding.py b/impresso/api_client/api/tools/perform_image_embedding.py index fd81207..c3c4154 100644 --- a/impresso/api_client/api/tools/perform_image_embedding.py +++ b/impresso/api_client/api/tools/perform_image_embedding.py @@ -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: diff --git a/impresso/api_client/api/tools/perform_ner.py b/impresso/api_client/api/tools/perform_ner.py index 853f249..41feb50 100644 --- a/impresso/api_client/api/tools/perform_ner.py +++ b/impresso/api_client/api/tools/perform_ner.py @@ -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: diff --git a/impresso/api_client/api/tools/perform_text_embedding.py b/impresso/api_client/api/tools/perform_text_embedding.py index d5dffd9..2db05b6 100644 --- a/impresso/api_client/api/tools/perform_text_embedding.py +++ b/impresso/api_client/api/tools/perform_text_embedding.py @@ -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: diff --git a/impresso/api_client/api/topics/find_topics.py b/impresso/api_client/api/topics/find_topics.py index 6871679..ffc016a 100644 --- a/impresso/api_client/api/topics/find_topics.py +++ b/impresso/api_client/api/topics/find_topics.py @@ -93,6 +93,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: diff --git a/impresso/api_client/api/topics/get_topic.py b/impresso/api_client/api/topics/get_topic.py index 0488188..9484e4d 100644 --- a/impresso/api_client/api/topics/get_topic.py +++ b/impresso/api_client/api/topics/get_topic.py @@ -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: diff --git a/impresso/api_client/api/version/get_version_details.py b/impresso/api_client/api/version/get_version_details.py index 2b23682..89e2de7 100644 --- a/impresso/api_client/api/version/get_version_details.py +++ b/impresso/api_client/api/version/get_version_details.py @@ -42,6 +42,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: diff --git a/impresso/api_client/models/__init__.py b/impresso/api_client/models/__init__.py index 6ef26e4..5260bb6 100644 --- a/impresso/api_client/models/__init__.py +++ b/impresso/api_client/models/__init__.py @@ -25,6 +25,10 @@ from .collectable_items_updated_response import CollectableItemsUpdatedResponse from .collection import Collection from .collection_access_level import CollectionAccessLevel +from .collection_remove_response import CollectionRemoveResponse +from .collection_remove_response_params import CollectionRemoveResponseParams +from .collection_remove_response_params_status import CollectionRemoveResponseParamsStatus +from .collection_remove_response_task import CollectionRemoveResponseTask from .content_item import ContentItem from .content_item_access_bitmaps import ContentItemAccessBitmaps from .content_item_access_rights import ContentItemAccessRights @@ -165,10 +169,6 @@ from .new_collection_request import NewCollectionRequest from .new_collection_request_access_level import NewCollectionRequestAccessLevel from .partner import Partner -from .remove_collection_response import RemoveCollectionResponse -from .remove_collection_response_params import RemoveCollectionResponseParams -from .remove_collection_response_params_status import RemoveCollectionResponseParamsStatus -from .remove_collection_response_task import RemoveCollectionResponseTask from .search_base_find_response import SearchBaseFindResponse from .search_base_find_response_pagination import SearchBaseFindResponsePagination from .search_facet_bucket import SearchFacetBucket @@ -220,6 +220,10 @@ "CollectableItemsUpdatedResponse", "Collection", "CollectionAccessLevel", + "CollectionRemoveResponse", + "CollectionRemoveResponseParams", + "CollectionRemoveResponseParamsStatus", + "CollectionRemoveResponseTask", "ContentItem", "ContentItemAccessBitmaps", "ContentItemAccessRights", @@ -344,10 +348,6 @@ "NewCollectionRequest", "NewCollectionRequestAccessLevel", "Partner", - "RemoveCollectionResponse", - "RemoveCollectionResponseParams", - "RemoveCollectionResponseParamsStatus", - "RemoveCollectionResponseTask", "SearchBaseFindResponse", "SearchBaseFindResponsePagination", "SearchFacetBucket", diff --git a/impresso/api_client/models/collection_remove_response.py b/impresso/api_client/models/collection_remove_response.py new file mode 100644 index 0000000..9ce7897 --- /dev/null +++ b/impresso/api_client/models/collection_remove_response.py @@ -0,0 +1,55 @@ +from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar + +from attrs import define as _attrs_define + +if TYPE_CHECKING: + from ..models.collection_remove_response_params import CollectionRemoveResponseParams + from ..models.collection_remove_response_task import CollectionRemoveResponseTask + + +T = TypeVar("T", bound="CollectionRemoveResponse") + + +@_attrs_define +class CollectionRemoveResponse: + """Remove collection response + + Attributes: + params (CollectionRemoveResponseParams): + task (CollectionRemoveResponseTask): Deletion task details + """ + + params: "CollectionRemoveResponseParams" + task: "CollectionRemoveResponseTask" + + def to_dict(self) -> Dict[str, Any]: + params = self.params.to_dict() + + task = self.task.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update( + { + "params": params, + "task": task, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.collection_remove_response_params import CollectionRemoveResponseParams + from ..models.collection_remove_response_task import CollectionRemoveResponseTask + + d = src_dict.copy() + params = CollectionRemoveResponseParams.from_dict(d.pop("params")) + + task = CollectionRemoveResponseTask.from_dict(d.pop("task")) + + collection_remove_response = cls( + params=params, + task=task, + ) + + return collection_remove_response diff --git a/impresso/api_client/models/remove_collection_response_params.py b/impresso/api_client/models/collection_remove_response_params.py similarity index 65% rename from impresso/api_client/models/remove_collection_response_params.py rename to impresso/api_client/models/collection_remove_response_params.py index 214fee2..503170f 100644 --- a/impresso/api_client/models/remove_collection_response_params.py +++ b/impresso/api_client/models/collection_remove_response_params.py @@ -2,22 +2,22 @@ from attrs import define as _attrs_define -from ..models.remove_collection_response_params_status import RemoveCollectionResponseParamsStatus +from ..models.collection_remove_response_params_status import CollectionRemoveResponseParamsStatus from ..types import UNSET, Unset -T = TypeVar("T", bound="RemoveCollectionResponseParams") +T = TypeVar("T", bound="CollectionRemoveResponseParams") @_attrs_define -class RemoveCollectionResponseParams: +class CollectionRemoveResponseParams: """ Attributes: id (Union[Unset, str]): The collection id - status (Union[Unset, RemoveCollectionResponseParamsStatus]): The status of the operation + status (Union[Unset, CollectionRemoveResponseParamsStatus]): The status of the operation """ id: Union[Unset, str] = UNSET - status: Union[Unset, RemoveCollectionResponseParamsStatus] = UNSET + status: Union[Unset, CollectionRemoveResponseParamsStatus] = UNSET def to_dict(self) -> Dict[str, Any]: id = self.id @@ -41,15 +41,15 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: id = d.pop("id", UNSET) _status = d.pop("status", UNSET) - status: Union[Unset, RemoveCollectionResponseParamsStatus] + status: Union[Unset, CollectionRemoveResponseParamsStatus] if isinstance(_status, Unset): status = UNSET else: - status = RemoveCollectionResponseParamsStatus(_status) + status = CollectionRemoveResponseParamsStatus(_status) - remove_collection_response_params = cls( + collection_remove_response_params = cls( id=id, status=status, ) - return remove_collection_response_params + return collection_remove_response_params diff --git a/impresso/api_client/models/remove_collection_response_params_status.py b/impresso/api_client/models/collection_remove_response_params_status.py similarity index 52% rename from impresso/api_client/models/remove_collection_response_params_status.py rename to impresso/api_client/models/collection_remove_response_params_status.py index d3ab186..b573bff 100644 --- a/impresso/api_client/models/remove_collection_response_params_status.py +++ b/impresso/api_client/models/collection_remove_response_params_status.py @@ -2,11 +2,11 @@ from typing import Literal -class RemoveCollectionResponseParamsStatus(str, Enum): +class CollectionRemoveResponseParamsStatus(str, Enum): DEL = "DEL" def __str__(self) -> str: return str(self.value) -RemoveCollectionResponseParamsStatusLiteral = Literal["DEL",] +CollectionRemoveResponseParamsStatusLiteral = Literal["DEL",] diff --git a/impresso/api_client/models/remove_collection_response_task.py b/impresso/api_client/models/collection_remove_response_task.py similarity index 85% rename from impresso/api_client/models/remove_collection_response_task.py rename to impresso/api_client/models/collection_remove_response_task.py index f986e9d..dc91496 100644 --- a/impresso/api_client/models/remove_collection_response_task.py +++ b/impresso/api_client/models/collection_remove_response_task.py @@ -4,11 +4,11 @@ from ..types import UNSET, Unset -T = TypeVar("T", bound="RemoveCollectionResponseTask") +T = TypeVar("T", bound="CollectionRemoveResponseTask") @_attrs_define -class RemoveCollectionResponseTask: +class CollectionRemoveResponseTask: """Deletion task details Attributes: @@ -40,9 +40,9 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: creation_date = d.pop("creationDate", UNSET) - remove_collection_response_task = cls( + collection_remove_response_task = cls( task_id=task_id, creation_date=creation_date, ) - return remove_collection_response_task + return collection_remove_response_task diff --git a/impresso/api_client/models/new_collection_request.py b/impresso/api_client/models/new_collection_request.py index 47964d3..64effc1 100644 --- a/impresso/api_client/models/new_collection_request.py +++ b/impresso/api_client/models/new_collection_request.py @@ -13,17 +13,17 @@ class NewCollectionRequest: """Create new collection request Attributes: - name (str): + title (str): description (Union[Unset, str]): access_level (Union[Unset, NewCollectionRequestAccessLevel]): Access level of the collection. """ - name: str + title: str description: Union[Unset, str] = UNSET access_level: Union[Unset, NewCollectionRequestAccessLevel] = UNSET def to_dict(self) -> Dict[str, Any]: - name = self.name + title = self.title description = self.description @@ -34,7 +34,7 @@ def to_dict(self) -> Dict[str, Any]: field_dict: Dict[str, Any] = {} field_dict.update( { - "name": name, + "title": title, } ) if description is not UNSET: @@ -47,7 +47,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - name = d.pop("name") + title = d.pop("title") description = d.pop("description", UNSET) @@ -59,7 +59,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: access_level = NewCollectionRequestAccessLevel(_access_level) new_collection_request = cls( - name=name, + title=title, description=description, access_level=access_level, ) diff --git a/impresso/api_client/models/remove_collection_response.py b/impresso/api_client/models/remove_collection_response.py deleted file mode 100644 index 0733ac6..0000000 --- a/impresso/api_client/models/remove_collection_response.py +++ /dev/null @@ -1,55 +0,0 @@ -from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar - -from attrs import define as _attrs_define - -if TYPE_CHECKING: - from ..models.remove_collection_response_params import RemoveCollectionResponseParams - from ..models.remove_collection_response_task import RemoveCollectionResponseTask - - -T = TypeVar("T", bound="RemoveCollectionResponse") - - -@_attrs_define -class RemoveCollectionResponse: - """Remove collection response - - Attributes: - params (RemoveCollectionResponseParams): - task (RemoveCollectionResponseTask): Deletion task details - """ - - params: "RemoveCollectionResponseParams" - task: "RemoveCollectionResponseTask" - - def to_dict(self) -> Dict[str, Any]: - params = self.params.to_dict() - - task = self.task.to_dict() - - field_dict: Dict[str, Any] = {} - field_dict.update( - { - "params": params, - "task": task, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - from ..models.remove_collection_response_params import RemoveCollectionResponseParams - from ..models.remove_collection_response_task import RemoveCollectionResponseTask - - d = src_dict.copy() - params = RemoveCollectionResponseParams.from_dict(d.pop("params")) - - task = RemoveCollectionResponseTask.from_dict(d.pop("task")) - - remove_collection_response = cls( - params=params, - task=task, - ) - - return remove_collection_response diff --git a/impresso/api_models.py b/impresso/api_models.py index 89475e8..a119d3d 100644 --- a/impresso/api_models.py +++ b/impresso/api_models.py @@ -12,92 +12,92 @@ class Collection(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier of the collection.")] - title: Annotated[Optional[str], Field(None, description="Title of the collection.")] + id: Annotated[str, Field(description='Unique identifier of the collection.')] + title: Annotated[Optional[str], Field(None, description='Title of the collection.')] description: Annotated[ - Optional[str], Field(None, description="Description of the collection.") + Optional[str], Field(None, description='Description of the collection.') ] accessLevel: Annotated[ - Optional[Literal["public", "private"]], - Field(None, description="Access level of the collection."), + Optional[Literal['public', 'private']], + Field(None, description='Access level of the collection.'), ] createdAt: Annotated[ Optional[AwareDatetime], - Field(None, description="Creation date of the collection."), + Field(None, description='Creation date of the collection.'), ] updatedAt: Annotated[ Optional[AwareDatetime], - Field(None, description="Last update date of the collection."), + Field(None, description='Last update date of the collection.'), ] totalItems: Annotated[ Optional[int], - Field(None, description="Total number of items in the collection."), + Field(None, description='Total number of items in the collection.'), ] creatorId: Annotated[ Optional[str], - Field(None, description="Identifier of the user who created the collection."), + Field(None, description='Identifier of the user who created the collection.'), ] class Name(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - langCode: Annotated[str, Field(description="ISO 639-1 language code.")] + langCode: Annotated[str, Field(description='ISO 639-1 language code.')] name: Annotated[ - str, Field(description="Name of the data provider in this language.") + str, Field(description='Name of the data provider in this language.') ] class DataProvider(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the data provider.")] - name: Annotated[str, Field(description="The default name of the data provider.")] + id: Annotated[str, Field(description='The unique identifier of the data provider.')] + name: Annotated[str, Field(description='The default name of the data provider.')] names: Annotated[ Sequence[Name], - Field(description="Names of the data provider in different languages."), + Field(description='Names of the data provider in different languages.'), ] bitmapIndex: Annotated[ Optional[int], Field( - None, description="Bitmap index used for efficient data provider filtering." + None, description='Bitmap index used for efficient data provider filtering.' ), ] class Entity(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier of the entity")] + id: Annotated[str, Field(description='Unique identifier of the entity')] relevance: Annotated[ - int, Field(description="Relevance of the entity in the document") + int, Field(description='Relevance of the entity in the document') ] - name: Annotated[Optional[str], Field(None, description="Name of the entity")] + name: Annotated[Optional[str], Field(None, description='Name of the entity')] class ExperimentInfo(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the experiment.")] - name: Annotated[str, Field(description="The display name of the experiment.")] + id: Annotated[str, Field(description='The unique identifier of the experiment.')] + name: Annotated[str, Field(description='The display name of the experiment.')] description: Annotated[ Optional[str], - Field(None, description="A description of what the experiment does."), + Field(None, description='A description of what the experiment does.'), ] class FacetWithLabel(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier of the facet")] - label: Annotated[str, Field(description="Label of the facet")] + id: Annotated[str, Field(description='Unique identifier of the facet')] + label: Annotated[str, Field(description='Label of the facet')] class Q(RootModel[str]): @@ -110,268 +110,266 @@ class QItem(RootModel[str]): class Filter(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - context: Optional[Literal["include", "exclude"]] = "include" - op: Optional[Literal["AND", "OR"]] = "OR" + context: Optional[Literal['include', 'exclude']] = 'include' + op: Optional[Literal['AND', 'OR']] = 'OR' type: Annotated[ str, Field(description="Possible values are in 'impresso-jscomons Filter.type'") ] - precision: Optional[Literal["fuzzy", "soft", "exact", "partial"]] = "exact" + precision: Optional[Literal['fuzzy', 'soft', 'exact', 'partial']] = 'exact' q: Optional[Union[Q, Sequence[QItem]]] = None daterange: Annotated[ Optional[str], Field( None, - description="DEPRECATED: Use `q`.", - pattern="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z TO \\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z", + description='DEPRECATED: Use `q`.', + pattern='\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z TO \\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z', ), - ] = None - uids: Annotated[Optional[str], Field(None, description="DEPRECATED: Use `q`.")] = ( - None - ) + ] + uids: Annotated[Optional[str], Field(None, description='DEPRECATED: Use `q`.')] class ImageTypes(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) visualContent: Annotated[ Optional[str], - Field(None, description="Whether the content is an image or not."), + Field(None, description='Whether the content is an image or not.'), ] technique: Annotated[ Optional[str], - Field(None, description="Determines if the image is a photograph."), + Field(None, description='Determines if the image is a photograph.'), ] communicationGoal: Annotated[ Optional[str], - Field(None, description="Purpose or communicative function of the image."), + Field(None, description='Purpose or communicative function of the image.'), ] visualContentType: Annotated[ - Optional[str], Field(None, description="Classification of the visual content.") + Optional[str], Field(None, description='Classification of the visual content.') ] class MediaSourceRef(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the media source")] - name: Annotated[str, Field(description="The name of the media source")] + id: Annotated[str, Field(description='The unique identifier of the media source')] + name: Annotated[str, Field(description='The name of the media source')] type: Annotated[ - Optional[Literal["newspaper"]], - Field(None, description="The type of the media source"), + Optional[Literal['newspaper']], + Field(None, description='The type of the media source'), ] class Image(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the image")] - caption: Annotated[Optional[str], Field(None, description="Image caption")] + id: Annotated[str, Field(description='The unique identifier of the image')] + caption: Annotated[Optional[str], Field(None, description='Image caption')] issueId: Annotated[ str, Field( - description="The unique identifier of the issue that the image belongs to." + description='The unique identifier of the issue that the image belongs to.' ), ] contentItemId: Annotated[ Optional[str], Field( None, - description="The unique identifier of the content item that the image belongs to.", + description='The unique identifier of the content item that the image belongs to.', ), ] - previewUrl: Annotated[AnyUrl, Field(description="The URL of the image preview")] + previewUrl: Annotated[AnyUrl, Field(description='The URL of the image preview')] pageNumbers: Annotated[ Optional[Sequence[int]], Field( - None, description="The page numbers of the issue that the image belongs to." + None, description='The page numbers of the issue that the image belongs to.' ), ] imageTypes: Optional[ImageTypes] = None mediaSourceRef: Annotated[ - MediaSourceRef, Field(description="The media source of the image") + MediaSourceRef, Field(description='The media source of the image') ] date: Annotated[ date, Field( - description="The date of the image or the date of the issue that the image belongs to." + description='The date of the image or the date of the issue that the image belongs to.' ), ] embeddings: Annotated[ Optional[Sequence[str]], Field( None, - description="Precomputed embeddings for the image in the format: :.", + description='Precomputed embeddings for the image in the format: :.', ), ] class Offset(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - start: Annotated[int, Field(description="Start offset of the entity in the text")] - end: Annotated[int, Field(description="End offset of the entity in the text")] + start: Annotated[int, Field(description='Start offset of the entity in the text')] + end: Annotated[int, Field(description='End offset of the entity in the text')] class Confidence(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) ner: Annotated[ Optional[float], - Field(None, description="Confidence score for the named entity recognition"), + Field(None, description='Confidence score for the named entity recognition'), ] nel: Annotated[ Optional[float], - Field(None, description="Confidence score for the named entity linking"), + Field(None, description='Confidence score for the named entity linking'), ] class Wikidata(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Wikidata ID of the entity")] + id: Annotated[str, Field(description='Wikidata ID of the entity')] wikipediaPageName: Annotated[ - Optional[str], Field(None, description="Wikipedia page name of the entity") + Optional[str], Field(None, description='Wikipedia page name of the entity') ] wikipediaPageUrl: Annotated[ - Optional[str], Field(None, description="Wikipedia page URL of the entity") + Optional[str], Field(None, description='Wikipedia page URL of the entity') ] class ImpressoNerEntity(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="ID of the entity")] + id: Annotated[str, Field(description='ID of the entity')] type: Annotated[ Literal[ - "comp.demonym", - "comp.function", - "comp.name", - "comp.qualifier", - "comp.title", - "loc", - "loc.add.elec", - "loc.add.phys", - "loc.adm.nat", - "loc.adm.reg", - "loc.adm.sup", - "loc.adm.town", - "loc.fac", - "loc.oro", - "loc.phys.astro", - "loc.phys.geo", - "loc.phys.hydro", - "loc.unk", - "org", - "org.adm", - "org.ent", - "org.ent.pressagency", - "org.ent.pressagency.AFP", - "org.ent.pressagency.ANSA", - "org.ent.pressagency.AP", - "org.ent.pressagency.APA", - "org.ent.pressagency.ATS-SDA", - "org.ent.pressagency.Belga", - "org.ent.pressagency.CTK", - "org.ent.pressagency.DDP-DAPD", - "org.ent.pressagency.DNB", - "org.ent.pressagency.DPA", - "org.ent.pressagency.Domei", - "org.ent.pressagency.Europapress", - "org.ent.pressagency.Extel", - "org.ent.pressagency.Havas", - "org.ent.pressagency.Kipa", - "org.ent.pressagency.Reuters", - "org.ent.pressagency.SPK-SMP", - "org.ent.pressagency.Stefani", - "org.ent.pressagency.TASS", - "org.ent.pressagency.UP-UPI", - "org.ent.pressagency.Wolff", - "org.ent.pressagency.Xinhua", - "org.ent.pressagency.ag", - "org.ent.pressagency.unk", - "pers", - "pers.coll", - "pers.ind", - "pers.ind.articleauthor", - "prod", - "prod.doctr", - "prod.media", - "time", - "time.date.abs", - "time.hour.abs", - "unk", + 'comp.demonym', + 'comp.function', + 'comp.name', + 'comp.qualifier', + 'comp.title', + 'loc', + 'loc.add.elec', + 'loc.add.phys', + 'loc.adm.nat', + 'loc.adm.reg', + 'loc.adm.sup', + 'loc.adm.town', + 'loc.fac', + 'loc.oro', + 'loc.phys.astro', + 'loc.phys.geo', + 'loc.phys.hydro', + 'loc.unk', + 'org', + 'org.adm', + 'org.ent', + 'org.ent.pressagency', + 'org.ent.pressagency.AFP', + 'org.ent.pressagency.ANSA', + 'org.ent.pressagency.AP', + 'org.ent.pressagency.APA', + 'org.ent.pressagency.ATS-SDA', + 'org.ent.pressagency.Belga', + 'org.ent.pressagency.CTK', + 'org.ent.pressagency.DDP-DAPD', + 'org.ent.pressagency.DNB', + 'org.ent.pressagency.DPA', + 'org.ent.pressagency.Domei', + 'org.ent.pressagency.Europapress', + 'org.ent.pressagency.Extel', + 'org.ent.pressagency.Havas', + 'org.ent.pressagency.Kipa', + 'org.ent.pressagency.Reuters', + 'org.ent.pressagency.SPK-SMP', + 'org.ent.pressagency.Stefani', + 'org.ent.pressagency.TASS', + 'org.ent.pressagency.UP-UPI', + 'org.ent.pressagency.Wolff', + 'org.ent.pressagency.Xinhua', + 'org.ent.pressagency.ag', + 'org.ent.pressagency.unk', + 'pers', + 'pers.coll', + 'pers.ind', + 'pers.ind.articleauthor', + 'prod', + 'prod.doctr', + 'prod.media', + 'time', + 'time.date.abs', + 'time.hour.abs', + 'unk', ], - Field(description="Type of the entity"), + Field(description='Type of the entity'), ] surfaceForm: Annotated[ - Optional[str], Field(None, description="Surface form of the entity") + Optional[str], Field(None, description='Surface form of the entity') ] offset: Optional[Offset] = None isTypeNested: Annotated[ - Optional[bool], Field(None, description="Whether the entity type is nested") + Optional[bool], Field(None, description='Whether the entity type is nested') ] confidence: Confidence wikidata: Optional[Wikidata] = None function: Annotated[ - Optional[str], Field(None, description="Function of the entity") + Optional[str], Field(None, description='Function of the entity') ] - name: Annotated[Optional[str], Field(None, description="Name of the entity")] + name: Annotated[Optional[str], Field(None, description='Name of the entity')] class Totals(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) articles: Annotated[ Optional[int], - Field(None, description="The number of articles in the media source."), + Field(None, description='The number of articles in the media source.'), ] issues: Annotated[ Optional[int], - Field(None, description="The number of issues in the media source."), + Field(None, description='The number of issues in the media source.'), ] pages: Annotated[ Optional[int], - Field(None, description="The number of pages in the media source."), + Field(None, description='The number of pages in the media source.'), ] class Property(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the property.")] - label: Annotated[str, Field(description="The name of the property.")] - value: Annotated[str, Field(description="The value of the property.")] + id: Annotated[str, Field(description='The unique identifier of the property.')] + label: Annotated[str, Field(description='The name of the property.')] + value: Annotated[str, Field(description='The value of the property.')] class MediaSource(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the media source.")] + id: Annotated[str, Field(description='The unique identifier of the media source.')] type: Annotated[ - Literal["newspaper"], Field(description="The type of the media source.") + Literal['newspaper'], Field(description='The type of the media source.') ] - name: Annotated[str, Field(description="A display name of the media source.")] + name: Annotated[str, Field(description='A display name of the media source.')] languageCodes: Annotated[ Sequence[str], - Field(description="ISO 639-2 language codes this media source has content in."), + Field(description='ISO 639-2 language codes this media source has content in.'), ] publishedPeriodYears: Annotated[ Optional[Sequence[int]], Field( None, - description="The range of years this media source has been published for. Impresso may not have data for all this period. Is not defined if there is no information.", + description='The range of years this media source has been published for. Impresso may not have data for all this period. Is not defined if there is no information.', max_length=2, min_length=2, ), @@ -380,7 +378,7 @@ class MediaSource(BaseModel): Optional[Sequence[AwareDatetime]], Field( None, - description="The range of dates this media source has content items for. This represents the earliest and the latest dates of the contet items. Is not defined if there are no content items for this source.", + description='The range of dates this media source has content items for. This represents the earliest and the latest dates of the contet items. Is not defined if there are no content items for this source.', max_length=2, min_length=2, ), @@ -391,10 +389,10 @@ class MediaSource(BaseModel): class Partner(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Partner ID")] - title: Annotated[str, Field(description="Partner Title")] + id: Annotated[str, Field(description='Partner ID')] + title: Annotated[str, Field(description='Partner Title')] url: Annotated[ Optional[str], Field(None, description="URL of the partner's website") ] @@ -402,240 +400,240 @@ class Partner(BaseModel): class TimeCoverage(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) startDate: Annotated[ date, Field( - description="Publication date of the earliest content item in the cluster." + description='Publication date of the earliest content item in the cluster.' ), ] endDate: Annotated[ date, Field( - description="Publication date of the latest content item in the cluster." + description='Publication date of the latest content item in the cluster.' ), ] class TextReuseCluster(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique ID of the text reuse cluster.")] + id: Annotated[str, Field(description='Unique ID of the text reuse cluster.')] lexicalOverlap: Annotated[ Optional[float], Field( None, - description="Overlap in percents between the passages in the cluster.", + description='Overlap in percents between the passages in the cluster.', ge=0.0, le=100.0, ), ] clusterSize: Annotated[ Optional[int], - Field(None, description="Number of passages in the cluster.", ge=0), + Field(None, description='Number of passages in the cluster.', ge=0), ] textSample: Annotated[ Optional[str], Field( None, - description="Sample of a text from one of the passages in the cluster.", + description='Sample of a text from one of the passages in the cluster.', ), ] timeCoverage: Annotated[ - Optional[TimeCoverage], Field(None, description="Time coverage of the cluster.") + Optional[TimeCoverage], Field(None, description='Time coverage of the cluster.') ] class Offset1(BaseModel): start: Annotated[ - int, Field(description="Start offset of the passage in the content item.") + int, Field(description='Start offset of the passage in the content item.') ] end: Annotated[ - int, Field(description="End offset of the passage in the content item.") + int, Field(description='End offset of the passage in the content item.') ] class TextReusePassage(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique ID of the text reuse passage.")] + id: Annotated[str, Field(description='Unique ID of the text reuse passage.')] content: Annotated[ - Optional[str], Field(None, description="Textual content of the passage.") + Optional[str], Field(None, description='Textual content of the passage.') ] contentItemId: Annotated[ Optional[str], Field( None, - description="ID of the content item that the text reuse passage belongs to.", + description='ID of the content item that the text reuse passage belongs to.', ), ] offset: Annotated[ Optional[Offset1], Field( None, - description="Start and end offsets of the passage in the content item.", + description='Start and end offsets of the passage in the content item.', ), ] class TopicWord(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - w: Annotated[str, Field(description="Word surface form")] - p: Annotated[float, Field(description="Probability of the word in topic")] - h: Annotated[Optional[bool], Field(None, description="If word is highlighted")] + w: Annotated[str, Field(description='Word surface form')] + p: Annotated[float, Field(description='Probability of the word in topic')] + h: Annotated[Optional[bool], Field(None, description='If word is highlighted')] class Coordinates(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) latitude: Annotated[ - Optional[float], Field(None, description="The latitude of the location") + Optional[float], Field(None, description='The latitude of the location') ] longitude: Annotated[ - Optional[float], Field(None, description="The longitude of the location") + Optional[float], Field(None, description='The longitude of the location') ] class WikidataLocation(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ str, Field( - description="The Q Wikidata ID of the location (https://www.wikidata.org/wiki/Wikidata:Identifiers)" + description='The Q Wikidata ID of the location (https://www.wikidata.org/wiki/Wikidata:Identifiers)' ), ] - type: Annotated[Literal["location"], Field(description="The type of the entity")] + type: Annotated[Literal['location'], Field(description='The type of the entity')] labels: Annotated[ Optional[Mapping[str, Sequence[str]]], - Field(None, description="Labels of the location in different languages"), + Field(None, description='Labels of the location in different languages'), ] descriptions: Annotated[ Optional[Mapping[str, Sequence[str]]], - Field(None, description="Descriptions of the location in different languages"), + Field(None, description='Descriptions of the location in different languages'), ] coordinates: Optional[Coordinates] = None class WikidataPerson(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ str, Field( - description="The Q Wikidata ID of the person (https://www.wikidata.org/wiki/Wikidata:Identifiers)" + description='The Q Wikidata ID of the person (https://www.wikidata.org/wiki/Wikidata:Identifiers)' ), ] - type: Annotated[Literal["human"], Field(description="The type of the entity")] + type: Annotated[Literal['human'], Field(description='The type of the entity')] labels: Annotated[ Optional[Mapping[str, Sequence[str]]], - Field(None, description="Labels of the person in different languages"), + Field(None, description='Labels of the person in different languages'), ] descriptions: Annotated[ Optional[Mapping[str, Sequence[str]]], - Field(None, description="Descriptions of the person in different languages"), + Field(None, description='Descriptions of the person in different languages'), ] birthDate: Annotated[ - Optional[AwareDatetime], Field(None, description="The birth date of the person") + Optional[AwareDatetime], Field(None, description='The birth date of the person') ] deathDate: Annotated[ - Optional[AwareDatetime], Field(None, description="The death date of the person") + Optional[AwareDatetime], Field(None, description='The death date of the person') ] birthPlace: Annotated[ Optional[WikidataLocation], - Field(None, description="The birth place of the person"), + Field(None, description='The birth place of the person'), ] deathPlace: Annotated[ Optional[WikidataLocation], - Field(None, description="The death place of the person"), + Field(None, description='The death place of the person'), ] class WordMatch(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier for the word")] - languageCode: Annotated[str, Field(description="The language code of the word")] - word: Annotated[str, Field(description="The word")] + id: Annotated[str, Field(description='Unique identifier for the word')] + languageCode: Annotated[str, Field(description='The language code of the word')] + word: Annotated[str, Field(description='The word')] class YearWeights(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - c: Annotated[Optional[float], Field(None, description="Number of content items")] - a: Annotated[Optional[float], Field(None, description="Number of articles")] - p: Annotated[Optional[float], Field(None, description="Number of pages")] - i: Annotated[Optional[float], Field(None, description="Number of issues")] + c: Annotated[Optional[float], Field(None, description='Number of content items')] + a: Annotated[Optional[float], Field(None, description='Number of articles')] + p: Annotated[Optional[float], Field(None, description='Number of pages')] + i: Annotated[Optional[float], Field(None, description='Number of issues')] m: Annotated[ Optional[float], - Field(None, description="Number of images (with or without vectors)"), + Field(None, description='Number of images (with or without vectors)'), ] class ContentItemAccessBitmaps(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) explore: Annotated[ - Optional[str], Field(None, description="Bitmap for explore access. As bytes.") + Optional[str], Field(None, description='Bitmap for explore access. As bytes.') ] getTranscript: Annotated[ Optional[str], - Field(None, description="Bitmap for get transcript access. As bytes."), + Field(None, description='Bitmap for get transcript access. As bytes.'), ] getImages: Annotated[ Optional[str], - Field(None, description="Bitmap for get images access. As bytes."), + Field(None, description='Bitmap for get images access. As bytes.'), ] getAudio: Annotated[ - Optional[str], Field(None, description="Bitmap for get audio access. As bytes.") + Optional[str], Field(None, description='Bitmap for get audio access. As bytes.') ] class ContentItemAccessRights(BaseModel): dataDomain: Annotated[ - Literal["pbl", "prt"], + Literal['pbl', 'prt'], Field( description="Rights data domain. (e.g., 'pbl' for public, 'prt' for private)" ), ] dataDomainLabel: Annotated[ Optional[str], - Field(None, description="Human-readable label for the dataDomain code."), + Field(None, description='Human-readable label for the dataDomain code.'), ] copyright: Annotated[ - Literal["pbl", "und", "nkn", "euo", "unk", "in_cpy"], - Field(description="Copyright status."), + Literal['pbl', 'und', 'nkn', 'euo', 'unk', 'in_cpy'], + Field(description='Copyright status.'), ] copyrightLabel: Annotated[ Optional[str], - Field(None, description="Human-readable label for the copyright code."), + Field(None, description='Human-readable label for the copyright code.'), ] accessBitmaps: Annotated[ Optional[ContentItemAccessBitmaps], - Field(None, description="Access bitmaps for different functionalities."), + Field(None, description='Access bitmaps for different functionalities.'), ] class ContentItemAudioLocator(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) timeCode: Annotated[ Optional[Sequence[float]], Field( None, - description="Represents the start offset and the length of the audio segment in seconds.", + description='Represents the start offset and the length of the audio segment in seconds.', max_length=2, min_length=2, ), @@ -644,7 +642,7 @@ class ContentItemAudioLocator(BaseModel): Optional[Sequence[int]], Field( None, - description="Represents the character offset and length of the audio segment in the content item text.", + description='Represents the character offset and length of the audio segment in the content item text.', max_length=2, min_length=2, ), @@ -653,135 +651,135 @@ class ContentItemAudioLocator(BaseModel): Optional[int], Field( None, - description="Represents the index of the utterance in the audio file this audio segment belongs to. May not be provided if no utterance information is available.", + description='Represents the index of the utterance in the audio file this audio segment belongs to. May not be provided if no utterance information is available.', ), ] class ContentItemAudioRecord(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ - Optional[str], Field(None, description="Unique identifier of the audio record.") + Optional[str], Field(None, description='Unique identifier of the audio record.') ] number: Annotated[ - Optional[int], Field(None, description="The number of the audio record.") + Optional[int], Field(None, description='The number of the audio record.') ] audioSegmentsLocators: Annotated[ Optional[Sequence[ContentItemAudioLocator]], - Field(None, description="A list of audio segments locators."), + Field(None, description='A list of audio segments locators.'), ] audioFileUrl: Annotated[ - Optional[str], Field(None, description="The URL of the audio file.") + Optional[str], Field(None, description='The URL of the audio file.') ] class ContentItemMention(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) surfaceForm: Annotated[ Optional[str], - Field(None, description="The surface form (label) of the entity mention"), + Field(None, description='The surface form (label) of the entity mention'), ] mentionConfidence: Annotated[ Optional[float], - Field(None, description="Confidence score of the entity mention"), + Field(None, description='Confidence score of the entity mention'), ] startOffset: Annotated[ Optional[int], Field( - None, description="Start offset of the entity mention in the content item" + None, description='Start offset of the entity mention in the content item' ), ] endOffset: Annotated[ Optional[int], - Field(None, description="End offset of the entity mention in the content item"), + Field(None, description='End offset of the entity mention in the content item'), ] class ContentItemMeta(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) sourceType: Annotated[ Literal[ - "newspaper", - "radio_broadcast", - "radio_magazine", - "radio_schedule", - "monograph", - "encyclopedia", + 'newspaper', + 'radio_broadcast', + 'radio_magazine', + 'radio_schedule', + 'monograph', + 'encyclopedia', ], - Field(description="Type of the media source."), + Field(description='Type of the media source.'), ] sourceMedium: Annotated[ - Literal["audio", "print", "typescript"], + Literal['audio', 'print', 'typescript'], Field( - description="Medium of the source (audio for audio radio broadcasts, print for newspapers, typescript for digitised radio bulletin typescripts)." + description='Medium of the source (audio for audio radio broadcasts, print for newspapers, typescript for digitised radio bulletin typescripts).' ), ] mediaId: Annotated[ Optional[str], Field( None, - description="Media title alias. Usually a 3 letter code of the media title (newspaper, radio station, etc.).", + description='Media title alias. Usually a 3 letter code of the media title (newspaper, radio station, etc.).', ), ] mediaTitle: Annotated[ Optional[str], Field( None, - description="Human-readable title of the media source identified by mediaId.", + description='Human-readable title of the media source identified by mediaId.', ), ] date: Annotated[ - AwareDatetime, Field(description="Full date and time in ISO 8601 format") + AwareDatetime, Field(description='Full date and time in ISO 8601 format') ] partnerId: Annotated[ Optional[str], Field( - None, description="Identifier of the partner providing the content item." + None, description='Identifier of the partner providing the content item.' ), ] partnerTitle: Annotated[ Optional[str], Field( None, - description="Human-readable title of the partner identified by partnerId.", + description='Human-readable title of the partner identified by partnerId.', ), ] countryCode: Annotated[ Optional[str], Field( None, - description="Country code of the content item.", - pattern="^[A-Za-z]{2}$", + description='Country code of the content item.', + pattern='^[A-Za-z]{2}$', ), ] provinceCode: Annotated[ Optional[str], Field( None, - description="Province code of the content item.", - pattern="^[A-Za-z]{2}$", + description='Province code of the content item.', + pattern='^[A-Za-z]{2}$', ), ] class ContentItemNamedEntity(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ - Optional[str], Field(None, description="Unique identifier of the named entity") + Optional[str], Field(None, description='Unique identifier of the named entity') ] count: Annotated[ Optional[int], Field( None, - description="Number of times this entity is mentioned in the content item", + description='Number of times this entity is mentioned in the content item', ), ] label: Annotated[ @@ -797,7 +795,7 @@ class RegionCoordinate(RootModel[Sequence[Any]]): root: Annotated[ Sequence[Any], Field( - description="Region coordinates as an array: [x, y, w, h].", + description='Region coordinates as an array: [x, y, w, h].', max_length=4, min_length=4, ), @@ -806,19 +804,19 @@ class RegionCoordinate(RootModel[Sequence[Any]]): class ContentItemPageIIIF(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) manifestUrl: Annotated[ - AnyUrl, Field(description="The URL of the IIIF manifest for the page.") + AnyUrl, Field(description='The URL of the IIIF manifest for the page.') ] thumbnailUrl: Annotated[ - AnyUrl, Field(description="The URL of the thumbnail image for the page.") + AnyUrl, Field(description='The URL of the thumbnail image for the page.') ] class NamedEntities(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) persons: Optional[Sequence[ContentItemNamedEntity]] = None locations: Optional[Sequence[ContentItemNamedEntity]] = None @@ -828,7 +826,7 @@ class NamedEntities(BaseModel): class Mentions(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) persons: Optional[Sequence[ContentItemMention]] = None locations: Optional[Sequence[ContentItemMention]] = None @@ -838,74 +836,74 @@ class Mentions(BaseModel): class ContentItemTextMatch(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - fragment: Annotated[str, Field(description="TODO")] - coords: Annotated[Optional[Sequence[float]], Field(None, description="TODO")] - pageId: Annotated[Optional[str], Field(None, description="TODO")] - iiif: Annotated[Optional[str], Field(None, description="TODO")] + fragment: Annotated[str, Field(description='TODO')] + coords: Annotated[Optional[Sequence[float]], Field(None, description='TODO')] + pageId: Annotated[Optional[str], Field(None, description='TODO')] + iiif: Annotated[Optional[str], Field(None, description='TODO')] class ContentItemTopic(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) relevance: Annotated[ float, Field( - description="Relevance score of the topic in the content item, typically between 0 and 1, where 1 indicates high relevance.", + description='Relevance score of the topic in the content item, typically between 0 and 1, where 1 indicates high relevance.', ge=0.0, le=1.0, ), ] - id: Annotated[str, Field(description="Unique identifier of the topic.")] + id: Annotated[str, Field(description='Unique identifier of the topic.')] label: Annotated[ - Optional[str], Field(None, description="Human-readable label of the topic.") + Optional[str], Field(None, description='Human-readable label of the topic.') ] languageCode: Annotated[ Optional[str], Field( None, - description="Language code of the topic, following ISO 639-1 standards.", + description='Language code of the topic, following ISO 639-1 standards.', ), ] class AddCollectableItemsFromFilters(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) filters: Annotated[ Sequence[Filter], Field( - description="Filters to apply when selecting items to add to the collection" + description='Filters to apply when selecting items to add to the collection' ), ] namespace: Annotated[ - Literal["search", "tr_passages"], + Literal['search', 'tr_passages'], Field( - description="Namespace to use when selecting items to add to the collection" + description='Namespace to use when selecting items to add to the collection' ), ] class AdminPatchRequest(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) action: Literal[ - "clear-db-cache", - "clear-solr-cache", - "clear-wikidata-cache", - "rebuild-well-known-cache", + 'clear-db-cache', + 'clear-solr-cache', + 'clear-wikidata-cache', + 'rebuild-well-known-cache', ] class AuthenticationCreateRequest(BaseModel): model_config = ConfigDict( - extra="allow", + extra='allow', ) - strategy: Literal["local", "jwt-app", "jwt", "magic-link"] + strategy: Literal['local', 'jwt-app', 'jwt', 'magic-link'] email: Optional[str] = None password: Optional[str] = None accessToken: Optional[str] = None @@ -913,78 +911,78 @@ class AuthenticationCreateRequest(BaseModel): class ImpressoImageEmbeddingRequest(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) searchTarget: Annotated[ - Literal["image", "multimodal"], - Field(description="Which embedding space the embedding is going to be used in"), + Literal['image', 'multimodal'], + Field(description='Which embedding space the embedding is going to be used in'), ] bytes: Annotated[ str, Field( - description="Base64-encoded image bytes. JPG and PNG formats are supported." + description='Base64-encoded image bytes. JPG and PNG formats are supported.' ), ] class ImpressoNerRequest(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) text: Annotated[ str, Field( - description="Text to be processed for named entity recognition", + description='Text to be processed for named entity recognition', max_length=3999, min_length=1, ), ] method: Annotated[ - Optional[Literal["ner", "ner-nel", "nel"]], + Optional[Literal['ner', 'ner-nel', 'nel']], Field( - "ner", - description="NER method to be used: `ner` (default), `ner-nel` (named entity recognition with named entity linking) and `nel` (linking only - enclose entities in [START] [END] tags).", + 'ner', + description='NER method to be used: `ner` (default), `ner-nel` (named entity recognition with named entity linking) and `nel` (linking only - enclose entities in [START] [END] tags).', ), ] class ImpressoTextEmbeddingRequest(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) searchTarget: Annotated[ - Literal["multimodal", "text"], - Field(description="Which embedding space the embedding is going to be used in"), + Literal['multimodal', 'text'], + Field(description='Which embedding space the embedding is going to be used in'), ] - text: Annotated[str, Field(description="Text to be embedded", max_length=8000)] + text: Annotated[str, Field(description='Text to be embedded', max_length=8000)] class NewCollectionRequest(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - name: Annotated[str, Field(max_length=50, min_length=2)] + title: Annotated[str, Field(max_length=50, min_length=2)] description: Annotated[Optional[str], Field(None, max_length=500)] accessLevel: Annotated[ - Optional[Literal["public", "private"]], - Field(None, description="Access level of the collection."), + Optional[Literal['public', 'private']], + Field(None, description='Access level of the collection.'), ] class UpdateCollectableItemsRequest(BaseModel): add: Annotated[ Optional[Sequence[str]], - Field(None, description="IDs of the items to add to the collection"), + Field(None, description='IDs of the items to add to the collection'), ] remove: Annotated[ Optional[Sequence[str]], - Field(None, description="IDs of the items to remove from the collection"), + Field(None, description='IDs of the items to remove from the collection'), ] class CacheCounts(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) db: int solr: int @@ -993,7 +991,7 @@ class CacheCounts(BaseModel): class WellKnownComputedAt(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) mediaSources: str topics: str @@ -1002,14 +1000,14 @@ class WellKnownComputedAt(BaseModel): class Cleared(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) count: int class PatchResult(BaseModel): model_config = ConfigDict( - extra="allow", + extra='allow', ) action: str cleared: Optional[Cleared] = None @@ -1018,7 +1016,7 @@ class PatchResult(BaseModel): class AdminGetResponse(BaseModel): model_config = ConfigDict( - extra="allow", + extra='allow', ) contentItemsPermissionsDetails: Optional[Mapping[str, Any]] = None imagesPermissionsDetails: Optional[Mapping[str, Any]] = None @@ -1035,7 +1033,7 @@ class Authentication(BaseModel): class User(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: int username: str @@ -1049,34 +1047,34 @@ class User(BaseModel): class AuthenticationCreateResponse(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) accessToken: str authentication: Authentication - user: Annotated[User, Field(description="User details", title="User")] + user: Annotated[User, Field(description='User details', title='User')] class Pagination(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) total: Annotated[ - int, Field(description="The total number of items matching the query") + int, Field(description='The total number of items matching the query') ] limit: Annotated[ - int, Field(description="The number of items returned in this response") + int, Field(description='The number of items returned in this response') ] offset: Annotated[ int, Field( - description="Starting index of the items subset returned in this response" + description='Starting index of the items subset returned in this response' ), ] class BaseFind(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) data: Sequence pagination: Pagination @@ -1084,136 +1082,136 @@ class BaseFind(BaseModel): class CollectableItemsUpdatedResponse(BaseModel): totalAdded: Annotated[ - int, Field(description="Total number of items added to the collection") + int, Field(description='Total number of items added to the collection') ] totalRemoved: Annotated[ - int, Field(description="Total number of items removed from the collection") + int, Field(description='Total number of items removed from the collection') ] class Params(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[Optional[str], Field(None, description="The collection id")] + id: Annotated[Optional[str], Field(None, description='The collection id')] status: Annotated[ - Optional[Literal["DEL"]], Field(None, description="The status of the operation") + Optional[Literal['DEL']], Field(None, description='The status of the operation') ] class Task(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - task_id: Annotated[Optional[str], Field(None, description="The ID of the task")] + task_id: Annotated[Optional[str], Field(None, description='The ID of the task')] creationDate: Annotated[ - Optional[str], Field(None, description="When task was created") + Optional[str], Field(None, description='When task was created') ] class CollectionsRemoveResponse(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) params: Params - task: Annotated[Task, Field(description="Deletion task details")] + task: Annotated[Task, Field(description='Deletion task details')] class Error(BaseModel): type: Annotated[ AnyUrl, Field( - description="A URI reference [RFC3986] that identifies the problem type." + description='A URI reference [RFC3986] that identifies the problem type.' ), ] title: Annotated[ - str, Field(description="A short, human-readable summary of the problem type.") + str, Field(description='A short, human-readable summary of the problem type.') ] status: Annotated[ - int, Field(description="The HTTP status code ([RFC7231], Section 6)") + int, Field(description='The HTTP status code ([RFC7231], Section 6)') ] detail: Annotated[ Optional[str], Field( None, - description="A human-readable explanation specific to this occurrence of the problem.", + description='A human-readable explanation specific to this occurrence of the problem.', ), ] class TimeCoverage1(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - from_: Annotated[Optional[date], Field(None, alias="from")] + from_: Annotated[Optional[date], Field(None, alias='from')] to: Optional[date] = None class Cluster1(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ str, Field( - description="ID of the text reuse passage", - examples=["abc123"], - pattern="^[a-zA-Z0-9-_]+$", - title="Passage ID", + description='ID of the text reuse passage', + examples=['abc123'], + pattern='^[a-zA-Z0-9-_]+$', + title='Passage ID', ), ] lexicalOverlap: Annotated[ Optional[float], Field( None, - description="Percentage of overlap between passages in the cluster", + description='Percentage of overlap between passages in the cluster', ge=0.0, le=100.0, ), ] clusterSize: Annotated[ Optional[float], - Field(None, description="Number of passages in cluster", ge=0.0), + Field(None, description='Number of passages in cluster', ge=0.0), ] connectedClustersCount: Annotated[ - Optional[float], Field(None, description="Number of connected clusters", ge=0.0) + Optional[float], Field(None, description='Number of connected clusters', ge=0.0) ] timeCoverage: Annotated[ Optional[TimeCoverage1], - Field(None, description="Time window covered by documents in the cluster"), + Field(None, description='Time window covered by documents in the cluster'), ] class Facet(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - type: Annotated[Optional[str], Field(None, description="Facet type")] - numBuckets: Annotated[Optional[int], Field(None, description="Number of buckets")] + type: Annotated[Optional[str], Field(None, description='Facet type')] + numBuckets: Annotated[Optional[int], Field(None, description='Number of buckets')] buckets: Optional[Sequence[Mapping[str, Any]]] = None class Details(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) facets: Sequence[Facet] resolution: Annotated[ - Optional[Literal["year", "month", "day"]], + Optional[Literal['year', 'month', 'day']], Field(None, description="Resolution for the 'date' facet"), ] class Cluster(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) cluster: Annotated[ Optional[Cluster1], Field( None, - description="Represents a cluster of text reuse passages", - title="Text Reuse Cluster", + description='Represents a cluster of text reuse passages', + title='Text Reuse Cluster', ), ] textSample: str @@ -1221,22 +1219,22 @@ class Cluster(BaseModel): Optional[Details], Field( None, - description="Extra details of the cluster", - title="Text Reuse Cluster Details", + description='Extra details of the cluster', + title='Text Reuse Cluster Details', ), ] bitmapExplore: Annotated[ - Optional[int], Field(None, description="Access rights bitmap for the UI") + Optional[int], Field(None, description='Access rights bitmap for the UI') ] bitmapGetTranscript: Annotated[ Optional[int], - Field(None, description="Access rights bitmap for downloading the transcript"), + Field(None, description='Access rights bitmap for downloading the transcript'), ] class FindTextReuseClustersResponse(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) clusters: Sequence[Cluster] info: Any @@ -1245,35 +1243,35 @@ class FindTextReuseClustersResponse(BaseModel): class Freeform(BaseModel): pass model_config = ConfigDict( - extra="allow", + extra='allow', ) class ImpressoEmbeddingResponse(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) embedding: Annotated[ str, Field( - description="Embedding vector, base64-encoded with the model prefix. E.g. :" + description='Embedding vector, base64-encoded with the model prefix. E.g. :' ), ] class ImpressoNerResponse(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) modelId: Annotated[ - str, Field(description="ID of the model used for the named entity recognition") + str, Field(description='ID of the model used for the named entity recognition') ] text: Annotated[ - str, Field(description="Text processed for named entity recognition") + str, Field(description='Text processed for named entity recognition') ] timestamp: Annotated[ AwareDatetime, - Field(description="Timestamp of when named entity recognition was performed"), + Field(description='Timestamp of when named entity recognition was performed'), ] entities: Sequence[ImpressoNerEntity] @@ -1294,7 +1292,7 @@ class ApiVersion(BaseModel): class DocumentsDateSpan(BaseModel): model_config = ConfigDict( - extra="allow", + extra='allow', ) start: Optional[AwareDatetime] = None end: Optional[AwareDatetime] = None @@ -1306,7 +1304,7 @@ class Newspapers(BaseModel): class Name1(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) langCode: str name: str @@ -1314,7 +1312,7 @@ class Name1(BaseModel): class PartnerInstitution(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: str names: Sequence[Name1] @@ -1323,7 +1321,7 @@ class PartnerInstitution(BaseModel): class VersionDetailsFull(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) solr: Solr mysql: Mysql @@ -1337,56 +1335,56 @@ class VersionDetailsFull(BaseModel): class VersionDetailsShort(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - version: Annotated[str, Field(description="Version of the API.")] + version: Annotated[str, Field(description='Version of the API.')] class CollectableItemGroup(BaseModel): itemId: Annotated[ - Optional[str], Field(None, description="The id of the collectable item group") + Optional[str], Field(None, description='The id of the collectable item group') ] contentType: Annotated[ - Optional[Literal["A", "E", "P", "I"]], + Optional[Literal['A', 'E', 'P', 'I']], Field( None, - description="Content type of the collectable item group: (A)rticle, (E)ntities, (P)ages, (I)ssues", + description='Content type of the collectable item group: (A)rticle, (E)ntities, (P)ages, (I)ssues', ), ] collectionIds: Annotated[ - Optional[Sequence[str]], Field(None, description="Ids of the collections") + Optional[Sequence[str]], Field(None, description='Ids of the collections') ] searchQueries: Annotated[ - Optional[Sequence[str]], Field(None, description="Search queries") + Optional[Sequence[str]], Field(None, description='Search queries') ] collections: Annotated[ - Optional[Sequence[Collection]], Field(None, description="Collection objects") + Optional[Sequence[Collection]], Field(None, description='Collection objects') ] latestDateAdded: Annotated[ Optional[AwareDatetime], - Field(None, description="The latest date added to the collectable item group"), + Field(None, description='The latest date added to the collectable item group'), ] class EntityDetails(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier of the entity")] - label: Annotated[Optional[str], Field(None, description="Entity label")] - type: Optional[Literal["person", "location", "organisation", "newsagency"]] = None + id: Annotated[str, Field(description='Unique identifier of the entity')] + label: Annotated[Optional[str], Field(None, description='Entity label')] + type: Optional[Literal['person', 'location', 'organisation', 'newsagency']] = None wikidataId: Annotated[ - Optional[str], Field(None, description="Wikidata identifier of the entity.") + Optional[str], Field(None, description='Wikidata identifier of the entity.') ] totalMentions: Annotated[ Optional[int], - Field(None, description="Total number of mentions of the entity."), + Field(None, description='Total number of mentions of the entity.'), ] totalContentItems: Annotated[ Optional[int], Field( None, - description="Total number of content items the entity is mentioned in.", + description='Total number of content items the entity is mentioned in.', ), ] wikidataDetails: Optional[Union[WikidataPerson, WikidataLocation]] = None @@ -1394,29 +1392,29 @@ class EntityDetails(BaseModel): class Topic(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="The unique identifier of the topic")] - language: Annotated[str, Field(description="The language code of the topic")] + id: Annotated[str, Field(description='The unique identifier of the topic')] + language: Annotated[str, Field(description='The language code of the topic')] contentItemsCount: Annotated[ Optional[float], - Field(None, description="Number of content items with this topic"), + Field(None, description='Number of content items with this topic'), ] words: Annotated[ Optional[Sequence[TopicWord]], - Field(None, description="Top N words associated with the topic"), + Field(None, description='Top N words associated with the topic'), ] model: Annotated[ Optional[str], - Field(None, description="ID of the model used to generate the topic"), + Field(None, description='ID of the model used to generate the topic'), ] class Year(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[int, Field(description="Numeric representation of the year")] + id: Annotated[int, Field(description='Numeric representation of the year')] values: Optional[YearWeights] = None refs: Optional[YearWeights] = None @@ -1426,27 +1424,27 @@ class ContentItemAudio(BaseModel): Optional[str], Field( None, - description="Start time of media in HH:MM:SS format (relative to the day of broadcast).", - pattern="^\\d{2}:\\d{2}:\\d{2}$", + description='Start time of media in HH:MM:SS format (relative to the day of broadcast).', + pattern='^\\d{2}:\\d{2}:\\d{2}$', ), ] duration: Annotated[ Optional[str], Field( None, - description="Duration of the radio broadcast in HH:MM:SS format (relative to the start of the broadcast on the given broadcast day).", - pattern="^\\d{2}:\\d{2}:\\d{2}$", + description='Duration of the radio broadcast in HH:MM:SS format (relative to the start of the broadcast on the given broadcast day).', + pattern='^\\d{2}:\\d{2}:\\d{2}$', ), ] records: Annotated[ Optional[Sequence[ContentItemAudioRecord]], - Field(None, description="Array of records"), + Field(None, description='Array of records'), ] recordsCount: Annotated[ Optional[int], Field( None, - description="Total number of records/segments in the radio broadcast", + description='Total number of records/segments in the radio broadcast', ge=0, ), ] @@ -1454,123 +1452,123 @@ class ContentItemAudio(BaseModel): class ContentItemPage(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) id: Annotated[ - Optional[str], Field(None, description="Unique identifier of the page.") + Optional[str], Field(None, description='Unique identifier of the page.') ] - number: Annotated[Optional[int], Field(None, description="The number of the page.")] + number: Annotated[Optional[int], Field(None, description='The number of the page.')] regionCoordinates: Annotated[ Optional[Sequence[RegionCoordinate]], - Field(None, description="List of region coordinates."), + Field(None, description='List of region coordinates.'), ] iiif: Optional[ContentItemPageIIIF] = None class ContentItemSemanticEnrichments(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) ocrQuality: Annotated[ Optional[float], Field( None, - description="OCR quality assessment score between 0,00 and 1,00.", + description='OCR quality assessment score between 0,00 and 1,00.', ge=0.0, le=1.0, ), ] namedEntities: Annotated[ Optional[NamedEntities], - Field(None, description="Lists of named entities in the content item by type."), + Field(None, description='Lists of named entities in the content item by type.'), ] mentions: Annotated[ Optional[Mentions], - Field(None, description="List of mentions in the content item per type."), + Field(None, description='List of mentions in the content item per type.'), ] topics: Annotated[ Optional[Sequence[ContentItemTopic]], - Field(None, description="List of topics assigned to the content item."), + Field(None, description='List of topics assigned to the content item.'), ] collections: Annotated[ Optional[Sequence[Collection]], Field( - None, description="List of user collections the content item belongs to." + None, description='List of user collections the content item belongs to.' ), ] embeddings: Annotated[ Optional[Sequence[str]], Field( None, - description="Precomputed embeddings for the content item in the format: :.", + description='Precomputed embeddings for the content item in the format: :.', ), ] class ContentItemText(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) documentType: Annotated[ - Optional[Literal["p", "ci"]], + Optional[Literal['p', 'ci']], Field( - None, description="Type of document, e.g., page (p) or content item (ci)." + None, description='Type of document, e.g., page (p) or content item (ci).' ), ] itemType: Annotated[ Optional[ Literal[ - "ar", - "ad", - "page", - "tb", - "ob", - "w", - "ch", - "chapter", - "chronicle", - "unsegmented", - "radio_broadcast_episode", - "radio_bulletin", + 'ar', + 'ad', + 'page', + 'tb', + 'ob', + 'w', + 'ch', + 'chapter', + 'chronicle', + 'unsegmented', + 'radio_broadcast_episode', + 'radio_bulletin', ] ], - Field(None, description="Type of content item, e.g., article, section."), + Field(None, description='Type of content item, e.g., article, section.'), ] itemTypeLabel: Annotated[ Optional[str], - Field(None, description="Human-readable label for the itemType code."), + Field(None, description='Human-readable label for the itemType code.'), ] originalLangCode: Annotated[ - Optional[str], Field(None, description="Original language of the content item.") + Optional[str], Field(None, description='Original language of the content item.') ] langCode: Annotated[ - Optional[str], Field(None, description="Computed language of the content item.") + Optional[str], Field(None, description='Computed language of the content item.') ] contentLength: Annotated[ Optional[int], - Field(None, description="Token count of the content item (space split)."), + Field(None, description='Token count of the content item (space split).'), ] snippet: Annotated[ Optional[str], - Field(None, description="Snippet of the content item (first 150 characters)."), + Field(None, description='Snippet of the content item (first 150 characters).'), ] title: Annotated[ - Optional[str], Field(None, description="Title of the content item") + Optional[str], Field(None, description='Title of the content item') ] - content: Annotated[Optional[str], Field(None, description="Full text content")] + content: Annotated[Optional[str], Field(None, description='Full text content')] matches: Optional[Sequence[ContentItemTextMatch]] = None class SearchFacetBucket(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - count: Annotated[int, Field(description="Number of items in the bucket")] + count: Annotated[int, Field(description='Number of items in the bucket')] value: Annotated[ - Union[str, float, int], Field(description="Value that represents the bucket.") + Union[str, float, int], Field(description='Value that represents the bucket.') ] label: Annotated[ - Optional[str], Field(None, description="Label of the value, if relevant.") + Optional[str], Field(None, description='Label of the value, if relevant.') ] item: Annotated[ Optional[ @@ -1578,7 +1576,7 @@ class SearchFacetBucket(BaseModel): ], Field( None, - description="The item in the bucket. Particular object schema depends on the facet type", + description='The item in the bucket. Particular object schema depends on the facet type', ), ] @@ -1586,56 +1584,56 @@ class SearchFacetBucket(BaseModel): class ContentItemImage(BaseModel): pagesCount: Annotated[ Optional[int], - Field(None, description="Total number of pages in the content item."), + Field(None, description='Total number of pages in the content item.'), ] isFrontPage: Annotated[ Optional[bool], - Field(None, description="Indicates if the content item is on the front page."), + Field(None, description='Indicates if the content item is on the front page.'), ] isCoordinatesConverted: Annotated[ Optional[bool], - Field(None, description="Indicates whether coordinates were converted."), + Field(None, description='Indicates whether coordinates were converted.'), ] pages: Annotated[ Optional[Sequence[ContentItemPage]], - Field(None, description="List of pages this content item is on."), + Field(None, description='List of pages this content item is on.'), ] lineBreaks: Annotated[ Optional[Sequence[int]], Field( None, - description="List of line breaks offsets in the content item (relative to textual content).", + description='List of line breaks offsets in the content item (relative to textual content).', ), ] paragraphBreaks: Annotated[ Optional[Sequence[int]], Field( None, - description="List of paragraph breaks offsets in the content item (relative to textual content).", + description='List of paragraph breaks offsets in the content item (relative to textual content).', ), ] regionBreaks: Annotated[ Optional[Sequence[int]], Field( None, - description="List of region breaks offsets in the content item (relative to textual content).", + description='List of region breaks offsets in the content item (relative to textual content).', ), ] class ContentItem(BaseModel): model_config = ConfigDict( - extra="forbid", + extra='forbid', ) - id: Annotated[str, Field(description="Unique identifier for the content item")] + id: Annotated[str, Field(description='Unique identifier for the content item')] issueId: Annotated[ - Optional[str], Field(None, description="Unique issue identifier") + Optional[str], Field(None, description='Unique issue identifier') ] relevanceScore: Annotated[ Optional[float], Field( None, - description="Relevance score for this content item relative to the search query", + description='Relevance score for this content item relative to the search query', ge=0.0, ), ] diff --git a/impresso/resources/collections.py b/impresso/resources/collections.py index d7fe342..35852a2 100644 --- a/impresso/resources/collections.py +++ b/impresso/resources/collections.py @@ -1,9 +1,12 @@ from typing import Any, Callable, Iterator, cast from pandas import DataFrame, json_normalize from impresso.api_client.api.collections import ( + create_collection, find_collections, get_collection, patch_collections_collection_id_items, + remove_collection, + update_collection, ) from impresso.api_client.models.find_collections_base_find_response import ( FindCollectionsBaseFindResponse, @@ -12,6 +15,11 @@ FindCollectionsOrderBy, FindCollectionsOrderByLiteral, ) +from impresso.api_client.models.new_collection_request import NewCollectionRequest +from impresso.api_client.models.new_collection_request_access_level import ( + NewCollectionRequestAccessLevel, + NewCollectionRequestAccessLevelLiteral, +) from impresso.api_client.models.update_collectable_items_request import ( UpdateCollectableItemsRequest, ) @@ -75,6 +83,11 @@ def df(self) -> DataFrame: return json_normalize([self._data.to_dict()]).set_index("id") return DataFrame() + @property + def pydantic(self) -> Collection: + """The response data as a pydantic model.""" + return Collection.model_validate(self.raw) + @property def size(self) -> int: """Current page size.""" @@ -114,6 +127,16 @@ class CollectionsResource(Resource): Remove items from a collection: >>> item_ids_to_remove = ["item-id-1"] # Replace with real item IDs >>> collections.remove_items(collection_id, item_ids_to_remove) # doctest: +SKIP + + Create a new collection: + >>> new_collection = collections.create("My Collection", description="A test collection") # doctest: +SKIP + >>> print(new_collection.df) # doctest: +SKIP + + Rename a collection: + >>> collections.rename(collection_id, "New Name") # doctest: +SKIP + + Delete a collection: + >>> collections.delete(collection_id) # doctest: +SKIP """ name = "collections" @@ -235,6 +258,70 @@ def add_items(self, collection_id: str, item_ids: list[str]) -> None: ) raise_for_error(result) + def create( + self, + title: str, + description: str | None = None, + access_level: NewCollectionRequestAccessLevelLiteral | None = None, + ) -> GetCollectionContainer: + """ + Create a new collection. + + Args: + title: Title of the collection. + description: Optional description of the collection. + access_level: Access level of the collection ("private" or "public"). + + Returns: + GetCollectionContainer: Data container with the created collection. + """ + result = create_collection.sync( + client=self._api_client, + body=NewCollectionRequest( + title=title, + description=description if description is not None else UNSET, + access_level=( + get_enum_from_literal(access_level, NewCollectionRequestAccessLevel) + if access_level is not None + else UNSET + ), + ), + ) + raise_for_error(result) + return GetCollectionContainer(result, FindCollectionsSchema) + + def rename(self, id: str, title: str) -> GetCollectionContainer: + """ + Rename a collection. + + Args: + id: The ID of the collection to rename. + title: The new title for the collection. + + Returns: + GetCollectionContainer: Data container with the updated collection. + """ + result = update_collection.sync( + id=id, + client=self._api_client, + body=NewCollectionRequest(title=title), + ) + raise_for_error(result) + return GetCollectionContainer(result, FindCollectionsSchema) + + def delete(self, id: str) -> None: + """ + Delete a collection by ID. + + Args: + id: The ID of the collection to delete. + """ + result = remove_collection.sync( + id=id, + client=self._api_client, + ) + raise_for_error(result) + def remove_items(self, collection_id: str, item_ids: list[str]) -> None: """ Remove items from a collection by their IDs. diff --git a/impresso/resources/images.py b/impresso/resources/images.py index c04534d..384de7d 100644 --- a/impresso/resources/images.py +++ b/impresso/resources/images.py @@ -201,7 +201,7 @@ def find( if issue_id is not None: filters.extend(and_or_filter(issue_id, "issue")) if is_front is not None: - filters.append(Filter(type="isFront", daterange=None)) + filters.append(Filter(type="isFront", daterange=None, uids=None)) if date_range is not None: filters.append( Filter( @@ -209,6 +209,7 @@ def find( q=Q(DateRange._as_filter_value(date_range)), context="exclude" if date_range.inverted else "include", daterange=None, + uids=None, ) ) if visual_content is not None: diff --git a/impresso/resources/search.py b/impresso/resources/search.py index 8acbcb4..24a0c2c 100644 --- a/impresso/resources/search.py +++ b/impresso/resources/search.py @@ -457,11 +457,11 @@ def _build_filters( if string: filters.extend(and_or_filter(string, "string")) if with_text_contents: - filters.append(Filter(type="has_text_contents", daterange=None)) + filters.append(Filter(type="has_text_contents", daterange=None, uids=None)) if title is not None: filters.extend(and_or_filter(title, "title")) if front_page: - filters.append(Filter(type="is_front", daterange=None)) + filters.append(Filter(type="is_front", daterange=None, uids=None)) if entity_id is not None: filters.extend(and_or_filter(entity_id, "entity")) if newspaper_id is not None: @@ -473,6 +473,7 @@ def _build_filters( q=Q(DateRange._as_filter_value(date_range)), context="exclude" if date_range.inverted else "include", daterange=None, + uids=None, ) ) if language is not None: diff --git a/impresso/resources/text_reuse/clusters.py b/impresso/resources/text_reuse/clusters.py index 5f80f4b..45c0afd 100644 --- a/impresso/resources/text_reuse/clusters.py +++ b/impresso/resources/text_reuse/clusters.py @@ -335,6 +335,7 @@ def _build_cluster_facet_filters( q=Q(DateRange._as_filter_value(date_range)), context="exclude" if date_range.inverted else "include", daterange=None, + uids=None, ) ) if newspaper_id is not None: @@ -415,6 +416,7 @@ def _build_filters( q=Q(DateRange._as_filter_value(date_range)), context="exclude" if date_range.inverted else "include", daterange=None, + uids=None, ) ) if newspaper_id is not None: @@ -422,7 +424,7 @@ def _build_filters( if collection_id is not None: filters.extend(and_or_filter(collection_id, "collection")) if front_page: - filters.append(Filter(type="is_front", daterange=None)) + filters.append(Filter(type="is_front", daterange=None, uids=None)) if topic_id is not None: filters.extend(and_or_filter(topic_id, "topic")) if language is not None: diff --git a/impresso/util/filters.py b/impresso/util/filters.py index 74bd27b..65b64e9 100644 --- a/impresso/util/filters.py +++ b/impresso/util/filters.py @@ -109,6 +109,7 @@ def and_or_filter( context="exclude" if item.inverted else "include", precision=item.precision, daterange=None, + uids=None, ) chain_filters = [ Filter( @@ -117,11 +118,18 @@ def and_or_filter( op=chain_item.op, context="exclude" if chain_item.inverted else "include", daterange=None, + uids=None, ) for chain_item in item.chain ] return [filter] + chain_filters else: return [ - Filter(type=type, q=Q(converter(item)), daterange=None, precision="exact") + Filter( + type=type, + q=Q(converter(item)), + daterange=None, + precision="exact", + uids=None, + ) ]