if

Description

Performs actions based on whether a condition is true.

The "condition" property specifies an action to execute. The condition is true if the action returns true. Otherwise the condition is false.

If the condition is true, the actions within the "then" property are executed.

If the condition is false, the actions within the "else" property are executed (if specified).

Properties

NameRequiredTypeDescription
conditionyesactionAction that tests whether condition is true.
thenyesarray of actionsOne or more actions to perform if condition is true.
elsenoarray of actionsOne or more actions to perform if condition is false.

Return Value

If the condition was true, returns the value of the last action in the "then" property.

If the condition was false, returns the value of the last action in the "else" property. If no "else" property was specified, returns false.

Example

{
  "comments": [ "If regulator is downlevel use different configuration rule" ],
  "if": {
    "condition": {
      "run_rule": "is_downlevel_regulator"
    },
    "then": [
      { "run_rule": "configure_downlevel_regulator" }
    ],
    "else": [
      { "run_rule": "configure_standard_regulator" }
    ]
  }
}