Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of VMC API Calls
import requests
import os
def login():
key = os.environ['oauthkey']
baseurl = ''
uri = '/am/api/auth/api-tokens/authorize'
headers = {'Content-Type':'application/json'}
payload = {'refresh_token': key}
r ='{baseurl}{uri}', headers = headers, params = payload)
if r.status_code != 200:
print(f'Unsuccessful Login Attmept. Error code {r.status_code}')
print('Login successful. ')
auth_json = r.json()['access_token']
auth_Header = {'Content-Type':'application/json','csp-auth-token':auth_json}
return auth_Header
auth_header = login()
orgList = requests.get('', headers = auth_header)
orgID = orgList.json()[1]['id']
sddcList = requests.get(f'{orgID}/sddcs', headers = auth_header)
if sddcList.status_code != 200:
print('API Error')
for sddc in sddcList.json():
print("SDDC Name: " + sddc['name'])
print("SDDC Create Date: " + sddc['created'])
print("SDDC Provider: " + sddc['provider'])
print("SDDC Region: " + sddc['resource_config']['region'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.