init
This commit is contained in:
41
app/api/routes_config.py
Normal file
41
app/api/routes_config.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
app/api/routes_config.py
|
||||
HTTP endpoints for reading and updating runtime configuration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.models import ConfigResponse, UpdateConfigRequest
|
||||
from app.services import config_service, event_service
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api/config", tags=["config"])
|
||||
|
||||
|
||||
@router.get("", response_model=ConfigResponse)
|
||||
def get_config():
|
||||
return config_service.get_config()
|
||||
|
||||
|
||||
@router.patch("", response_model=ConfigResponse)
|
||||
def update_config(body: UpdateConfigRequest):
|
||||
cfg = config_service.update_config(
|
||||
default_wait_seconds=body.default_wait_seconds,
|
||||
default_empty_response=body.default_empty_response,
|
||||
agent_stale_after_seconds=body.agent_stale_after_seconds,
|
||||
)
|
||||
event_service.broadcast(
|
||||
"config.updated",
|
||||
{
|
||||
"default_wait_seconds": cfg.default_wait_seconds,
|
||||
"default_empty_response": cfg.default_empty_response,
|
||||
"agent_stale_after_seconds": cfg.agent_stale_after_seconds,
|
||||
},
|
||||
)
|
||||
return cfg
|
||||
|
||||
Reference in New Issue
Block a user