36 lines
1.0 KiB
Bash
36 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
BASE_URL="${1:-http://127.0.0.1:8100}"
|
|
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
|
|
|
echo "[1/2] ops link snapshot"
|
|
SNAPSHOT_JSON="$(curl -fsS "${BASE_URL}/api/v1/ops/link-snapshot")"
|
|
echo "${SNAPSHOT_JSON}"
|
|
echo
|
|
echo
|
|
|
|
echo "[2/2] condensed summary"
|
|
"${PYTHON_BIN}" - <<'PY' "$SNAPSHOT_JSON"
|
|
import json
|
|
import sys
|
|
|
|
payload = json.loads(sys.argv[1]).get("data", {})
|
|
print(f"status: {payload.get('status', '-')}")
|
|
print(f"headline: {payload.get('headline', '-')}")
|
|
print()
|
|
print("summary:")
|
|
for line in payload.get("summary_lines", []) or []:
|
|
print(f"- {line}")
|
|
|
|
actions = payload.get("next_actions", []) or []
|
|
if actions:
|
|
print()
|
|
print("next_actions:")
|
|
for item in actions:
|
|
label = str(item.get("label", "") or "").strip() or "-"
|
|
action_code = str(item.get("action_code", "") or "").strip() or "-"
|
|
node_codes = "、".join(str(x).strip() for x in (item.get("node_codes", []) or []) if str(x).strip()) or "-"
|
|
print(f"- {label} / {action_code} / nodes: {node_codes}")
|
|
PY
|