feat: add remote API help listing
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-22 20:25:27 -06:00
parent c25a8a84e0
commit 05245a8bba
1 changed files with 24 additions and 0 deletions

View File

@ -2,6 +2,30 @@
set -euo pipefail
REMOTE_URL="${JEANNIE_REMOTE_URL:-http://127.0.0.1:8787}"
REMOTE_TOKEN="${JEANNIE_REMOTE_TOKEN:-${JEANNIE_SERVER_TOKEN:-}}"
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
export JEANNIE_REMOTE_URL="${REMOTE_URL}" REMOTE_TOKEN
python3 - <<'PY'
import json, os, sys, urllib.error, urllib.request
url = os.environ["JEANNIE_REMOTE_URL"].rstrip("/")
headers = {}
if os.environ.get("REMOTE_TOKEN"):
headers["Authorization"] = "Bearer " + os.environ["REMOTE_TOKEN"]
request = urllib.request.Request(url + "/v1/commands", headers=headers, method="GET")
try:
with urllib.request.build_opener(urllib.request.ProxyHandler({})).open(request, timeout=15) as response:
payload = json.loads(response.read())
except urllib.error.HTTPError as exc:
print(exc.read().decode(errors="replace"), file=sys.stderr)
raise SystemExit(1)
except urllib.error.URLError as exc:
print(f"jeannie remote: cannot reach {url}: {exc.reason}", file=sys.stderr)
raise SystemExit(1)
print(f"Jeannie remote API commands ({url}):")
for command in payload.get("commands", []):
print(f" {command}")
PY
exit 0
fi
if [[ $# -lt 1 ]]; then
echo "Usage: ./jeannie remote <jeannie-command> [args...]" >&2
exit 2