Created
July 8, 2020 10:42
-
-
Save danlester/a5287ae6bad0c44bdbd96227cec365e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
api_url = 'https://myjupyterhub.net/hub/api' | |
token = '<token from token menu of an admin user>' | |
# List all groups | |
r = requests.get(api_url + '/groups', | |
headers={ | |
'Authorization': 'token %s' % token, | |
} | |
) | |
r.raise_for_status() | |
r.json() | |
# List group info for the dash-r-shiny group | |
r = requests.get(api_url + '/groups/dash-r-shiny', | |
headers={ | |
'Authorization': 'token %s' % token, | |
} | |
) | |
r.raise_for_status() | |
r.json() | |
# Add bob to the list of users in the dash-r-shiny group | |
r = requests.post(api_url + '/groups/dash-r-shiny/users', | |
headers={ | |
'Authorization': 'token %s' % token, | |
}, | |
json={'users':['bob']} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment