feat(api): роутеры API v1 и WebSocket-поток метрик (Refs #19)
- ops: health/ready/metrics без аутентификации (503 = схема Error). - auth: login/logout/session, cookie-сессия + CSRF-токен. - status/config/routing/devices+logs: все эндпоинты контракта. - ws/metrics: /api/v1/metrics/stream, токен в заголовке или query.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Конфигурация AmneziaWG: чтение, атомарное применение, сухая валидация."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from awg_api.deps import StateDep, require_token
|
||||
from awg_api.schemas import ConfigUpdateRequest
|
||||
|
||||
router = APIRouter(prefix="/api/v1/config", tags=["config"], dependencies=[Depends(require_token)])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def get_config(state: StateDep) -> dict[str, Any]:
|
||||
return state.get_config()
|
||||
|
||||
|
||||
@router.put("")
|
||||
async def put_config(payload: ConfigUpdateRequest, state: StateDep) -> dict[str, Any]:
|
||||
return state.apply_config(payload)
|
||||
|
||||
|
||||
@router.post("/validate")
|
||||
async def validate_config(payload: ConfigUpdateRequest, state: StateDep) -> dict[str, Any]:
|
||||
return state.validate_config(payload)
|
||||
Reference in New Issue
Block a user