API filter expression for dictionary content

At the moment I use:

object Host "usv1.domain.tld" {
  vars.loc = "sr1rack1_v"

and this works very well for me:

curl ... -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/hosts' -d '{ "attrs": [ "__name" ], "filter": "host.vars.loc == \"sr1rack1_v\"" }'''

But now I would like to use a dictionary

object Host "usv1.domain.tld" {
  vars.locating = { "level" = "Kellergeschoss","room" = "Serverraum1","position" = "Rack1" }

Iam look now for a filter expression which looks into the dictionary:

a) how could I get host objects with position=Rack1
b) how could I get host objects with several conditions like: level=Kellergeschoss && room=Serverraum1

Thank you in advance


the first query should be:

curl ... -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/hosts' -d '{ "attrs": [ "__name" ], "filter": "host.vars.locating.position == \"Rack1\"" }'''

and the second one:

curl ... -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/hosts' -d '{ "attrs": [ "__name" ], "filter": "host.vars.locating.level == \"Kellergeschoss\" && host.vars.locating.room == \"Serverraum1 \"" }'''

If the variable is a dictionary you can jump into it with a point .


1 Like

Works perfect!
Thank you very much.