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",
)
```
CelonisCollection ¶
Bases: List[T]
Class to make lists searchable.
from_list
classmethod
¶
Convert list to Celonis Collection.
Parameters:
-
list_(List) –List to convert.
Returns:
-
CelonisCollection–CelonisCollection from given list.
find_all ¶
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:
-
CelonisCollection[T]–CelonisCollection with matching objects.
find ¶
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_termforsearch_attribute.
Raises:
-
PyCelonisNotFoundError–Raised if no object in collection matches
search_termforsearch_attributeand no default given. -
PyCelonisValueError–Raised if multiple objects in collection match
search_termforsearch_attribute.