32 lines
914 B
Python
32 lines
914 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from fastapi import APIRouter, HTTPException
|
||
|
|
|
||
|
|
from app.connectors.proxmox import get_status_summary, get_topology, poll_and_snapshot
|
||
|
|
|
||
|
|
router = APIRouter(prefix="/ops", tags=["ops"])
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/status")
|
||
|
|
def ops_status() -> dict:
|
||
|
|
try:
|
||
|
|
return get_status_summary()
|
||
|
|
except Exception as exc: # noqa: BLE001
|
||
|
|
raise HTTPException(status_code=500, detail=f"ops status failed: {exc}") from exc
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/topology")
|
||
|
|
def ops_topology() -> dict:
|
||
|
|
try:
|
||
|
|
return get_topology()
|
||
|
|
except Exception as exc: # noqa: BLE001
|
||
|
|
raise HTTPException(status_code=500, detail=f"ops topology failed: {exc}") from exc
|
||
|
|
|
||
|
|
|
||
|
|
@router.post("/refresh")
|
||
|
|
def ops_refresh() -> dict:
|
||
|
|
try:
|
||
|
|
return poll_and_snapshot()
|
||
|
|
except Exception as exc: # noqa: BLE001
|
||
|
|
raise HTTPException(status_code=500, detail=f"ops refresh failed: {exc}") from exc
|