Skip to content

Update Link Operation

Updates a link operation with data provided in a request body.

Request

HTTP Request

PATCH /node/api/links/:link_id/operations/:op_id

Permissions

linkPermissions & manage-links & manage-operations

Path parameters

Parameter Type Description
link_id String
required
The ID of a link whose operation should be updated.
op_id String
required
The ID of an operation to be updated.

Body parameters

This request uses the Operation model with some fields omitted. Note that the parameters field is different for each operation type and subtype.

Warning

You can't change the type and subtype of the operation during the update.

Fields that can be updated
Field Type Description
name String Operation's name.
description String Operation's description
popupResult Boolean Whether to show the results of the operation in a popup message.
parameters.message String An MQTT message. This parameter should be specified only for the MQTT message type.
parameters.topic String An MQTT topic. This parameter should be specified only for the MQTT message type.
parameters.path String A path to a script. This parameter should be specified only for the fileSystem subtype.
parameters.args Array<String> An array of script's input parameters. This parameter should be specified only for the fileSystem subtype.
parameters.ref String The ID of a script. This parameter should be specified only for the scriptReference subtype.
parameters.text String A script's source code. This parameter should be specified only for the scriptText subtype.

Request body

{
    "name": "New name for the operation",
    "description": "The updated description of the link operation",
    "popupResult": false,
    "parameters": {
        // Type-specific parameters
    }
}

Type-specific parameters:

MQTT parameters
{
    "name": "MQTT Link Operation",
    ...
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    }
}
Filesystem script parameters
{
    "name": "File System Link Script",
    ...
    "parameters": {
        "path": "/script_name.sh",
        "args": [
            "Hello",
            "World"
        ]
    }
}
Repository script parameters
{
    "name": "Repository Link Script",
    ...
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3"   // Script ID
    }
}
Plain text script parameters
{
    "name": "Plain Text Link Script",
    ...
    "parameters": {
        "text": "echo 'Hello World!'"
    }
}

Response

Returns the updated operation in the JSON format.

Examples

MQTT operation

Request example

login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/operations/$operation_id

curl -X PATCH $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
    "name": "Updated MQTT Operation",
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    },
    "description": "Updated Description",
    "popupResult": false,
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let operationId = <...>
let path = "/node/api/objects/" + objectId + "/operations/" + operationId;
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
    "name": "Updated MQTT Operation",
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    },
    "description": "Updated Description",
    "popupResult": false,
});

let requestOptions = {
    method: "PATCH",
    headers: headers,
    body: data
};

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 linkId = <...>
let operationId = <...>
let path = "/node/api/links/" + linkId + "/operations/" + operationId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "PATCH",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "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);
    });
});

let data = JSON.stringify({
    "name": "Updated MQTT Operation",
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    },
    "description": "Updated Description",
    "popupResult": false,
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/operations/" + operation_id

body =  {
    "name": "Updated MQTT Operation",
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    },
    "description": "Updated Description",
    "popupResult": False,
}

response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)

Response example

{
    "name": "Updated MQTT Operation",
    "parameters": {
        "topic": "New MQTT Topic",
        "message": "New MQTT Message Text"
    },
    "description": "Updated Description",
    "type": 1,
    "popupResult": false,
    "id": "62d9331aac866e4fcc1f21c0"
}

File system script operation

Request example

login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/operations/$operation_id

curl -X PATCH $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
    "name": "Updated Filesystem Script",
    "description": "Updated description",
    "popupResult": false,
    "parameters": {
        "path": "/script_name.sh",
        "args": [
            "Hello",
            "World"
        ]
    }
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let operationId = <...>
let path = "/node/api/objects/" + objectId + "/operations/" + operationId;
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
    "name": "Updated Filesystem Script",
    "description": "Updated description",
    "popupResult": false,
    "parameters": {
        "path": "/script_name.sh",
        "args": [
            "Hello",
            "World"
        ]
    }
});

let requestOptions = {
    method: "PATCH",
    headers: headers,
    body: data
};

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 linkId = <...>
let operationId = <...>
let path = "/node/api/links/" + linkId + "/operations/" + operationId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "PATCH",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "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);
    });
});

let data = JSON.stringify({
    "name": "Updated Filesystem Script",
    "description": "Updated description",
    "popupResult": false,
    "parameters": {
        "path": "/script_name.sh",
        "args": [
            "Hello",
            "World"
        ]
    }
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/operations/" + operation_id

body =  {
    "name": "Updated Filesystem Script",
    "description": "Updated description",
    "popupResult": False,
    "parameters": {
        "path": "/script_name.sh",
        "args": [
            "Hello",
            "World"
        ]
    }
}

response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)

Response example

{
    "name": "Updated Filesystem Script",
    "description": "Updated description",
    "type": 2,
    "popupResult": false,
    "parameters": {
        "path": "/script_name.sh",
        "type": "fileSystem",
        "args": [
            "Hello",
            "World"
        ]
    },
    "id": "62d95c18b238aa0131bd3b64"
}

Repository script operation

Request example

login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/operations/$operation_id

curl -X PATCH $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
    "name": "Updated Repository Script",
    "description": "Updated Script from repository",
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3",
    },
    "popupResult": True
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let operationId = <...>
let path = "/node/api/objects/" + objectId + "/operations/" + operationId;
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
    "name": "Updated Repository Script",
    "description": "Updated Script from repository",
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3",
    },
    "popupResult": True
});

let requestOptions = {
    method: "PATCH",
    headers: headers,
    body: data
};

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 linkId = <...>
let operationId = <...>
let path = "/node/api/links/" + linkId + "/operations/" + operationId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "PATCH",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "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);
    });
});

let data = JSON.stringify({
    "name": "Updated Repository Script",
    "description": "Updated Script from repository",
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3",
    },
    "popupResult": True
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/operations/" + operation_id

body = {
    "name": "Updated Repository Script",
    "description": "Updated Script from repository",
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3",
    },
    "popupResult": True
}

response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)

Response example

{
    "name": "Updated Repository Script",
    "parameters": {
        "ref": "5ecfc1e06d9341263ceaaeb3",
        "type": "scriptReference"
    },
    "description": "Updated Script from repository",
    "type": 2,
    "popupResult": false,
    "id": "62d9353d60d9d84f03997b22"
}

Plain text script operation

Request example

login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/operations/$operation_id

curl -X PATCH $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
    "name": "Updated Plain Text Link Script",
    "description": "Updated plain text script",
    "parameters": {
        "text": "echo \"Updated operation!\""
    },
    "popupResult": True
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let operationId = <...>
let path = "/node/api/objects/" + objectId + "/operations/" + operationId;
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
    "name": "Updated Plain Text Link Script",
    "description": "Updated plain text script",
    "parameters": {
        "text": "echo \"Updated operation!\""
    },
    "popupResult": True
});

let requestOptions = {
    method: "PATCH",
    headers: headers,
    body: data
};

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 linkId = <...>
let operationId = <...>
let path = "/node/api/links/" + linkId + "/operations/" + operationId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "PATCH",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "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);
    });
});

let data = JSON.stringify({
    "name": "Updated Plain Text Link Script",
    "description": "Updated plain text script",
    "parameters": {
        "text": "echo \"Updated operation!\""
    },
    "popupResult": True
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/operations/" + operation_id

body = {
    "name": "Updated Plain Text Link Script",
    "description": "Updated plain text script",
    "parameters": {
        "text": "echo \"Updated operation!\""
    },
    "popupResult": True
}

response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)

Response example

{
    "name": "Updated Plain Text Link Script",
    "description": "Updated Description",
    "type": 2,
    "parameters": {
        "type": "scriptText",
        "text": "echo \"Updated operation\""
    },
    "popupResult": true,
    "id": "62df037cb238aa0131bd3b93"
}