Skip to content

Instantly share code, notes, and snippets.

@lynnagara
Last active March 6, 2017 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynnagara/0686b620413997541f32fa02cb8957f7 to your computer and use it in GitHub Desktop.
Save lynnagara/0686b620413997541f32fa02cb8957f7 to your computer and use it in GitHub Desktop.
Get all users from launch darkly
#!/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