Functions
The Functions in Keep Workflow Engine are utilities that can be used to manipulate data, check conditions, or perform transformations within workflows. This document provides a brief overview and usage examples for each available function.
String Functions
uppercase
Description: Converts a string to uppercase.
Example:
lowercase
Description: Converts a string to lowercase. Example:
split
Description: Splits a string into a list using a delimiter. Example:
strip
Description: Removes leading and trailing whitespace from a string. Example:
replace
Description: Replaces occurrences of a substring with another string. Example:
remove_newlines
Description: Removes all newline and tab characters from a string. Example:
encode
Description: URL-encodes a string. Example:
List and Dictionary Functions
first
Description: Retrieves the first element from a list. Example:
last
Description: Retrieves the last element from a list. Example:
index
Description: Retrieves an element at a specific index from a list. Example:
join
Description: Joins a list of elements into a string using a delimiter. Example:
len
Description: Returns the length of a list. Example:
dict_to_key_value_list
Description: Converts a dictionary into a list of key-value pairs. Example:
Date and Time Functions
utcnow
Description: Returns the current UTC datetime. Example:
utcnowiso
Description: Returns the current UTC datetime in ISO format. Example:
to_utc
Description: Converts a datetime string or object to UTC. Example:
to_timestamp
Description: Converts a datetime object or string into a Unix timestamp. Example:
datetime_compare
Description: Compares two datetime objects and returns the difference in hours. Example:
is_business_hours
Description: Checks whether a given time falls within business hours. Example:
JSON Functions
json_dumps
Description: Converts a dictionary or string into a formatted JSON string. Example:
json_loads
Description: Parses a JSON string into a dictionary. Example:
Utility Functions
is_first_time
Description: Calculates the firing duration of an alert in specified time units. Example:
is_first_time
Description: Adds time to a date string based on specified time units. Example: