feat: add GET /api/0/hosts/{hostname}/info endpoint
This commit is contained in:
@@ -868,6 +868,23 @@ async def start(
|
|||||||
|
|
||||||
return web.json_response(host.access_dict())
|
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
|
# 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}/alerts", api_host_alerts),
|
||||||
web.get("/api/0/hosts/{hostname}/access", api_host_access_get),
|
web.get("/api/0/hosts/{hostname}/access", api_host_access_get),
|
||||||
web.put("/api/0/hosts/{hostname}/access", api_host_access_put),
|
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.get("/api/0/alerts", api_all_alerts),
|
||||||
web.post("/api/0/alerts/acknowledge", api_acknowledge_alert),
|
web.post("/api/0/alerts/acknowledge", api_acknowledge_alert),
|
||||||
web.get("/c", cmd),
|
web.get("/c", cmd),
|
||||||
|
|||||||
Reference in New Issue
Block a user