Forum Discussion
v1 and v2 (and to my knowledge v3) of the API allow you to specify that you want to filter for any records where there's a property with a specific name and a property with a specific value; however, you cannot filter for a specific property with a specific name and a specific value.
Example:
Device1: prop1: A, prop2: A
Device2: prop1: B, prop2: A
filter="name:\"prop1\",value:\"A\"" will return any devices that have a property called "prop1" and also contain any property with a value of "A". This filter will match on both Device1 and on Device2. This is because the "value" criteria, while it's ANDed with the name criteria doesn't mean "prop1 has a value of A" it means, "is there a value of A". IMO, this makes filtering by properties pretty much useless and you have to do something else to filter by properties.
For this reason in most of my calls, I don't filter by properties. I either: 1) create a dynamic group and grab /device/groups/{id}/devices or 2) I apply any other filtering in my API call, then as soon as I have the data, I create a single new dictionary under the device called properties using the name as the key and the value as the value. In python this is done this way:
devices = lm.get_device_list(size=1000).items #should do something to account for page size for d in devices: properties = {x.name:x.value for x in (d.system_properties + d.auto_properties + d.inherited_properties + d.custom_properties)}
Related Content
- 2 years ago