From 374e4184ffaacc1ec805df877ae746a2a637b9bc Mon Sep 17 00:00:00 2001 From: Guillaume BOURGEOIS Date: Sun, 12 Jul 2026 21:53:58 +0200 Subject: [PATCH] feat(meraki): new Cisco Meraki network integration Meraki Dashboard API v1, 5 commands: list organizations/networks/devices, list network clients. API-key auth, stdlib-only. py_compile clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- integrations/meraki/manifest.yaml | 63 +++++++++++++++++++ integrations/meraki/scripts/list_clients.py | 56 +++++++++++++++++ integrations/meraki/scripts/list_devices.py | 50 +++++++++++++++ integrations/meraki/scripts/list_networks.py | 50 +++++++++++++++ .../meraki/scripts/list_organizations.py | 43 +++++++++++++ .../meraki/scripts/test_connection.py | 43 +++++++++++++ 6 files changed, 305 insertions(+) create mode 100644 integrations/meraki/manifest.yaml create mode 100644 integrations/meraki/scripts/list_clients.py create mode 100644 integrations/meraki/scripts/list_devices.py create mode 100644 integrations/meraki/scripts/list_networks.py create mode 100644 integrations/meraki/scripts/list_organizations.py create mode 100644 integrations/meraki/scripts/test_connection.py diff --git a/integrations/meraki/manifest.yaml b/integrations/meraki/manifest.yaml new file mode 100644 index 0000000..e824be7 --- /dev/null +++ b/integrations/meraki/manifest.yaml @@ -0,0 +1,63 @@ +id: meraki +name: Cisco Meraki +version: 1.0.0 +description: "Cisco Meraki (Dashboard API v1) — network visibility: list organizations, networks and devices, and list clients on a network. API-key authentication; stdlib-only, no extra Python dependencies." +changelog: "1.0.0 — Initial release: list organizations/networks/devices, list network clients." +category: network + +# Per-instance configuration. Auth header 'X-Cisco-Meraki-API-Key: '. +config_schema: + properties: + api_key: + type: string + description: "Meraki Dashboard API key" + x-soar-sensitive: true + required: + - api_key + +commands: + - id: list_organizations + name: meraki-list-organizations + description: "List organizations the API key can access." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } + - id: list_networks + name: meraki-list-networks + description: "List networks in an organization." + risk: read + inputs_schema: + properties: + organization_id: { type: string, description: "Organization ID" } + required: [organization_id] + outputs_schema: { properties: {} } + - id: list_devices + name: meraki-list-devices + description: "List devices in an organization." + risk: read + inputs_schema: + properties: + organization_id: { type: string, description: "Organization ID" } + required: [organization_id] + outputs_schema: { properties: {} } + - id: list_clients + name: meraki-list-clients + description: "List clients seen on a network." + risk: read + inputs_schema: + properties: + network_id: { type: string, description: "Network ID" } + timespan: { type: number, description: "Look-back window in seconds (default 86400)" } + required: [network_id] + outputs_schema: { properties: {} } + + - id: test_connection + name: meraki-test-connection + description: "Verify the API key (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/meraki/scripts/list_clients.py b/integrations/meraki/scripts/list_clients.py new file mode 100644 index 0000000..960a32c --- /dev/null +++ b/integrations/meraki/scripts/list_clients.py @@ -0,0 +1,56 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +BASE = "https://api.meraki.com/api/v1" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def request(method, path, cfg, params=None): + url = BASE + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, inputs): + network_id = inputs.get("network_id") + if not network_id: + raise Exception("network_id is required") + timespan = inputs.get("timespan") + + response = request( + "GET", + "/networks/" + q(network_id) + "/clients", + cfg, + params={"timespan": int(timespan or 86400)}, + ) + return response + + +_run(main) diff --git a/integrations/meraki/scripts/list_devices.py b/integrations/meraki/scripts/list_devices.py new file mode 100644 index 0000000..49ec8aa --- /dev/null +++ b/integrations/meraki/scripts/list_devices.py @@ -0,0 +1,50 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +BASE = "https://api.meraki.com/api/v1" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def request(method, path, cfg, params=None): + url = BASE + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, inputs): + organization_id = inputs.get("organization_id") + if not organization_id: + raise Exception("organization_id is required") + + response = request("GET", "/organizations/" + q(organization_id) + "/devices", cfg) + return response + + +_run(main) diff --git a/integrations/meraki/scripts/list_networks.py b/integrations/meraki/scripts/list_networks.py new file mode 100644 index 0000000..6a3def5 --- /dev/null +++ b/integrations/meraki/scripts/list_networks.py @@ -0,0 +1,50 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +BASE = "https://api.meraki.com/api/v1" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def request(method, path, cfg, params=None): + url = BASE + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, inputs): + organization_id = inputs.get("organization_id") + if not organization_id: + raise Exception("organization_id is required") + + response = request("GET", "/organizations/" + q(organization_id) + "/networks", cfg) + return response + + +_run(main) diff --git a/integrations/meraki/scripts/list_organizations.py b/integrations/meraki/scripts/list_organizations.py new file mode 100644 index 0000000..d120a03 --- /dev/null +++ b/integrations/meraki/scripts/list_organizations.py @@ -0,0 +1,43 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +BASE = "https://api.meraki.com/api/v1" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def request(method, path, cfg, params=None): + url = BASE + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + response = request("GET", "/organizations", cfg) + return response + + +_run(main) diff --git a/integrations/meraki/scripts/test_connection.py b/integrations/meraki/scripts/test_connection.py new file mode 100644 index 0000000..831e028 --- /dev/null +++ b/integrations/meraki/scripts/test_connection.py @@ -0,0 +1,43 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +BASE = "https://api.meraki.com/api/v1" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def request(method, path, cfg, params=None): + url = BASE + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + request("GET", "/organizations", cfg) + return {"ok": True} + + +_run(main)