Reputation: 1304
Is is possible to fetch inventory by more than one fragment type?
like
inventory/managedObjects?fragmentType=c8y_IsDevice&fragmentType=c8y_DistanceSensor
and is possible to konow the list of available fragments?
Upvotes: 0
Views: 574
Reputation: 718
Yes, check out the section "Query Language" on https://cumulocity.com/guides/reference/inventory. Your query would be:
$filter=(has(c8y_IsDevice) or has(c8y_DistanceSensor))
The query text needs to be encoded into valid HTTP query syntax (see http://www.w3schools.com/tags/ref_urlencode.asp). The encoded URL would be:
/inventory/managedObjects?q=%24filter%3D(has(c8y_IsDevice)%2Bor%2Bhas(c8y_DistanceSensor))
... which is a bit less readable. Note that queries using "or" tend to run slower.
You can currently not query for all available fragments in the system. This is something that can dynamically change at any time and can be extended by anyone.
Upvotes: 1