Hi,
I'm beginning in Python code with Meraki's API. We are a MSP so we have multiple Organizations.
Made a few codes, but i'm stuck on this one :
Want to list in to a csv file, organizations where a MX under Advanced Security is configured, and have the
IDS mode value.
Code :
import meraki
import os
API = os.environ.get("API_KEY_FF")
dashboard = meraki.DashboardAPI(API, suppress_logging=True)
to_write = ""
organisations = dashboard.organizations.getOrganizations()
for organisation in organisations:
devices = dashboard.organizations.getOrganizationDevices(organisation["id"], total_pages='all')
for device in devices:
if "MX" in device["model"]:
print(organisation["name"] + "," + device["model"])
ASI = dashboard.appliance.getNetworkApplianceSecurityIntrusion(device["networkId"])
for MX in ASI:
to_write = to_write + f'{organisation["name"]},{device["networkId"]},{device["name"]},{ASI["mode"]}\n'
f = open("Get_ASI_MX.csv", "w")
f.write(to_write)
f.close()
Problem : output indicates after a few org scanned : 400 Bad Request, {'errors': ['Intrusion detection is not supported by this network']}
Effectively, organization with MX under Enterprise license doesn't show IDS parameters, so the code is crashing.
Question : How to exclude those organizations or MX Enterprise in my code ?
Many thanks !