Get Class by ID

Returns the class with the specified ID.

Request

HTTP Request

GET /node/api/classes/:id

Path parameters

Parameter Type Description

id

String
required

The ID of the class to be retrieved.

Request body

The request body is empty.

Response

Returns the following fields from the Class model.

Field Type Description

id

String
required

Class’s ID.

name

String
required

Class’s name.

description

String

Class’s description

category_id

String

Class’s category ID. See a more detailed description below.

operations

Array<Operation>

An array of class’s operations.

You can get the remaining fields either with the Get All Classes request that returns all set fields of all classes in the system. You can also use specialized requests like Get Class Properties to get information about properties or EN/modules/ROOT/pages/documentation/methods/classes/state-conditions/get-class-state-conditions.adoc request to get class’s state conditions.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_id

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let classID = <...>
let auth = "Basic " + btoa(login + ":" + password)
let path = "/node/api/classes/" + classID

let myHeaders = new Headers();
myHeaders.append("Authorization", auth);

let requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch(saymonHostname + path, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
let http = require('follow-redirects').http;
let fs = require('fs');

let login = <...>
let password = <...>
let saymonHostname = <...>
let classId = <...>
let path = "/node/api/classes/" + classId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
  'method': 'GET',
  'hostname': '192.168.1.101',
  'path': '/node/api/classes/4',
  'headers': {
    'Authorization': auth
  },
  'maxRedirects': 20
};

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 = <...>
class_id = <...>
url = "http://" + saymon_hostname + "/node/api/classes/" + class_id

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

{
    "id": 4,
    "name": "CPU",
    "category_id": 1,
    "description": "Central Processor Unit",
    "operations": []
}