utils.py
Utilities to work with API objects.
HttpMethod
¶
Helper class for common used request methods.
Attributes:
Name | Type | Description |
---|---|---|
GET |
str |
|
POST |
str |
|
PUT |
str |
|
DELETE |
str |
|
KeyType
¶
Helper class for Celonis API key types.
Attributes:
Name | Type | Description |
---|---|---|
USER_KEY |
str |
|
APP_KEY |
str |
|
threaded(iterable, function, *args, **kwargs)
¶
Can be used to write parallel for loops using multiprocessing using joblib.Parallel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable |
Iterable |
An iterable of which each item will passed as argument to the function. |
required |
function |
Callable |
A function that should be able to handle each item passed by the iterable. |
required |
*args |
Additional arguments passed to the function. |
() |
|
**kwargs |
Additional keyword named arguments passed to function. |
{} |
Yields:
Type | Description |
---|---|
Generator |
Result of the function for each item in the iterable. |
check_uuid(_id)
¶
Checks whether a string is a valid uuid4.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_id |
str |
The ID as string. |
required |
Returns:
Type | Description |
---|---|
bool |
True if the string is a valid uuid4, else False. |
find_object_from_list(list_of_dicts, _id)
¶
Finds an object in a list of dicts by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
list_of_dicts |
List |
List of dictionaries with each dictionary containing a key called "id". |
required |
_id |
Union[str, int] |
The ID of the item to find in the list. |
required |
Returns:
Type | Description |
---|---|
Dict |
The item with the matching ID. |
pathify(weird_string, symbols_to_keep=' .')
¶
Deletes anything that is not an alphanumeric character or something in symbols_to_keep from the string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weird_string |
str |
String to be checked. |
required |
symbols_to_keep |
str |
String containing symbols to keep. |
' .' |
Returns:
Type | Description |
---|---|
str |
String without non alphanumeric characters except for |
check_outdated(version)
¶
Checks if the current PyCelonis version is outdated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
str |
PyCelonis version to be checked. |
required |
Returns:
Type | Description |
---|---|
Tuple[bool, str] |
Tuple of bool if version is outdated and string of latest version. |
equal_dicts(d1, d2, ignore_keys=None)
¶
Verifies whether two dicts are equal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d1 |
Dict |
First dictionary to be compared. |
required |
d2 |
Dict |
Second dictionary to be compared. |
required |
ignore_keys |
List[str] |
List of keys to be ignored. |
None |
Returns:
Type | Description |
---|---|
bool |
True if dictionaries are equal given |
update_dict(d1, d2)
¶
Updates a dictionary with values from another dictionary recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d1 |
Dict |
First dictionary to be extended. |
required |
d2 |
Dict |
Second dictionary to be copied. |
required |
Returns:
Type | Description |
---|---|
Dict |
First dictionary updated with valued form second dictionary. |