05-08-2019 08:55 PM
A similar alternative to the above:
import requests import json def login() header = {'Content-Type':'application/json'} payload = {'username':'redlock_user','password':'redlock_pw','customerName':'customer_name'} API = 'https://api.redlock.io' response = requests.request('POST', '{}/login'.format(API), json=payload, headers=header) json_response = response.json() return json_response['token'] JWT_TOKEN = login() REQ_HEADER = {'Content-Type':'application/json','x-redlock-auth':JWT_TOKEN} # Example data pull response = requests.request('GET', '{}/cloud'.format(API), headers=REQ_HEADER) cloud_accounts = json.loads(response.text)
That small code snippet should load all cloud account instances in RedLock and save them to an array cloud_accounts.
Hope this helps.