feat: opt-in /api/containers listing running Docker containers and their uptime
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c9dd7c9b3
commit
10aaa13aeb
3 files changed
+148
-2
No files matched your search
+11
-2
@@ -1,8 +1,8 @@
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
|
||||
from . import stats
|
||||
from . import containers, stats
|
||||
from .security import require_api_key
|
||||
|
||||
|
||||
@@ -25,3 +25,12 @@ def health():
|
||||
@app.get("/api/stats", dependencies=[Depends(require_api_key)])
|
||||
def get_stats():
|
||||
return stats.collect()
|
||||
|
||||
|
||||
@app.get("/api/containers", dependencies=[Depends(require_api_key)])
|
||||
def get_containers():
|
||||
# Opt-in: only works when the agent can reach the Docker API (see README.md).
|
||||
try:
|
||||
return {"containers": containers.collect()}
|
||||
except containers.DockerUnavailable as exc:
|
||||
raise HTTPException(status_code=503, detail=str(exc))
|
||||
Reference in new issue
Block a user