No canonical snake_case/camelCase serialization policy
This commit is contained in:
@@ -4,18 +4,18 @@ Covers jail config files (``jail.d/``), filter definitions (``filter.d/``),
|
||||
and action definitions (``action.d/``).
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import Field
|
||||
|
||||
from app.models.response import BanGuiBaseModel
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Jail config file models (Task 4a)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class JailConfigFile(BaseModel):
|
||||
class JailConfigFile(BanGuiBaseModel):
|
||||
"""Metadata for a single jail configuration file in ``jail.d/``."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
name: str = Field(..., description="Jail name (file stem, e.g. ``sshd``).")
|
||||
filename: str = Field(..., description="Actual filename (e.g. ``sshd.conf``).")
|
||||
enabled: bool = Field(
|
||||
@@ -26,81 +26,56 @@ class JailConfigFile(BaseModel):
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class JailConfigFilesResponse(BaseModel):
|
||||
class JailConfigFilesResponse(BanGuiBaseModel):
|
||||
"""Response for ``GET /api/config/jail-files``."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
files: list[JailConfigFile] = Field(default_factory=list)
|
||||
total: int = Field(..., ge=0)
|
||||
|
||||
|
||||
class JailConfigFileContent(BaseModel):
|
||||
class JailConfigFileContent(BanGuiBaseModel):
|
||||
"""Single jail config file with its raw content."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
name: str = Field(..., description="Jail name (file stem).")
|
||||
filename: str = Field(..., description="Actual filename.")
|
||||
enabled: bool = Field(..., description="Whether the jail is enabled.")
|
||||
content: str = Field(..., description="Raw file content.")
|
||||
|
||||
|
||||
class JailConfigFileEnabledUpdate(BaseModel):
|
||||
class JailConfigFileEnabledUpdate(BanGuiBaseModel):
|
||||
"""Payload for ``PUT /api/config/jail-files/{filename}/enabled``."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
enabled: bool = Field(..., description="New enabled state for this jail.")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Generic conf-file entry (shared by filter.d and action.d)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ConfFileEntry(BaseModel):
|
||||
class ConfFileEntry(BanGuiBaseModel):
|
||||
"""Metadata for a single ``.conf`` or ``.local`` file."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
name: str = Field(..., description="Base name without extension (e.g. ``sshd``).")
|
||||
filename: str = Field(..., description="Actual filename (e.g. ``sshd.conf``).")
|
||||
|
||||
|
||||
class ConfFilesResponse(BaseModel):
|
||||
class ConfFilesResponse(BanGuiBaseModel):
|
||||
"""Response for list endpoints (``GET /api/config/filters`` and ``GET /api/config/actions``)."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
files: list[ConfFileEntry] = Field(default_factory=list)
|
||||
total: int = Field(..., ge=0)
|
||||
|
||||
|
||||
class ConfFileContent(BaseModel):
|
||||
class ConfFileContent(BanGuiBaseModel):
|
||||
"""A conf file with its raw text content."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
name: str = Field(..., description="Base name without extension.")
|
||||
filename: str = Field(..., description="Actual filename.")
|
||||
content: str = Field(..., description="Raw file content.")
|
||||
|
||||
|
||||
class ConfFileUpdateRequest(BaseModel):
|
||||
class ConfFileUpdateRequest(BanGuiBaseModel):
|
||||
"""Payload for ``PUT /api/config/filters/{name}`` and ``PUT /api/config/actions/{name}``."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
content: str = Field(..., description="New raw file content (must not exceed 512 KB).")
|
||||
|
||||
|
||||
class ConfFileCreateRequest(BaseModel):
|
||||
class ConfFileCreateRequest(BanGuiBaseModel):
|
||||
"""Payload for ``POST /api/config/filters`` and ``POST /api/config/actions``."""
|
||||
|
||||
model_config = ConfigDict(strict=True)
|
||||
|
||||
name: str = Field(
|
||||
...,
|
||||
description="New file base name (without extension). Must contain only "
|
||||
|
||||
Reference in New Issue
Block a user