7d9cf8ca5e
- ops: health/ready/metrics без аутентификации (503 = схема Error). - auth: login/logout/session, cookie-сессия + CSRF-токен. - status/config/routing/devices+logs: все эндпоинты контракта. - ws/metrics: /api/v1/metrics/stream, токен в заголовке или query.
30 lines
759 B
Python
30 lines
759 B
Python
"""Устройства и журнал: /api/v1/devices, /api/v1/logs."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from awg_api.deps import StateDep, require_token
|
|
|
|
router = APIRouter(
|
|
prefix="/api/v1", tags=["devices", "logs"], dependencies=[Depends(require_token)]
|
|
)
|
|
|
|
|
|
@router.get("/devices")
|
|
async def list_devices(state: StateDep) -> dict[str, Any]:
|
|
return state.list_devices()
|
|
|
|
|
|
@router.get("/logs")
|
|
async def list_logs(
|
|
state: StateDep,
|
|
limit: int = Query(default=100, ge=1, le=500),
|
|
cursor: str | None = None,
|
|
level: str | None = None,
|
|
q: str | None = None,
|
|
) -> dict[str, Any]:
|
|
return state.list_logs(limit=limit, cursor=cursor, level=level, query=q)
|