Get Object’s Parent Paths
Get hierarchy path from the specified object to the root object.
Request
Response
Response contains two lists — paths
and objects
.
-
paths
contains IDs of every parent object (including the root object) and the ID of the requested object itself. The first element in the list is the requested object, the last is the root object. -
objects
list contains information about each object in the path. You can select returned fields with thefields
query parameter. You can see the list of all possible fields in the Object model article.
If the object has multiple paths to the root (for example, there is an object with multiple parents in the path), the path list will contain a list of all possible paths. Entries in the objects list will not be duplicated.
|
By default, each object includes the following fields:
Field | Type | Description |
---|---|---|
id |
String |
Object’s ID. |
name |
String |
Object’s name. |
class_id |
String |
The ID of an object class. |
child_ids |
Array<String> |
An array of object’s child objects IDs. |
child_link_ids |
Array<String> |
An array of object’s child links IDs. |
child_ref_ids |
Array<String> |
An array of object’s child references IDs. |
parent_id |
Array<String> |
The IDs of an object’s parents. |
geoposition |
Array<Float> |
Object’s position on a map. It’s specified as an array of two float numbers, where the first number is longitude, the second one is latitude. |
geopositionRadius |
Integer |
The radius of an object’s area displayed on a map. |
state_id |
String |
The ID of an object state. |
last_state_update |
Integer |
A timestamp when object’s state was last updated. |
Examples
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
object_id=<...>
url=https://$saymon_hostname/node/api/objects/$object_id/paths?fields=id,name
curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let path = "/node/api/objects/" + objectId + "/paths?fields=id,name";
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 objectId = <...>
let path = "/node/api/objects/" + objectId + "/paths?fields=id,name";
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 = <...>
object_id = <...>
url = "https://" + saymon_hostname + "/node/api/objects/" + object_id + "/paths?fields=id,name"
response = requests.request("GET", url, auth=(login, password))
print(response.text)
Response
{
"paths": [
[
"59367b82ffb40f0b89504a96",
"59318c33ce35c42e1c8b4efa",
"5926c944beefaf6c11526a11",
"5641e41511039b1637d31c9b",
1
],
[
"59367b82ffb40f0b89504a96",
"59318c33ce35c42e1c8b4efa",
"5926c944beefaf6c11526a11",
"5821c8ddd0240f4f5a7dba04",
"5800d9aaac7bf0f90d3d520e",
1
],
[
"59367b82ffb40f0b89504a96",
"59318c33ce35c42e1c8b4efa",
"5926c944beefaf6c11526a11",
1
]
],
"objects": [
{
"name": "Staging",
"id": 1
},
{
"name": "Test Host",
"id": "5641e41511039b1637d31c9b"
},
{
"name": "BlackBox",
"id": "5800d9aaac7bf0f90d3d520e"
},
{
"name": "Data",
"id": "5821c8ddd0240f4f5a7dba04"
},
{
"name": "Demo and Test",
"id": "5926c944beefaf6c11526a11"
},
{
"name": "CDR Data",
"id": "59318c33ce35c42e1c8b4efa"
},
{
"name": "sum",
"id": "59367b82ffb40f0b89504a96"
}
]
}