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.
28 lines
838 B
Python
28 lines
838 B
Python
"""Конфигурация 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)
|