import json, os, sys, urllib.request, urllib.error def run(): s = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) base = str(s.get("base_url") or "").strip().rstrip("/") if not base.startswith("https://"): raise ValueError("base_url must be the relay's https:// address") req = urllib.request.Request(base + "/relay/v1/status", method="GET", headers={ "Authorization": "Bearer " + str(s.get("read_token") or "").strip(), "Accept": "application/json"}) with urllib.request.urlopen(req, timeout=30) as r: print(r.read().decode("utf-8")) try: run() 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)