39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""
|
|
API router for configuration management
|
|
"""
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
|
from app.core.dependencies import get_config_manager
|
|
from app.schemas.config import ConfigResponse, ConfigUpdateRequest, ConfigTestRequest, ConfigTestResponse
|
|
from app.services.config_manager import ConfigManager
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/", response_model=ConfigResponse)
|
|
async def get_config(config_manager: ConfigManager = Depends(get_config_manager)):
|
|
"""Retrieve the current system configuration."""
|
|
return await config_manager.get_config()
|
|
|
|
@router.put("/", response_model=ConfigResponse)
|
|
async def update_config(
|
|
config_update: ConfigUpdateRequest,
|
|
config_manager: ConfigManager = Depends(get_config_manager)
|
|
):
|
|
"""Update system configuration."""
|
|
return await config_manager.update_config(config_update)
|
|
|
|
@router.post("/test", response_model=ConfigTestResponse)
|
|
async def test_config(
|
|
test_request: ConfigTestRequest,
|
|
config_manager: ConfigManager = Depends(get_config_manager)
|
|
):
|
|
"""Test a specific configuration (e.g., database connection)."""
|
|
# The test logic will be implemented in a subsequent step inside the ConfigManager
|
|
# For now, we return a placeholder response.
|
|
# test_result = await config_manager.test_config(
|
|
# test_request.config_type,
|
|
# test_request.config_data
|
|
# )
|
|
# return test_result
|
|
raise HTTPException(status_code=501, detail="Not Implemented")
|