Get All Custom Triggers
Returns a list of all custom class trigger scripts in the system. Custom triggers allow you to run a script on object’s creation or deletion.
Custom triggers are executed by the server. |
Response
Returns a list of all custom class trigger scripts in the system. See the Class Model article to see how a custom trigger is defined in a model.
Custom trigger scripts have the following fields:
Field | Type | Description |
---|---|---|
id |
String |
ID of the script. ID should be a path to the trigger script. |
title |
String |
Title of the task. |
icon |
String |
The icon used in the web interface. |
args |
Array<Object> |
An array of script arguments. |
Script variables
You can pass the following variables into the script.
Field | Type | Description |
---|---|---|
{{body}} |
String |
Object’s body in the JSON format. |
{{class_id}} |
String |
Object’s class ID. |
{{client_data}} |
String |
Object’s Client Data. |
{{created}} |
Integer |
Timestamp of the object creation. |
{{geoposition}} |
String |
Object’s geoposition. |
{{geopositionRadius}} |
String |
Object’s geoposition radius. |
{{id}} |
String |
Object ID. |
{{entityId}} |
String |
Entity ID. |
{{last_state_update}} |
Integer |
Timestamp of the last State update. |
{{name}} |
String |
Object’s name. |
{{parent_id}} |
Array<String> |
List of parents' IDs. |
{{state_id}} |
String |
ID of the object’s State. |
{{tags}} |
Array<Tag> |
Object Tags. |
{{updated}} |
Integer |
Timestamp of the object update. |
You can also pass object’s properties as arguments with the following syntax:
{{properties.prop_name}}
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/entity-custom-triggers
curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/entity-custom-triggers";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Authorization", auth);
let requestOptions = {
method: "GET",
headers: headers
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/entity-custom-triggers/";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "GET",
"hostname": saymonHostname,
"headers": {
"Authorization": auth
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/entity-custom-triggers"
response = requests.request("GET", url, auth=(login, password))
print(response.text)
Response
[
{
"title": "Custom probe example",
"icon": "fa fa-folder fa-fw",
"excludeForClasses": [
1,
2
],
"args": [
{
"name": "Unnamed (positional) argument"
},
{
"name": "Named argument",
"id": "--name"
},
{
"name": "Argument with description",
"description": "Argument description",
"id": "--description"
},
{
"name": "Argument with default value",
"description": "Argument description",
"id": "--defval",
"default": "default_value"
},
{
"name": "Required argument",
"description": "This field is required to fill in",
"id": "--required",
"required": true
},
{
"name": "Type - Text",
"description": "This and all above fields have got text type",
"id": "--text",
"type": "text"
},
{
"name": "Type - Text Area",
"description": "This field is text area. \nIt is resizable in most browsers. \nAnd allows to enter multiline texts.",
"id": "--textarea",
"type": "textarea"
},
{
"name": "Type - Checkbox",
"description": "This is the checkbox type",
"id": "--checkbox",
"type": "checkbox"
},
{
"name": "Type - Password",
"description": "This is the password field",
"id": "--pass",
"default": "qwerty",
"type": "password"
},
{
"name": "Type - Select",
"description": "This is the select type. This description is not displayed in the web interface. Use description for each option instead.",
"id": "--select",
"default": "option2",
"type": "select",
"options": [
{
"description": "== Not selected =="
},
{
"value": "option1",
"description": "OK"
},
{
"description": "== Divider =="
},
{
"value": "option2",
"description": "Warning"
},
{
"value": "description"
}
]
}
]
}
{
"title": "Check SSH",
"icon": "fa fa-folder fa-fw",
"args": [
{
"name": "Host IP-address or DNS name"
},
{
"name": "Port",
"id": "-p"
}
],
"id": "Extras/check_ssh.sh"
},
...
]