Alright, here it is.
A few comments:
- Just update everything that is between <> and the script should run fine
- We only have 3 organizations so I decided to hard code the org name and org ids in the script out of laziness ; now of course you can use an API endpoint to get this information and put it in an array instead of hardcoding it
- The scripts only reports SSID information that I cared about but of course you can update it to collect more/everything
import json
import requests
import sys
import csv
# Define organizations
orgs={'<orgName 1>':'<org Id 1>','<orgName 2>':'<org Id 2>','<orgName 3>':'<org Id 3>'}
org_names=orgs.keys()
# Define API URL and API key
base_url='https://api.meraki.com/api/v0/'
API_KEY = '<ApiKey>'
with open('<filepath>', mode='w',newline='') as report_csv:
report = csv.writer(report_csv, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
report.writerow(['Org name','Network name','SSID name','SSID Authmode','SSID Encryption mode','WPA mode','VLAN','RADIUS servers'])
for org_name in org_names:
#Get list of networks in each organization
print("Cycling through organization " + org_name)
session = requests.session()
headers = {'X-Cisco-Meraki-API-Key': API_KEY, 'Content-Type': 'application/json'}
networks = json.loads(session.get(base_url + 'organizations/' + orgs[org_name] + '/networks', headers=headers).text)
#Get list of SSIDs in each network
for net in networks:
ssids=json.loads(session.get(base_url + 'networks/' + net['id'] + '/ssids', headers=headers).text)
#Write csv file with various information
for ssid in ssids:
if "Unconfigured" in ssid['name']:
break
elif '8021x' in ssid['authMode'] and ssid['useVlanTagging']:
row=[org_name,net['name'],ssid['name'],ssid['authMode'],ssid['encryptionMode'],ssid['wpaEncryptionMode'],ssid['defaultVlanId']]
for index,radius in enumerate(ssid['radiusServers']):
row.insert(7+index,radius['host'])
report.writerow(row)
elif '8021x' in ssid['authMode']:
row=[org_name,net['name'],ssid['name'],ssid['authMode'],ssid['encryptionMode'],ssid['wpaEncryptionMode'],'No tagging']
for index,radius in enumerate(ssid['radiusServers']):
row.insert(7+index,radius['host'])
report.writerow(row)
elif ssid['useVlanTagging']:
report.writerow([org_name,net['name'],ssid['name'],ssid['authMode'],'','',ssid['defaultVlanId']])
else:
report.writerow([org_name,net['name'],ssid['name'],ssid['authMode'],'','','No tagging'])
report_csv.close