cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Which rest API to use in order to list the groups that belong to a specific user

Mohit_m
Valued Contributor II

Which rest API to use in order to list the groups that belong to a specific user

5 REPLIES 5

Prabakar
Esteemed Contributor III
Esteemed Contributor III

api/2.0/groups/list-parents

--data '{ "user_name": "someone@example.com" }'

Mohit_m
Valued Contributor II

Please check the below curl command example which invokes list-parents endpoint from the Groups API. It can be extended/modified based on the requirements.

It retrieves all groups in which a given user or group is a member. 

This method is non-recursive; it returns all groups in which the given user or group is a member but not the groups in which those groups are members. 

Example:

curl --netrc -X GET \

https://xxxxx.cloud.databricks.com/api/2.0/groups/list-parents \

--data '{ "user_name": "someone@example.com" }' \

| jq .

Reference documentation from more details:

https://docs.databricks.com/dev-tools/api/latest/groups.html#list-parents

Hubert-Dudek
Esteemed Contributor III

Hi there is groups API.

https://docs.databricks.com/dev-tools/api/latest/groups.html

There is example API call to list members of the group:

curl --netrc -X GET \
https://dbc-a1b2345c-d6e7.cloud.databricks.com/api/2.0/groups/list-members \
--data '{ "group_name": "reporting-department" }' \
| jq .

Prabakar
Esteemed Contributor III
Esteemed Contributor III

Hi @Hubert Dudek​ the API list-members will list all the members of the group, but here the question is to list all the groups of a user. So list-parents is the API to be used. This will give all groups in which a given user or group is a member.

https://docs.databricks.com/dev-tools/api/latest/groups.html#list-parents

jose_gonzalez
Moderator
Moderator

@Mohit Miglani​ ,

Make sure to select the best option so the post will be moved to the top and will help in case more users have this question in the future.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.