REST API - Parent oder Children finden
-
Hallo!
Über die REST API kann ich ja sehr schön einzelnen Objekte auslesen.
Wie finde ich raus, welche "Floors" zu welchem "Building" gehören? Dazu finde ich einfach nichts.zb:
Dieser Request:{
"version": "2.0",
"method": "cmdb.object.read",
"params": {
"id": 41,
"apikey": "c1ia5q",
"language": "en"
},
"id": 1
}liefert dieses Objekt:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"id": 41,
"title": "Basement",
"sysid": "FLOOR_0000041",
"objecttype": 88,
"type_title": "Floor",
"type_icon": "room.gif",
"status": 2,
"cmdb_status": 6,
"cmdb_status_title": "in operation",
"created": "2015-02-20 15:56:30",
"updated": "2015-09-10 14:43:58",
"image": "https://demo.i-doit.com/images/objecttypes/room.png"
}
}Das ist ein Floor der an einem Building hängt. Wie sehe ich das über die API?
lg
Frafu -
Da "Floor" und "Building" mit dem Standort zusammenhängt, wäre wohl die Methode cmdb.location_tree.read die richtige. Die funktioniert aber m.W. nur "abwärts" von der Location Root (Object-ID 1) aus. Eventuell kommt man auch mit cmdb.objects_by_relation.read weiter. Dafür müsste man aber die Konstante für den relation_type kennen (die m.W. nirgends richtig dokumentiert sind).
-
Hallo zusammen,
@MartinV hatte es richtig erkannt - um die zugewiesenen Standorte eines Objekts zu erhalten braucht man die Methode
cmdb.location_tree.readhier kann man mittels Parameteridentscheiden wessen "children" man sehen möchte.Also z.B.
{ "version": "2.0", "method": "cmdb.location_tree.read", "params": { "id": 1234, "apikey": "<key>" }, "id": 1 }Im Ergebnis erhält man dann ein Array mit allen direkt zugewiesenen Objekten, die Daten schauen dabei so aus (pro Objekt):
[ { "id": 302, "title": "0.01 Office", "sysid": "ROOM_00000302", "type": 26, "type_title": "Room", "status": 2, "cmdb_status": 6, "cmdb_status_title": "in operation" }, { "id": 1073, "title": "pool.ntp.org", "sysid": "CLOUD_0001073", "type": 39, "type_title": "Host", "status": 2, "cmdb_status": 6, "cmdb_status_title": "in operation" }, ... ]Viele Grüße
Leo
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login