Forum Discussion

Mosh's avatar
Mosh
Icon for Professor rankProfessor
6 years ago

REST API endpoint device/groups/{id}/devices

We have a regional (Americas, EMEA, APAC) hierarchy in our Resources structure, and would like to be able to query via the API the total number of resources at a group level. 

Currently the API only returns items if the group has direct child resources, but if the group is there purely for taxonomy, then it returns no items.

We would like to be able to call an endpoint similar to /device/groups/{id}/devices which would return a total count of resources for the group, including all sub-groups.

Our use case is cross charging the regions for LogicMonitor costs, and for this we need to be able to automate the counting up of resource items for each region.  Basically we want to be able to get the same count we currently see in a resource group's tooltip, but via the API.

  • Just a word of caution -- we found long ago that using groups for taxonomy creates massive security problems if you also want to grant different users access to functional groups (e.g., SQL admins to SQL servers).  With RBAC as it is, if a device is in two or more such groups, you cannot give access that way without giving access to all groups the device is in (this is apparently not considered a bug).  There really needs to be an option to mark a group as a security group to avoid this.  In the meantime, we have moved from static groups almost entirely to dynamic groups.  Our biggest problem before was this one -- using location-based groups to organize devices and to avoid setting the location string many times.  Now we use custom propertysources to set a location property value to define a dynamic location group, and that group gets the location string. 

    As far as your issue, I assume you could recurse to get the data, but definitely there should be a way to do this in one shot, just like inherited properties.

  • Sarah_Terry's avatar
    Sarah_Terry
    Icon for Product Manager rankProduct Manager

    Hi @Mosh - The total number of resources (including those in sub-groups) should be returned in the group object information - i.e. GET /device/groups/ID. This is actually what the tooltip in the UI is pulling from. Have you tried this yet?

  • 32 minutes ago, Sarah Terry said:

    Hi @Mosh - The total number of resources (including those in sub-groups) should be returned in the group object information - i.e. GET /device/groups/ID. This is actually what the tooltip in the UI is pulling from. Have you tried this yet?

    Ah! Thanks @Sarah Terry  I was looking at the documentation which all had examples with another path after the /id and it never occurred to me to try just up to the id!

    Cheers.