Last active
March 6, 2017 11:16
-
-
Save lynnagara/0686b620413997541f32fa02cb8957f7 to your computer and use it in GitHub Desktop.
Get all users from launch darkly
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
#!/usr/bin/python | |
import urllib.request | |
import time | |
import json | |
ACCESS_TOKEN = 'your-access-token' | |
PROJ_KEY = 'default' | |
ENV_KEY = 'production' | |
base_path = 'https://app.launchdarkly.com' | |
path = '/api/v2/users/' + PROJ_KEY + '/' + ENV_KEY + '?limit=50' | |
items = [] | |
while(True): | |
p = base_path + path | |
print('getting', p) | |
request = urllib.request.Request(p, None, {'Authorization': ACCESS_TOKEN}) | |
response = json.loads(urllib.request.urlopen(request).read().decode('utf-8')) | |
items.extend(response['items']) | |
if('next' in response['_links']): | |
path = response['_links']['next']['href'] | |
time.sleep(0.5) | |
else: | |
print('done, exiting') | |
break | |
log = open('output.json', 'w') | |
print(items, file = log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment