-
-
Save nmcspadden/fd0f706f0e996a2ca26e07398cb607f0 to your computer and use it in GitHub Desktop.
adobe_tools - Get Product and User lists (internal)
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
def _product_list(config_data, access_token): | |
"""Get the list of product configurations.""" | |
page = 0 | |
result = {} | |
productlist = [] | |
while result.get('lastPage', False) is not True: | |
url = "https://" + config_data['host'] + config_data['endpoint'] + \ | |
"/groups/" + config_data['org_id'] + "/" + str(page) | |
res = requests.get(url, headers=headers(config_data, access_token)) | |
if res.status_code == 200: | |
# print(res.status_code) | |
# print(res.headers) | |
# print(res.text) | |
result = json.loads(res.text) | |
productlist += result.get('groups', []) | |
page += 1 | |
return productlist | |
def _user_list(config_data, access_token): | |
"""Get a list of all users.""" | |
page = 0 | |
result = {} | |
userlist = [] | |
while result.get('lastPage', False) is not True: | |
url = "https://" + config_data['host'] + config_data['endpoint'] + \ | |
"/users/" + config_data['org_id'] + "/" + str(page) | |
res = requests.get(url, headers=headers(config_data, access_token)) | |
if res.status_code == 200: | |
# print(res.status_code) | |
# print(res.headers) | |
# print(res.text) | |
result = json.loads(res.text) | |
userlist += result.get('users', []) | |
page += 1 | |
return userlist | |
def _user_data(config_data, access_token, username): | |
"""Get the data for a given user.""" | |
userlist = _user_list(config_data, access_token) | |
for user in userlist: | |
if user['email'] == username: | |
return user | |
return {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment