Update Class Operation
Updates a class operation with data provided in a request body.
Request
HTTP Request
Permissions
Path parameters
Parameter | Type | Description |
---|---|---|
class_id | Stringrequired |
The ID of a class whose operation should be updated. |
op_id | Stringrequired |
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
Type-specific parameters:
MQTT parameters
Filesystem script parameters
Repository script parameters
Plain text script parameters
Response
Returns the updated operation in the JSON format.
Examples
MQTT operation
Request
login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_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 classId = <...>
let operationId = <...>
let path = "/node/api/classes/" + classId + "/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 = <...>
class_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/classes/" + \
class_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
File system script operation
Request
login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_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 classId = <...>
let operationId = <...>
let path = "/node/api/classes/" + classId + "/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 = <...>
class_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/classes/" + \
class_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
Repository script operation
Request
login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_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 classId = <...>
let operationId = <...>
let path = "/node/api/classes/" + classId + "/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 = <...>
class_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/classes/" + \
class_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
Plain text script operation
Request
login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
operation_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_id/operations/$operation_id
curl -X PATCH $url -u $login:$password \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"name": "Updated Plain Text Class 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 Class 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 classId = <...>
let operationId = <...>
let path = "/node/api/classes/" + classId + "/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 Class Script",
"description": "Updated plain text script",
"parameters": {
"text": "echo \"Updated operation!\""
},
"popupResult": True
});
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
class_id = <...>
operation_id = <...>
url = "https://" + saymon_hostname + "/node/api/classes/" + \
class_id + "/operations/" + operation_id
body = {
"name": "Updated Plain Text Class 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)