Skip to content

collection

Module to define the CelonisCollection.

This module defines the CelonisCollection used in PyCelonis to facilitate searching objects by their attributes.

Typical usage example:

```python
data_models = CelonisCollection([data_model1, data_model2])
found_data_models = data_models.find("TEST_DM", search_attribute="name")
data_model = data_models.find_single("TEST_DM", search_attribute="name")
```

T module-attribute

T = typing.TypeVar('T')

CelonisCollection

Bases: List[T]

Class to make lists searchable.

from_list classmethod

from_list(list_)

Convert list to Celonis Collection.

Parameters:

  • list_ (List) –

    List to convert.

Returns:

find_all

find_all(search_term, search_attribute='name')

Return all objects with matching search_attribute for given search_term.

Parameters:

  • search_term (Any) –

    Term to search for within objects of collection.

  • search_attribute (str, default: 'name' ) –

    Attribute of objects to search, default 'name'.

Returns:

find

find(search_term, search_attribute='name', default=None)

Return single object with matching search_attribute for given search_term.

Parameters:

  • search_term (Any) –

    Term to search for within objects of collection.

  • search_attribute (str, default: 'name' ) –

    Attribute of objects to search, default 'name'.

  • default (Optional[T], default: None ) –

    Default to return if no matching object found. If no default PyCelonisNotFoundError is raised if no object found.

Returns:

  • T

    Object matching search_term for search_attribute.

Raises:

  • PyCelonisNotFoundError

    Raised if no object in collection matches search_term for search_attribute and no default given.

  • PyCelonisValueError

    Raised if multiple objects in collection match search_term for search_attribute.

find_by_id

find_by_id(search_id)

Return single object with matching ID for given search_id.

Parameters:

  • search_id (str) –

    ID to search for within objects of collection.

Returns:

  • T

    Object matching search_id.