You need to use the API for it to be org wide. Main: configure-meraki-custom-templates.py #Import modules
import requests
import json
import os
import config
#API documentation for calls used in this script.
#!! This API Call is in early access. Make sure to enable EA API access under organization -> Early Access.
#https://developer.cisco.com/meraki/api-latest/create-organization-webhooks-payload-template/
#set global vars
organizationId = config.orgid
apikey = os.environ.get("MERAKI_DASHBOARD_API_KEY")
headers = {
"X-Cisco-Meraki-API-Key": apikey,
"Content-Type":"application/json",
"Accept":"application/json"
}
#open webhook template settings file and convert it to a python dictionary
with open ("templatesettings.json") as f:
jsonfile = json.load(f)
#serialize python dict to json string for use in POST request
payload = json.dumps(jsonfile)
#generate post request to payloadTemplate URI and formats string with organizationId in configuration file.
try:
url = "https://api.meraki.com/api/v1/organizations/{}/webhooks/payloadTemplates".format(organizationId)
response = requests.request('POST', url , headers = headers, data = payload)
print(response.status_code)
print(response.text)
except requests.exceptions.HTTPError as err:
raise SystemExit(err) config file: config.py orgid = "<<insert org id>>"
#example orgid = "123456789" Settings: templatesettings.json {
"name": "ServiceNow",
"headers": [{
"name": "Authorization",
"template": "Basic {{ sharedSecret | base64_encode }}"
},
{
"name": "Content-Type",
"template": "application/json"
},
{
"name": "Accept",
"template": "*/*"
},
{
"name": "Accept-Encoding",
"template": "gzip, compress, br"
}
],
"body": "{\r\n\"version\": \"0.1\",\r\n\"sharedSecret\": \"{{sharedSecret}}\",\r\n\"sentAt\": \"{{sentAt}}\",\r\n\"organizationId\": \"{{organizationId}}\",\r\n\"organizationName\": \"{{organizationName}}\",\r\n\"organizationUrl\": \"{{organizationUrl}}\",\r\n\"networkId\": \"{{networkId}}\",\r\n\"networkName\": \"{{networkName}}\",\r\n\"networkUrl\": \"{{networkUrl}}\",\r\n\"networkTags\": {{ networkTags | jsonify }},\r\n\"deviceSerial\": \"{{deviceSerial}}\",\r\n\"deviceMac\": \"{{deviceMac}}\",\r\n\"deviceName\": \"{{deviceName}}\",\r\n\"deviceUrl\": \"{{deviceUrl}}\",\r\n\"deviceTags\": {{ deviceTags | jsonify }},\r\n\"deviceModel\": \"{{deviceModel}}\",\r\n\"alertId\": \"{{alertId}}\",\r\n\"alertType\": \"{{alertType}}\",\r\n\"alertTypeId\": \"{{alertTypeId}}\",\r\n\"alertLevel\": \"{{alertLevel}}\",\r\n\"occurredAt\": \"{{occurredAt}}\",\r\n\"alertData\": {{ alertData | jsonify }}\r\n}\r\n",
"sharing": {
"byNetwork": {
"adminsCanModify": true,
"ids": [
null
],
"withAll": true
}
}
} Take a note of this part in the templatesettings.json part. No idea why its not in the GUI yet, but set this to true and you can use it org wide. "sharing": { "byNetwork": { "adminsCanModify": true, "ids": [ null ], "withAll": true <--- read me: # cisco-meraki
Automation scripts for Cisco Meraki cloud networking
Go to https://developer.cisco.com/meraki/api-latest/overview/ for API documentation
API calls used to find values and attributes needed in the different config files can be found there as well.
Custom Cisco Meraki scripts
All scripts are self contained and can be executed on their own as long as all requirements are installed.
Setup
Enable API access in your Meraki dashboard organization and obtain an API key (instructions).
Keep your API key safe and secure, as it is similar to a password for your dashboard. If publishing your Python code to a wider audience, please research secure handling of API keys.
Install the latest version of Python 3.
Install the requests module. pip3 install requests.
Usage
Export your API key as an environment variable, for example: export MERAKI_DASHBOARD_API_KEY=123456789asdfghjklasdasd
Alternatively, define your API key as a variable in your source code; this method is not recommended due to its inherent insecurity.
Update the config.py file with the organization ID and other settings you wish to include/add in the scripts And please forgive the bad code... its just something i cobbeld together. Also, this is for a service now integration. you might need to adjust some of the header settings in the templatesettings.json file. To run this scrappy code you must get a bit familiar with python. But you should just be able to follow the readme and pile all the files somewhere in the same folder and run it.
... View more