its not pretty. but this is the minimal work to make it run with your current code. What is suggested Eddysanoli is a better approach though. Not tested. Also could be simplified a lot more import meraki, requests, time, apikey, json
def PrintNetworks(Orgid):
url = "https://api.meraki.com/api/v1/organizations/{0}/networks".format(Orgid)
payload={}
headers = {'X-Cisco-Meraki-API-Key': apikey.api_key}
response = requests.request("GET", url, headers=headers, data=payload)
networks = json.loads(response.text)
for Networks in networks:
print("Name: {} \t ID: {}".format(Networks["name"],Networks["id"]))
#Organizations
print('********************************************************************')
print('Listing Organizations xxxx')
print('********************************************************************')
url = "https://api.meraki.com/api/v1/organizations"
payload={}
headers = { 'X-Cisco-Meraki-API-Key': apikey.api_key}
response = requests.request("GET", url, headers=headers, data=payload)
allOrg = json.loads(response.text)
for Organization in allOrg:
print("Name: {} \t ID: {}".format(Organization["name"],Organization["id"]))
if Organization["id"] == "535660":
print('EU Networks')
PrintNetworks(Organization["id"])
elif Organization["id"] == "419633":
print('US Networks')
PrintNetworks(Organization["id"])
elif Organization["id"] == "671036344478206491":
print('APAC Networks')
PrintNetworks(Organization["id"])
print('********************************************************************')
... View more