Get All Classes

Returns a list of all existing classes.

This request doesn’t return all fields of classes. Check the Response section for more information.

Request

HTTP Request

GET /node/api/classes

Path parameters

No parameters required.

Request body

The request body is empty.

Response

Returns an array of all classes in the system. Uses the Class model.

This request doesn’t return all fields of classes. It returns fields based on whether they were assigned.

The following fields are returned for a newly created class.

Field Type Description

id

String

Class’s ID.

name

String

Class’s name.

operations

Array<Operation>

An array of class’s operations.

client_data

String

Class’s client data.

The rest of class’s fields are returned if they’ve been assigned a value. For example, if you add a property to a class, a list of properties will be included in the response.

However, even if you set the changed field to the default value (for example, delete all properties or set the description to an empty string), it would still be included in the response.

  • New class

  • Added a new property

  • Removed property, added description

{
    "name": "New class",
    "client_data": "{}",
    "operations": [],
    "id": "62fa271e18baa649c1d26338"
}
{
    "name": "New class",
    "client_data": "{}",
    "operations": [],
    "properties": [
        {
            "type_id": 1,
            "name": "New Property",
            "value": "Value",
            "id": "62fa26c0ad05cf4924c35569"
        }
    ],
    "id": "62fa1e20ad05cf4924c35550"
}
{
    "name": "New class",
    "client_data": "{}",
    "operations": [],
    "description": "Description",
    "properties": [],
    "id": "62fa1e20ad05cf4924c35550"
}

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

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

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/classes";
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/classes";
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/classes"

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

Response

[
    {
        "name": "Root",
        "operations": [],
        "properties": [],
        "description": "Root object",
        "default_agent_task_definition": "",
        "category_id": null,
        "id": 1
    },
    {
        "name": "Saymon Agent",
        "operations": [],
        "properties": [],
        "description": "Saymon Agent",
        "default_agent_task_definition": "",
        "id": 2
    },
    {
        "name": "Node",
        "operations": [],
        "default_agent_task_definition": "",
        "category_id": 3,
        "id": 13
    },
    ...
]