cancel
Showing results for 
Search instead for 
Did you mean: 
Create a Post
Employee
Employee

How to find all objets with a tag or many tag

Hi,

Is it possible to search a object with a tag ?

If i use this JSON body, this don't work

{

  "limit" : 10,

  "offset" : 0,

  "order" : [ {

    "ASC" : "name"

  } ],

  "in" : [ "tags", "test" ],

  "type" : "object",

  "details-level" : "full"

}

I think the cause is tags not only a field but a array. Is it possible to search in a array ?

Or do you have some other idea to find all objects with a tag ?

Thanks

Labels (1)
Tags (2)
0 Kudos
2 Replies
Employee+
Employee+

Re: How to find all objets with a tag or many tag

Maybe start by searching for objects that have a tag, so tag is not empty, then on those, do a search in the tags array for the tag you need.

0 Kudos
Employee+
Employee+

Re: How to find all objets with a tag or many tag

Hi Marc,

It's possible to search for an object with a tag, but you must use the tag identifier (not name).

Search for objects with a tag identified as "a80dda2f-e616-4e53-b2cb-43efdb1791e3"

show-objects

{    
  "in": ["tags", "a80dda2f-e616-4e53-b2cb-43efdb1791e3"],
  "details-level": "full",    
  "type": "object"
}

Search for hosts with a tag identified as "a80dda2f-e616-4e53-b2cb-43efdb1791e3"

show-objects

{     
  "in": ["tags", "a80dda2f-e616-4e53-b2cb-43efdb1791e3"],
  "details-level": "full",
  "type": "host"
}

Search for networks with a tag identified as "a80dda2f-e616-4e53-b2cb-43efdb1791e3" OR "f671818b-7adc-4a41-a5d1-cec35e6f4a70"

show-objects


  "in" : ["tags", "a80dda2f-e616-4e53-b2cb-43efdb1791e3", "tags", "f671818b-7adc-4a41-a5d1-cec35e6f4a70"],
  "details-level" : "full",
  "type": "network"
}

PS For now it is not possible to search for an object by "tag AND tag" but you can intersect results of a few calls yourself.

0 Kudos