What is the best way (with fewest API calls) to get all projects a user is a member of in Horizon project?

Asked by Vahid Hashemian

I have a user id and want to get a list of all projects this user is currently a member of. I can't find a single API call that gives me that. So I was wondering if I'm missing it, and if not, how I can get the list in the most efficient way. Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Dashboard (Horizon) Edit question
Assignee:
Lin Hua Cheng Edit question
Solved by:
Lin Hua Cheng
Solved:
Last query:
Last reply:
Revision history for this message
Vahid Hashemian (vahidhashemian) said :
#1

Forgot to mention I needed this for V2.

Revision history for this message
Best Lin Hua Cheng (lin-hua-cheng) said :
#2

Unfortunately, it cannot be done in a single call.

If you have the user credentials, you can use its token and just make a single call to /tenants. The returns you the list of project associated with the user token.

If you have the admin token, and only have the user_id:
1. Get all the projects: /tenants
2. Iterate through each project and see if the user has any role in it: /tenants/<project_id>/users/<user_id>/roles

Revision history for this message
Vahid Hashemian (vahidhashemian) said :
#3

Thanks Lin Hua Cheng, that solved my question.