Farshan_Ahamed | 2022-11-04 10:19:54 UTC | #1
Hi, I'm trying to retrieve all the users in an Organisation with a specific permission assigned. What would be the optimal way to do this?
I'm one of the developers of a Premium App in AppFoundry and we have a need to get the list of users having our premium app permission. One way we found is to use the users search API (api/v2/users/search) to list all users and then check the ones with permission. The problem with this approach is if there are 1000 users in an org, we'll have to call this API 10 times due to the pagination limit. So, Is there any better way to achieve this?
Thanks in advance.
John_Carnell | 2022-11-04 11:47:10 UTC | #2
Hi Farshan,
You could use the Genesys Cloud CLI and issue a gc users search to get the q64 search criteria and then issue a gc users search list -a. The -a will do auto pagination for you and should return all of the search results as one giant JSON blob.
If you can post your search, I can try to model one out for you.
Thanks, John Carnell
Farshan_Ahamed | 2022-11-04 14:41:31 UTC | #3
Hi, John. I appreciate your quick reply. Since we are trying to retrieve the data from our backend application, we prefer to use an API instead of a CLI. Is there any way to do this using an API?
Also in the Users-Search API (/api/v2/users/search), is there any way to filter the permission inside the permissions object inside the authorization property in the JSON.
If we pass the body of the request something like this.
{
"pageSize": 100,
"pageNumber": 1,
"expand": [
"authorization"
],
"query": [
{
"fields": ["authorization.permissions"],
"type": "CONTAINS",
"value": "##premium app permission##"
}
]
}
John_Carnell | 2022-11-09 13:08:11 UTC | #4
Hi Farshan,
Sorry, it took so long to get back to you. Almost all of our APIs use pagination so there is really no way around not using it. In the CLI we built auto-pagination into it, but the SDKs do not have it in there.
I know this will not help you right now, but I am going to add a not to see if we can add auto-pagination to our SDK as an option. I think that would help greatly simplify our programming model. We are looking at re-imaging our SDKs for next year so this might be an option we can look at.
Thanks, John Carnell Manager, Developer Engagement
Farshan_Ahamed | 2022-11-09 13:29:20 UTC | #5
Hi John, Thank you for the information.
At the moment, if we give "authorization.permissions" as the value of fields inside query object in the request body, it is returning users regardless of the permission. Is there any way to filter the user list having a specific permission?
system | 2022-12-10 13:29:34 UTC | #6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 17065