23 lines
714 B
Python
23 lines
714 B
Python
#!/usr/bin/env python3
|
|
"""Smoke agent: only Tool Gateway, no direct production URLs."""
|
|
import json
|
|
import urllib.request
|
|
|
|
BASE = "http://127.0.0.1:9137"
|
|
|
|
|
|
def call(tool, method="GET", body=None, approval=None):
|
|
req = urllib.request.Request(BASE + "/v1/call?tool=" + tool, method=method)
|
|
if body is not None:
|
|
req.data = json.dumps(body).encode()
|
|
req.add_header("Content-Type", "application/json")
|
|
if approval:
|
|
req.add_header("X-Approval", approval)
|
|
with urllib.request.urlopen(req, timeout=10) as r:
|
|
return json.loads(r.read().decode())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
d = call("catalog.read")
|
|
print("gateway_agent_ok", d.get("tool"), len(d.get("body") or ""))
|