schedule_utils.py
get_custom_object_from_km_dict(km, object_id)
¶
Get a specific Custom Object from a Knowledge Model by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
km |
Dict |
Knowledge Model as Dictionary. |
required |
object_id |
str |
ID of the Custom object. |
required |
Exceptions:
Type | Description |
---|---|
PyCelonisNotFoundError |
If Custom Object could not be found. |
Returns:
Type | Description |
---|---|
Dict |
The Custom Object. |
Source code in celonis_api/studio/schedule_utils.py
def get_custom_object_from_km_dict(km: typing.Dict, object_id: str) -> typing.Dict:
"""Get a specific Custom Object from a Knowledge Model by ID.
Args:
km: Knowledge Model as Dictionary.
object_id: ID of the Custom object.
Raises:
PyCelonisNotFoundError: If Custom Object could not be found.
Returns:
The Custom Object.
"""
config = None
for obj in km.get("layer", {}).get("customObjects", []):
if obj.get("id") == object_id:
config = obj
config = config.get("customAttributes")
break
if config is None:
raise PyCelonisNotFoundError(f"No custom object with id: {object_id} found.")
return config
get_filters_from_km_dict(km, filter_ids)
¶
Get all Filters from a Knowledge Model by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
km |
Dict |
Knowledge Model as Dictionary. |
required |
filter_ids |
str |
Comma separated list of IDs of Filters. |
required |
Returns:
Type | Description |
---|---|
List |
A List of Filters. |
Source code in celonis_api/studio/schedule_utils.py
def get_filters_from_km_dict(km: typing.Dict, filter_ids: str) -> typing.List:
"""Get all Filters from a Knowledge Model by ID.
Args:
km: Knowledge Model as Dictionary.
filter_ids: Comma separated list of IDs of Filters.
Returns:
A List of Filters.
"""
ids = re.sub(r"\[|\]|\"", "", filter_ids).split(",")
filters = []
for f in km["layer"]["filters"]:
if f["id"] in ids:
filters += [f["pql"]]
return filters
get_km_dict_by_key(celonis, layer_id=None, knowledge_model_key=None)
¶
Get a Knowledge Model by Key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
celonis |
Celonis Base object. |
required | |
layer_id |
str |
Knowledge Model layer ID. |
None |
knowledge_model_key |
Key of the Knowledge Model. |
None |
Returns:
Type | Description |
---|---|
Dict |
The Knowledge Model. |
Source code in celonis_api/studio/schedule_utils.py
def get_km_dict_by_key(celonis, layer_id: str = None, knowledge_model_key=None) -> typing.Dict:
"""Get a Knowledge Model by Key.
Args:
celonis: Celonis Base object.
layer_id: Knowledge Model layer ID.
knowledge_model_key: Key of the Knowledge Model.
Returns:
The Knowledge Model.
"""
if layer_id is None and knowledge_model_key is not None:
layer_id = knowledge_model_key
return celonis.api_request(f"{celonis.url}/semantic-layer/api/layer/{layer_id}")
get_record_from_km_dict(km, record_metadata_id)
¶
Get a specific Record from a Knowledge Model by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
km |
Dict |
Knowledge Model as Dictionary. |
required |
record_metadata_id |
str |
ID of the Record. |
required |
Exceptions:
Type | Description |
---|---|
PyCelonisNotFoundError |
If Record could not be found. |
Returns:
Type | Description |
---|---|
Dict |
The Record. |
Source code in celonis_api/studio/schedule_utils.py
def get_record_from_km_dict(km: typing.Dict, record_metadata_id: str) -> typing.Dict:
"""Get a specific Record from a Knowledge Model by ID.
Args:
km: Knowledge Model as Dictionary.
record_metadata_id: ID of the Record.
Raises:
PyCelonisNotFoundError: If Record could not be found.
Returns:
The Record.
"""
record = None
for obj in km.get("layer", {}).get("records", []):
if obj.get("id") == record_metadata_id:
record = obj
break
if record is None:
raise PyCelonisNotFoundError(f"No record with id: {record_metadata_id} found.")
return record