Skip to main content

Miscellaneous Cloud Workflow Functions

The following miscellaneous Cloud Workflow functions are described in this section:

assert

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

PositionPossible ValuesRequiredDefault ValueComment
1ExpressionYesNoneThe expression that should return a value to assert

Result

None

signer

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

PositionPossible ValuesRequiredDefault ValueComment
1StringYesNoneThe 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.

jwt_encode

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

PositionPossible ValuesRequiredDefault ValueComment
1StringYesNoneEncryption Algorithms Supported: RS256, RS384, RS512, HS256, HS512256, HS384, HS512
2HashYesNoneHash Payload for jwt token
3StringYesNoneEncryption key for the payload, RS* Encryption requires an RSA Key
4HashNoNoneHeader fields, such as typ

Result

A string containing a jwt token.

keys

Syntax

keys($hash)

Description

Return an array made of all the keys of the provided hash.

Arguments

PositionPossible ValuesRequiredDefault ValueComment
1HashYesNoneHash for which keys should be retrieved

Result

Array of strings representing all the keys of the provided hash.

map

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

PositionPossible ValuesRequiredDefault ValueComment
1HashYesNoneHash for which value should be retrieved
2StringYesNoneName of key
3StringYesNoneName of value

Result

Hash value at given key and value name.

now

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.

rand

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

PositionPossible ValuesRequiredDefault ValueComment
1NumberNoSee above Description section.Max number to generate a random integer

sleep

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

PositionPossible ValuesRequiredDefault Value
1DurationYesNone

Examples

sleep(60) # sleep one minute 
sleep(1h) # sleep 60 minutes
sleep(2m30s) # sleep 150 seconds

Result

None

sleep_until

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

PositionPossible ValuesRequiredDefault ValueComment
1ExpressionYesNoneThe expression that should return a value that is neither null nor false for the wait to stop

Result

None

sleep_while

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

PositionPossible ValuesRequiredDefault ValueComment
1ExpressionYesNoneThe expression that is run

Result

None

uuid

Syntax

uuid()

Description

Returns a string containing a Universally Unique IDentifier (UUID).

Arguments

None

Result

A string containing a UUID.

values

Syntax

values($hash)

Description

Return an array made of all the values of the provided hash.

Arguments

PositionPossible ValuesRequiredDefault ValueComment
1HashYesNoneHash for which values should be retrieved

Result

Array of strings representing all the values of the provided hash.

xpath

Syntax

xpath($xml_string, $xpath)

Description

Using a XPath string, extracts information out of an XML string.

Arguments

PositionPossible ValuesRequiredDefault ValueComment
1StringYesNoneXML string
2StringYesNoneXPath 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.