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

Most efficient way to get group member names via API?

Hi,

I need to export a list of all network and service groups' members by name, and am running into some issues doing that via the API.

When I get the information from a group, it returns the members' UIDs, as such:

{
'uid':'80dccaca-b24b-437c-8bf9-3db51369ba45',
'name':'xxxxxxxxxxxx.com_subnets',
'type':'group',
'domain':{
'uid':'41e821a0-3720-11e3-aa6e-0800200c9fde',
'name':'SMC User',
'domain-type':'domain'
},
'members':[
'475841b2-bccf-4b77-984a-7d2152dfbf97',
'5cc36867-b259-4708-897f-0741b8de4910',
'27d3f6ec-d566-4586-ad48-f7e8df3f70b3',
'98cffe2e-1d61-454e-9986-e2566e561c8f',
'7d5bad99-8303-427e-8dff-b0de0a7fd459',
],
'comments':'',
'color':'black',
'icon':'General/group',
'tags':[
],
'meta-info':{
'lock':'unlocked',
'validation-state':'ok',
'last-modify-time':{
'posix':1617023570975,
'iso-8601':'2021-03-29T09:12-0400'
},
'last-modifier':'user',
'creation-time':{
'posix':1599654745782,
'iso-8601':'2020-09-09T08:32-0400'
},
'creator':'user'
},
'read-only':False
}

Now, if all objects that could be within a group were objects of the same type, that would be great.  However, since that is not the case, and for example, in a network group, I could have host, network, IP Range or gateway objects, I do not know which one to search for a UID match.  That makes it so I need to go through all object types to find the UID and a matching object name, which is definitely not efficient.

Is there a way to search the entire database by UID in order to get the corresponding object?

 

Thanks in advance for you help!

 

0 Kudos
2 Replies
Scott_NORRIS
Explorer

Looks like I figured it out.  I missed the "show-object" call in the Misc. section of the API's documentation.

Tested it and it works wonderfully!

0 Kudos
Bob_Zimmerman
Authority
Authority

Depends on what you mean by efficient. As you found, 'show object uid <uuid>' is the most efficient from a memory perspective, as you're getting only the exact objects you want.

If you need time-efficiency, it's worth noting API calls all have a communication overhead beyond the time required for the management server to look up and return the result. Running 'show objects limit 500 offset ___' to download all of your objects, then looking things up from that output is likely to be far more time-efficient if you need to look up more than about 50.

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events