Rules

If you prefer to receive notifications only when predefined criteria are met, you can set up rules when creating a webhook. The rules consist of three components: variable, operation, and value.

The available operations vary depending on the data type of the variable:

uuid and string

EQUAL, NOT_EQUAL, IN, NOT_IN

integer

EQUAL, NOT_EQUAL, IN, NOT_IN, LESS_THAN, GREATER_THAN

date and time

LESS_THAN, GREATER_THAN

boolean

EQUAL, NOT_EQUAL

Rules must be specified during the creation of a webhook, provided via the rules attribute. Below is an example of a body with multiple rules for reference:

{   
    "description": "airflow_trigger_example",
    "is_active": true,
    "jobs": [
        "uuid_1", 
        "uuid_2", 
        ..., 
        "uuid_n"
    ],
    "method": "POST",
    "url": "https://{{variables.TOOL_URL}}/api/v1/dags/{{erathos.JOB_ID}}/dagRuns",
    "header": {
        "Content-Type": "application/json",
        "Authorization": "Basic ${{secrets.USER_KEY}}"
    },
    "body": {
        "conf": {
            "name": "{{erathos.TABLE_NAME}}",
            "status": "${{erathos.STATUS}}"
        }
    },
    "rules": [
        {
            "erathos_variable": "STATUS",
            "operation": "EQUAL",
            "value": "FINISHED"
        },
        {
            "erathos_variable": "ROWS",
            "operation": "GREATER_THAN",
            "value": "0"
        },
        {
            "erathos_variable": "FINISHED_AT_TIME",
            "operation": "GREATER_THAN",
            "value": "00:00"
        },
        {
            "erathos_variable": "FINISHED_AT_TIME",
            "operation": "LESS_THAN",
            "value": "08:00"
        },
        {
            "erathos_variable": "FINISHED_AT_WEEKDAY",
            "operation": "NOT_IN",
            "value": ["0", "6"]
        }
    ]
}

To discover the variables available for creating rules, refer to Metadata.

Last updated