From 653e018e4f7f87cdd9d8fa96821b3a0b739b1915 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Sun, 10 May 2026 08:18:49 -0400 Subject: [PATCH] feat: add GET /api/0/hosts/{hostname}/info endpoint --- hbd/server/http.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hbd/server/http.py b/hbd/server/http.py index 762381d..5b720ac 100644 --- a/hbd/server/http.py +++ b/hbd/server/http.py @@ -868,6 +868,23 @@ async def start( return web.json_response(host.access_dict()) + # ------------------------------------------------------------------------- + # Host info endpoint + # ------------------------------------------------------------------------- + + async def api_host_info(request): + """GET /api/0/hosts/{hostname}/info""" + user, err = _require_auth(request) + if err: + return err + hostname = request.match_info.get("hostname") + if hostname not in hbdclass.Host.hosts: + return web.json_response({"error": f"Host '{hostname}' not found"}, status=404) + host = hbdclass.Host.hosts[hostname] + if not _can_view_host(user, host): + return web.json_response({"error": "Forbidden"}, status=403) + return web.json_response(_build_host_info(host, threshold_checker=threshold_checker)) + # ------------------------------------------------------------------------- # User profile page # ------------------------------------------------------------------------- @@ -1309,6 +1326,7 @@ async def start( web.get("/api/0/hosts/{hostname}/alerts", api_host_alerts), web.get("/api/0/hosts/{hostname}/access", api_host_access_get), web.put("/api/0/hosts/{hostname}/access", api_host_access_put), + web.get("/api/0/hosts/{hostname}/info", api_host_info), web.get("/api/0/alerts", api_all_alerts), web.post("/api/0/alerts/acknowledge", api_acknowledge_alert), web.get("/c", cmd),