<!-- Source: https://docs.squirro.com/en/latest/api/squirro_client.topic.CollectionsMixin.html -->
# CollectionsMixin

**`class CollectionsMixin`**

Bases: [`object`](https://docs.python.org/3.11/library/functions.html#object)

Mixin for collection related API calls.

Collection is a list of items that can be used to filter the search results.

Methods SummaryMethods Documentation

**`add_item_to_collection(project_id, collection_id, item_id)`**

Add an item to a collection. The item_id validity is not checked. If successful, returns an empty dictionary.

Return type

[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)[[`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any), [`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]

**`create_collection(project_id, name, filter_query=None)`**

Create a new collection for a project.

**`delete_collection(project_id, collection_id)`**

Delete a collection by ID. If successful, returns an empty dictionary.

Return type

[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)[[`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any), [`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]

**`delete_item_from_collection(project_id, collection_id, item_id)`**

Delete an item from a collection. If successful, returns an empty dictionary.

Return type

[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)[[`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any), [`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]

**`get_collection(project_id, collection_id)`**

Get a collection by ID.

**`get_collections(project_id)`**

Get item collections for a project.

**`get_collections_containing_items(project_id, item_ids)`**

Get collections that contain the given items. Returns a dictionary with item IDs as keys and list of collection IDs as values.

**`update_collection(project_id, collection_id, name, filter_query=None)`**

Update a collection by ID.

Parameters

- `project_id` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – The project ID
- `collection_id` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – The collection ID
- `name` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – New name for the collection
- `filter_query` ([`Optional`](https://docs.python.org/3.11/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3.11/library/stdtypes.html#str)]) – New filter query (can be None to clear)
