Collection

Get Collection Types

Pulls back all configured collection types as CollectionType objects

SearchAPI.get_collection_types(raw=False) 
Name
Type
Description

raw

boolean

If true, this function returns the JSON response as a dictionary, not a CollectionType object. Default is false.


Search Collections

Searches all collections, returning a list of Collection objects. All matching collection objects up to the max_results parameter (visible to the user) will be returned regardless of page size parameter value.

SearchAPI.search_collections(query_string="*", start_page_num=1, page_size=20, max_results=0, raw=False) 

Get Collection

Used to retrieve a specific collection as a Collection object.

SearchAPI.get_collection(collection_id, raw=False) 
Name
Type
Description

collection_id

string

ID of collection to return

raw

boolean

If true, this function returns the JSON response as a dictionary, not a CollectionType object. Default is false.


Delete Collection

Used to delete a collection by ID.

SearchAPI.delete_collection(collection_id) 
Name
Type
Description

collection_id

string

ID of collection to delete


New Collection

Used to create a new collection, returns the created collection as a Collection object.

SearchAPI.new_collection(name, description="", collection_type="general-collection") 
Name
Type
Description

name

string

Name for new collection

description

string

Optional, description for collection

collection_type

string or CollectionType

Collection type to use, defaults to "general-collection", which will always be available.


Add to Collection

Adds a document to a collection.

SearchAPI.add_to_collection(collection, dataset, document_id) 
Name
Type
Description

collection

string or collection

Collection to add to

dataset

string or dataset

Dataset containing document (either string dataset ID or a Dataset object)

document_id

string

ID of document to add


Add Collection Permissions

Used to add additional user permissions to collections.

SearchAPI.add_collection_permissions(collection, permissions, users)
Name
Type
Description

collection

string or Collection

Collection to add to

permissions

string or integer

“remove”, “read”, “write”, “delete” or appropriate corresponding integer value

users

list of string

List of qualified usernames to add these permissions for


Get User

Used to get details about an AIE user as a SearchUser object.

SearchAPI.get_user(user_id="me", raw=False) 
Name
Type
Description

user_id

string

ID of user to pull (defaults to “me”, which returns the authenticated user)

raw

boolean

If true, this function returns the JSON response as a dictionary, not a SearchUser object. Default is false.


Get Settings

Used to return the Aiimi Insight Engine settings dictionary, which can be used to determine various things about the configured system, including details on search flows, configured DSAR and disclosure settings, theming etc.

SearchAPI.get_settings()

Download

Used to directly download a document from AIE, this is returned in python as a BytesIO object.

SearchAPI.download(dataset, document_id) 
Name
Type
Description

dataset

string or Dataset

Dataset containing document (either string dataset ID or a Dataset object)

document_id

string

ID of document to download


Collection Objects

The Collection class is a Python representation of a collection object, typically obtained through the SearchAPI wrapper. This class provides a structured way to interact with collections, allowing users to manage files, permissions, and other attributes associated with a collection. Below is a detailed overview of each class and its functionality.

Attributes

collectionType An instance of CollectionType, representing the type of the collection.

search_api An optional SearchAPI instance for performing operations.

Methods

type() Returns the type of the collection.

name() Returns the name of the collection.

str() Returns a string representation of the collection in the format collection:<name>.

to_dict() Returns a dictionary representation of the collection, including files, file entries, and permissions.

files() Returns a copy of the list of files associated with the collection.

file_entries() Returns a copy of the file entries associated with the collection.

permissions() Returns a copy of the permissions associated with the collection.

update(search_api=None) Updates the collection's data using the provided search_api instance or the instance stored in the object.

  • Parameters:

    • search_api (optional): An instance of SearchAPI to fetch the latest collection data.

  • Raises:

    • Exception: If no SearchAPI instance is provided.

delete(search_api=None) Deletes the collection using the provided search_api instance or the instance stored in the object.

  • Parameters:

    • search_api (optional): An instance of SearchAPI to perform the deletion.

  • Raises:

    • Exception: If no SearchAPI instance is provided.

add_document(dataset, document_id, search_api=None) Adds a document to the collection.

  • Parameters:

    • dataset: The dataset to which the document belongs. This can be an instance of Dataset or a dataset ID.

    • document_id: The ID of the document to be added.

    • search_api (optional): An instance of SearchAPI to perform the operation.

  • Raises:

    • Exception: If no SearchAPI instance is provided.

  • Notes:

    • If the document is already in the collection, a warning is printed and the operation is not performed again.

add_permissions(permissions, users, search_api=None) Adds permissions for specified users to the collection.

  • Parameters:

    • permissions: The permissions to be added, which can be a string ("read", "write", "delete", or "remove") or an integer.

    • users: A list of users to whom the permissions will be granted.

    • search_api (optional): An instance of SearchAPI to perform the operation.

  • Raises:

    • Exception: If no SearchAPI instance is provided.

    • ValueError: If the permissions are not valid.

  • Notes:

    • The method first removes the specified users from all permission types and then adds them according to the specified permissions.

parse_permissions(permissions) A static method to parse permissions from a string or integer.

  • Parameters:

    • permissions: The permissions to be parsed, which can be a string or an integer.

  • Returns:

    • An integer representing the parsed permissions.

  • Raises:

    • ValueError: If the permissions are not valid.

create_new(search_api, name, description="", collection_type="general-collection") A static method to create a new collection.

  • Parameters:

    • search_api: An instance of SearchAPI to perform the operation.

    • name: The name of the new collection.

    • description (optional): A description for the new collection.

    • collection_type (optional): The type of the collection, defaulting to "general-collection".

Last updated