All Products
Search
Document Center

Built-in functions

Last Updated: May 03, 2020

Operation Orchestration Service (OOS) provides multiple built-in functions to help you process the parameters and outputs of templates.

Built-in functions

  • Fn::Base64Encode: returns the Base64-encoded result of the source string.
  • Fn::Base64Decode: returns the Base64-decoded result of the source string.
  • Fn::MergeMapToList: returns a list in which multiple maps are merged.
  • Fn::MergeMap: returns a map in which multiple maps are merged.
  • Fn::Join: returns a string in which the elements in a list are joined by a specified separator.
  • Fn::Select: returns a data element from a data element container based on a specified index.
  • Fn::Split: splits a string into a number of substrings by using a specified separator and returns a list of the substrings.
  • Fn::Replace: returns a string in which a specified substring has been replaced with another substring.
  • Fn::Min: returns the element with the smallest value in the list.
  • Fn::Max: returns the element with the largest value in the list.
  • Fn::First: returns the first element in the list.
  • Fn::Last: returns the last element in the list.
  • Fn::ListJoin: returns a list in which multiple elements are joined.
  • Fn::Equals: compares whether two values are equal.
  • Fn::If: evaluates a condition and returns different values based on the evaluation result.
  • Fn::Not: performs the NOT operation on a condition.
  • Fn::AddHour: changes the time zone by offsetting N hours from the UTC time.
  • Fn::FormatUTCTime: Changes the time granularity of the UTC time as required.
  • Fn::Eval: executes an expression in a single line in a string and returns the execution result.
  • Fn::CalculateTimeByOpsWindow: returns a time point in the specified time period based on the execution time of this function.

Syntax

A built-in function consists of the name of the function and the parameters to be processed. When you call the function expression, the function processes the parameters and returns a result. The function expression can be referenced like other parameters.

Fn::Base64Encode

Returns the Base64-encoded result of the source string.

Syntax

  1. Fn::Base64Encode : StringToBeBase64

Parameters
StringToBeBase64: the string to be encoded in Base64.

Return values
The Base64-encoded result of the source string.

Fn::Base64Decode

Returns the Base64-decoded result of the source string.

Syntax

  1. Fn::Base64Decode : Base64ToBeString

Parameters
Base64ToBeString: the Base64-encoded string.

Return values
The Base64-decoded result of the source string.

Fn::MergeMapToList

Returns a list in which multiple maps are merged.

Syntax

  1. Fn::MergeMapToList: aListConatinsDicts

Parameters
aListContainsDicts: a list that contains multiple maps.

Return values
A list in which multiple maps are merged.

Fn::MergeMap

Returns a map in which multiple maps are merged.

Syntax

  1. Fn::MergeMap: aListConatinsDicts

Parameters
aListContainsDicts: a list that contains multiple maps.

Return values
A map in which multiple maps are merged.

Fn::Join

Returns a string in which the elements in a list are joined by a specified separator.

Syntax

  1. Fn::Join:
  2. - Connector
  3. - aListContainsString

Parameters
Connector: the string used to separate the elements in the returned string.
aListContainsString: a list that contains the elements to be joined.

Return values
A string in which the elements in the list are joined.

Fn::Select

Returns a data element from a data element container based on a specified index.

Syntax

  1. Fn::Select:
  2. - Index
  3. - Container

Parameters
Index: the String or Number index used to query a data element from the container.
Container: a list or map to be queried.

Return values
A data element queried from the container based on the index.

Fn::Split

Splits a string into a number of substrings by using a specified separator and returns a list of the substrings.

Syntax

  1. Fn::Split:
  2. - Separator
  3. - StringToSeprate

Parameters
Separator: the string used to split the source string.
StringToSeprate: the string to be split by the separator.

Return values
A list of substrings split by the separator.

Fn::Replace

Returns a string in which a specified substring has been replaced with another substring.

Syntax

  1. Fn::Replace:
  2. - $varName: StringToReplaceWith
  3. - StringToReplace

Parameters
$varName: a placeholder that starts with the dollar sign ($) followed by a common parameter name. The name requirements for the parameter after the dollar sign ($) are the same as those for the template parameters.
StringToReplaceWith: the substring used to replace the placeholder.
StringToReplace: the substring, including the placeholder, to be replaced, such as $varName is foo.

Return values
If the StringToReplaceWith parameter is set to baz, the returned string is baz is foo.

Fn::Min

Returns the element with the smallest value in the list.

Syntax

  1. Fn::Min: aList

Parameters
aList: a list that contains elements. The types of the elements in the list can be String, Int, Datetime, or None. All elements in the same list must be of the same type.

Return values
The element with the smallest value in the list excluding the element whose value is None. If the values of all elements in the list are None, None is returned.

Fn::Max

Returns the element with the largest value in the list.

Syntax

  1. Fn::Max: aList

Parameters
aList: a list that contains elements. The types of the elements in the list can be String, Int, Datetime, or None. All elements in the same list must be of the same type.

Return values
The element with the largest value in the list excluding the element whose value is None. If values of all elements in the list are None, None is returned.

Fn::First

Returns the first element in the list.

Syntax

  1. Fn::First: aList

Parameters
aList: a list that contains elements. The types of the elements in the list are not limited.

Return values
The first element returned for an iteration. For a loop task, the elements are sorted based on the task execution IDs generated for iterations.


Fn::Last

Returns the last element in the list.

Syntax

  1. Fn::Last: aList

Parameters
aList: a list that contains elements. The types of the elements in the list are not limited.

Return values
The last element returned for an iteration. For a loop task, the elements are sorted based on the task execution IDs generated for iterations.

Fn::ListJoin

Returns a list in which multiple elements are joined.

Syntax

  1. Fn::ListJoin: IterableContainer

Parameters
IterableContainer: a set of iterable elements. The types of the elements in the set are not limited.

Return values
A list in which the elements in the set are joined.

Fn::Equals

Compares whether two values are equal. If the two values are equal, true is returned. If the two values are not equal, false is returned.

Syntax

  1. Fn::Equals: ["parameter1", "parameter2"]

Parameters
parameter1 and parameter2: the values to be compared. The types of the values are not limited.

Return values
If the two values are equal, true is returned. If the two values are not equal, false is returned.

Fn::If

Evaluates a condition and returns different values based on the evaluation result.

Syntax

  1. Fn::If: ["condition_name", "value_if_true", "value_if_false"]

Parameters
condition_name: the condition to be evaluated.
value_if_true: the value to be returned if the specified condition is evaluated as true.
value_if_false: the value to be returned if the specified condition is evaluated as false.

Return values
If the specified condition is evaluated as true, value_if_true is returned.
If the specified condition is evaluated as false, value_if_false is returned.

Fn::Not

Performs the NOT operation on a condition.

Syntax

  1. Fn::Not: condition

Parameters
condition: the condition on which you want to perform the NOT operation.

Return values
If the condition is evaluated as true, false is returned. If the condition is evaluated as false, true is returned.

Fn::AddHour

Changes the time zone by offsetting N hours from the UTC time.

Syntax

  1. Fn::AddHour: ["utc_time", "hours_count"]

Parameters
utc_time: the UTC time to be changed.
hours_count: the number of hours that you want to offset from the UTC time. The value must be an integer.

Return values
The UTC+N or UTC-N time.
Example function

  1. Fn::AddHour: ["2019-06-01T02:12:45Z", 6]

Example return values

  1. "2019-06-01T08:12:45Z"

Fn::FormatUTCTime

Changes the time granularity of the UTC time as required.
Syntax

  1. Fn::FormatUTCTime: ["utc_time", "to_be_utc_time_format"]

Parameters
utc_time: the UTC time for which you want to change the time granularity.
to_be_utc_time_format: the specified time granularity.

Return values
The UTC time in the specified time granularity.

Example function

  1. Fn::FormatUTCTime: ["2019-06-01T02:12:45Z", "%Y-%m-%dT%H:%MZ"]

Example return values

  1. 2019-06-01T02:12Z

Fn::Eval

Executes an expression in a single line in a string and returns the execution result. Note that you cannot use this function to execute expressions that contains any line breaks.
Syntax

  1. Fn::Eval: ["expression"]

Parameters
expression: the expression to be executed, such as an operation expression.

Return values
The execution result of the expression.

Example function

  1. Fn::Eval: ["1+3*2+3%2+1"]

Example return values

  1. 9

Fn::CalculateTimeByOpsWindow

Returns a time point in the specified time period based on the execution time of this function. Note that the time period must be less than 24 hours. The Fn::CalculateTimeByOpsWindow function returns a time point by following these rules: If the function is executed during the specified time period on the current day, it returns the time point which is one minute later than the execution time of the specified function. If the function is executed earlier than the start time of the time period on the current day, it returns a random time point during the time period on the current day. If the function is executed later than the end time of the time period on the current day, it returns a random time point during the time period on the next day after it is executed.
Syntax

  1. Fn::CalculateTimeByOpsWindow : [ "startTime", "endTime" ]

Parameters
startTime: the start of the time period, such as 01:00:00Z.
endTime: the end of the time period, such as 03:00:00Z. Note that the interval between the start time and end time must be less than 24 hours.

Return values
A string that indicates a time point in the specified time period, in UTC.

Example function

  1. Fn::CalculateTimeByOpsWindow : [ "01:00:00Z", "03:00:00Z" ]

Example return values

  1. 2019-09-24T01:01:00Z