Workspace administrators have full privileges to manage a workspace. This includes adding and removing users, as well as managing all of the data resources (jobs, libraries, notebooks, repos, etc.) in the workspace.
If you are a workspace admin, you can view other workspace admins in the workspace UI by using Admin Settings.
- Click your username in the top bar of the workspace.
- Click Admin Settings.
- Click Groups.
- Click the admins group.
- Review the list of workspace admins.
While the UI method works for most situations, in certain use cases you may need to get a list of workspace admins from within a notebook.
This article provides a sample code that you can use to list all of the workspace admins in the current workspace.
Instructions
We can use the following code to fetch the workspace admin users.
- Copy and paste the sample code into a notebook cell.
- Replace the <workspace-domain-name> and <personal-access-token> values with ones specific to your workspace.
- Run the cell to generate a list of all the admin users in your workspace.
%python import requests access_token= "<personal-access-token>" headers={ 'Authorization': 'Bearer ' + access_token } response = requests.get(f"https://<workspace-domain-name>/api/2.0/preview/scim/v2/Groups", headers=headers) groups = response.json() for admin in groups['Resources']: if admin.get('displayName')== 'admins': admin_group_id=admin.get('id') print(admin_group_id) response = requests.get(f"https://<workspace-domain-name>/api/2.0/preview/scim/v2/Groups/{admin_group_id}", headers=headers) admin_group = response.json() members = admin_group.get('members', []) admin_users = [] for member in members: admin_users.append(member.get('display')) admin_users.sort() print(admin_users)