Miscellaneous Cloud Workflow Functions
• | assert |
• | signer |
• | jwt_encode |
• | keys |
• | map |
• | now |
• | rand |
• | sleep |
• | sleep_until |
• | sleep_while |
• | uuid |
• | values |
• | xpath |
Syntax
assert(expression)
Description
This function evaluates an assertion. It takes an expression that resolves to a value as an argument. If the expression does not resolve to a value, resolves to null, or resolves to false then an error is raised. In all other cases it does nothing.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Expression |
Yes |
None |
The expression that should return a value to assert |
Result
None
Syntax
signer($identifier)
Description
Return a signer reference as defined in the Credentials dashboard. For details, refer to Managing Credentials for Policy Access to External Systems.
Note:Note the following:
• | For policy developers: signer references are automatically imported for all credentials and auth blocks from the Policy engine. |
• | Using this function requires the admin role, or Permissions that grant the admin role. |
• | Must exactly match the identifier field of the credential. |
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
String |
Yes |
None |
The identifier of the Credential. |
Result
A reference to the Credentials resource, or raises an error if the Credentials are not found or the user doesn't have the required privileges.
Syntax
jwt_encode($algorithm, $payload, $key, $header_fields)
Description
This function creates a JWT from the fields provided. For more information on json web tokens visit: https://jwt.io/
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
String |
Yes |
None |
Encryption Algorithms Supported: RS256, RS384, RS512, HS256, HS512256, HS384, HS512 |
2 |
Hash |
Yes |
None |
Hash Payload for jwt token |
3 |
String |
Yes |
None |
Encryption key for the payload, RS* Encryption requires an RSA Key |
4 |
Hash |
No |
None |
Header fields, such as typ |
Result
A string containing a jwt token.
Syntax
keys($hash)
Description
Return an array made of all the keys of the provided hash.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Hash |
Yes |
None |
Hash for which keys should be retrieved |
Result
Array of strings representing all the keys of the provided hash.
Syntax
map($mapping_name, $key_name, $value_name)
Description
Return the value of a two-level hash given a key and value name. This function is syntactic sugar around the [] operator. It may provide a better notation when writing declarative code (for example, in resource declarations). Using map($hash, $key, $value) is equivalent to $hash[$key][$value].
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Hash |
Yes |
None |
Hash for which value should be retrieved |
2 |
String |
Yes |
None |
Name of key |
3 |
String |
Yes |
None |
Name of value |
Result
Hash value at given key and value name.
Syntax
now()
Description
Returns the current time in a datetime value. See the strftime function for formatting a datetime into a string.
Arguments
None
Result
Date time value that represents the current time in UTC.
Syntax
rand($max_value)
Description
Generates a random number. If max_value if specified, the random number is an integer between 0 and max_value. If max_value is not specified, the random number is a double between 0 and 1.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Number |
No |
See above Description section. |
Max number to generate a random integer |
Syntax
sleep($duration)
Description
Makes the current task sleep for the time expressed in duration. A duration consists of numbers suffixed with s (seconds), m (minutes), h (hours), or d (days). Each element of the duration is additive (for example, 2m30s means 2 minutes plus 30 seconds). If no suffix is specified, then the number represents seconds.
Arguments
Position |
Possible Values |
Required |
Default Value |
1 |
Duration |
Yes |
None |
Examples
sleep(60) # sleep one minute
sleep(1h) # sleep 60 minutes
sleep(2m30s) # sleep 150 seconds
Result
None
Syntax
sleep_until(expression)
Description
This function takes an expression that resolves to a value as argument. If the expression does not resolve to a value, then an error is raised. Sleeps until the expression evaluates to a value that is neither null nor false.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Expression |
Yes |
None |
The expression that should return a value that is neither null nor false for the wait to stop |
Result
None
Syntax
sleep_while(expression)
Description
This function takes an expression that resolves to a value as argument. If the expression does not resolve to a value then an error is raised. Sleeps while the expression evaluates to a value that is neither null nor false.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Expression |
Yes |
None |
The expression that is run |
Result
None
Syntax
uuid()
Description
Returns a string containing a Universally Unique IDentifier (UUID).
Arguments
None
Result
A string containing a UUID.
Syntax
values($hash)
Description
Return an array made of all the values of the provided hash.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
Hash |
Yes |
None |
Hash for which values should be retrieved |
Result
Array of strings representing all the values of the provided hash.
Syntax
xpath($xml_string, $xpath)
Description
Using a XPath string, extracts information out of an XML string.
Arguments
Position |
Possible Values |
Required |
Default Value |
Comment |
1 |
String |
Yes |
None |
XML string |
2 |
String |
Yes |
None |
XPath string like //item[2]/name/text() or css:div.li path |
The xpath argument can be passed a css: prefix, in which case the path is a CSS path, not a XPath.
Result
Array of [XML] strings.