29 lines
741 B
Plaintext
29 lines
741 B
Plaintext
|
#!/bin/python3
|
||
|
import sys
|
||
|
import logging
|
||
|
import json
|
||
|
import requests
|
||
|
|
||
|
# Identity attributes
|
||
|
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
||
|
|
||
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||
|
logger = logging.getLogger()
|
||
|
logger.setLevel(logging.INFO)
|
||
|
|
||
|
state = {}
|
||
|
|
||
|
def listOrganizations():
|
||
|
try:
|
||
|
orgs = json.loads(requests.get(f'http://{state['REP_ADDRESS']}/organization/list'))
|
||
|
orgs.raise_for_status()
|
||
|
|
||
|
except requests.exceptions.RequestException as errex:
|
||
|
logger.error("Failed to obtain response from server.")
|
||
|
sys.exit(1)
|
||
|
|
||
|
for org in orgs:
|
||
|
sys.stdout.write(org['id'] + " - " + org['name'])
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
listOrganizations(sys.argv[1:])
|