QuestionQ33

Controller-Based Network Automation

Drag the code snippets from the bottom onto the boxes in the code to configure the set_alerts function to send an email to all admins if a setting is modified by using the Cisco Meraki API. Not all options are used.

Drag & Drop
def set_alerts(network_id, default_emails, alert_emails, meraki_url, meraki_apiKey):
    url = meraki_url + "/networks/"+network_id+
    headers = {
        "X-Cisco-Meraki-API-Key": meraki_apiKey,
        "Content-Type": "application/json"
    }
    payload = {
        "defaultDestinations": {
            "emails": default_emails,
            "snmp": False,
            "allAdmins": False
        },
        "alerts": [
            {
                "type": ,
                "enabled": True,
                "alertDestinations": {
                    "emails": alert_emails,
                    "snmp": False,
                    "allAdmins": 
                },
                "filters": {}
            }
        ]
    }
    response = requests.request(, url, headers = headers,
    data = json.dumps(payload)).text
    return response
Explanation

Meraki network alert settings are updated with a PUT request to the network alerts-settings resource. The settingsChanged alert type represents configuration changes, and setting its alert destination's allAdmins property to True sends the notification to all administrators.

Community Discussion

No comments yet. Be the first to start the discussion!