Update Class
Updates a class according to data provided in a request body. Returns the updated class in the JSON format.
Request
Request body
You can update any class parameter, apart from its id. See the Class model page for all available parameters.
{
"name": "updated_name",
"description": "Updated Description",
"client_data": "{\"default_view\":\"standard\",\"columns\":[{\"id\":\"state_id\",\"name\":\"State\",\"sort\":\"int\"},{\"id\":\"widgets\" ...},{\"id\":\"accidentTime\",\"name\":\"Time\"},{\"id\":\"duration\",\"name\":\"Duration\"},{\"id\":\"id\",\"name\":\"ID\",\"sort\":\"string\",\"hidden\":true},{\"id\":\"name\",\"name\":\"Name\",\"sort\":\"string\",\"hidden\":true}]}",
"operations": [
...
],
"properties": [
...
],
"category_id": 3
}
Response
Returns the updated class in the JSON format. See the Class model page for more information.
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_id
curl -X PATCH $url -u $login:$password \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"name": "Host",
"description": "Physical/virtual host"
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let classId = <...>
let path = "/node/api/classes/" + classId;
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": "Host",
"description": "Physical/virtual host"
});
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 path = "/node/api/classes/" + class_id;
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": "Host",
"description": "Physical/virtual host"
});
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
class_id = <...>
url = "https://" + saymon_hostname + "/node/api/classes/" + class_id
body = {
"name": "Host",
"description": "Physical/virtual host"
}
response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)