#!/usr/bin/env python3 import requests import json import urllib3 import sys # SUPPRESS WARNINGS ############################################################ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # ADD USER ##################################################################### def check_users(details): global users if 'createdBy' not in details: return if details['createdBy'] not in users: print('Found user {}'.format(details['createdBy'])) users.append(details['createdBy']) if details['modifiedBy'] not in users: print('Found user {}'.format(details['modifiedBy'])) users.append(details['modifiedBy']) # MAIN ######################################################################### url = sys.argv[1].rstrip('/') session = requests.Session() response = session.get(url + '/api/repositories', verify=False) repositories = json.loads(response.text) users = [] print('There are {} repositories to process'.format(len(repositories))) for repository in repositories: try: response = session.get(url + '/api/storage/' + repository['key'], verify=False) if 'json' not in response.headers['Content-Type']: continue rep = json.loads(response.text) for child in rep['children']: uri = child['uri'] response = session.get(url + '/api/storage/' + repository['key'] + uri, verify=False) if 'json' not in response.headers['Content-Type']: continue details = json.loads(response.text) check_users(details) except Exception as e: pass