Networks and Images are now per-host, rendered as a section for the local host
plus one per registered agent (like the Stacks page).
- agent_app.py: new /agent/networks (list/inspect/containers/connect/disconnect/
create/delete/prune) and /agent/images (list/updates/check), reusing
network_service and a new image_service; DockerError mapped to HTTP status
(forbidden -> 400 so the proxy doesn't treat it as a token failure).
- routers/agents.py: proxy routes at /api/agents/{id}/networks/* and
/api/agents/{id}/images/*, audit-logging mutations.
- services/image_service.py: extracted the image-listing logic so the central
router and the agent share it.
- Frontend: networksApi/imagesApi take an optional agentId; Networks/Images
pages render NetworksSection/ImagesSection per host with a shared HostHeader.
Remote "Prune unused" networks resolves the address-pool-exhaustion deploy
error from the UI.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
697 B
Python
26 lines
697 B
Python
"""Image listing + update-check endpoints."""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from auth import get_current_user, require_admin
|
|
from models.user import User
|
|
from services import image_service, update_service
|
|
|
|
router = APIRouter(prefix="/api/images", tags=["images"])
|
|
|
|
|
|
@router.get("")
|
|
def list_images(_user: User = Depends(get_current_user)) -> list[dict]:
|
|
return image_service.list_images()
|
|
|
|
|
|
@router.get("/updates")
|
|
def updates(_user: User = Depends(get_current_user)) -> dict:
|
|
return update_service.get_cache()
|
|
|
|
|
|
@router.post("/check")
|
|
async def check(_user: User = Depends(require_admin)) -> dict:
|
|
return await update_service.check_all()
|