Refactor response handling and health check endpoints
- Enhance response model with additional fields and validation - Update health and server router implementations - Improve frontend type definitions and API integration - Clean up documentation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ from fastapi import APIRouter, Request, status
|
||||
|
||||
from app.dependencies import AuthDep, Fail2BanSocketDep
|
||||
from app.mappers import server_mappers
|
||||
from app.models.response import FlushLogsResponse
|
||||
from app.models.server import ServerSettingsResponse, ServerSettingsUpdate
|
||||
from app.services import server_service
|
||||
|
||||
@@ -86,12 +87,13 @@ async def update_server_settings(
|
||||
"/flush-logs",
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary="Flush and re-open fail2ban log files",
|
||||
response_model=FlushLogsResponse,
|
||||
)
|
||||
async def flush_logs(
|
||||
request: Request,
|
||||
_auth: AuthDep,
|
||||
socket_path: Fail2BanSocketDep,
|
||||
) -> dict[str, str]:
|
||||
) -> FlushLogsResponse:
|
||||
"""Flush and re-open fail2ban log files.
|
||||
|
||||
Useful after log rotation so the daemon writes to the newly created
|
||||
@@ -102,11 +104,11 @@ async def flush_logs(
|
||||
_auth: Validated session.
|
||||
|
||||
Returns:
|
||||
``{"message": "<response from fail2ban>"}``
|
||||
:class:`~app.models.response.FlushLogsResponse` with the result from fail2ban.
|
||||
|
||||
Raises:
|
||||
HTTPException: 400 when the command is rejected.
|
||||
HTTPException: 502 when fail2ban is unreachable.
|
||||
"""
|
||||
result = await server_service.flush_logs(socket_path)
|
||||
return {"message": result}
|
||||
return FlushLogsResponse(message=result)
|
||||
|
||||
Reference in New Issue
Block a user