Files
remnawave-bedolaga-telegram…/app/webapi/schemas/logs.py
c0mrade 9a2aea038a chore: add uv package manager and ruff linter configuration
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
2026-01-24 17:45:27 +03:00

101 lines
3.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Pydantic-схемы для работы с логами административного API."""
from __future__ import annotations
from datetime import datetime
from typing import Any
from pydantic import BaseModel, Field
class MonitoringLogEntry(BaseModel):
"""Запись лога мониторинга."""
id: int
event_type: str = Field(..., description='Тип события мониторинга')
message: str = Field(..., description='Краткое описание события')
data: dict[str, Any] | None = Field(
default=None,
description='Дополнительные данные события',
)
is_success: bool = Field(..., description='Флаг успешности выполнения операции')
created_at: datetime = Field(..., description='Дата и время создания записи')
class MonitoringLogListResponse(BaseModel):
"""Ответ со списком логов мониторинга."""
total: int = Field(..., ge=0)
limit: int = Field(..., ge=1)
offset: int = Field(..., ge=0)
items: list[MonitoringLogEntry]
class MonitoringLogTypeListResponse(BaseModel):
"""Ответ со списком доступных типов событий мониторинга."""
items: list[str] = Field(default_factory=list)
class SupportAuditLogEntry(BaseModel):
"""Запись аудита модераторов поддержки."""
id: int
actor_user_id: int | None
actor_telegram_id: int | None = None
is_moderator: bool
action: str
ticket_id: int | None
target_user_id: int | None
details: dict[str, Any] | None = None
created_at: datetime
class SupportAuditLogListResponse(BaseModel):
"""Ответ со списком аудита поддержки."""
total: int = Field(..., ge=0)
limit: int = Field(..., ge=1)
offset: int = Field(..., ge=0)
items: list[SupportAuditLogEntry]
class SupportAuditActionsResponse(BaseModel):
"""Ответ со списком доступных действий аудита поддержки."""
items: list[str] = Field(default_factory=list)
class SystemLogPreviewResponse(BaseModel):
"""Ответ с превью системного лог-файла бота."""
path: str = Field(..., description='Абсолютный путь до лог-файла')
exists: bool = Field(..., description='Флаг наличия лог-файла')
updated_at: datetime | None = Field(
default=None,
description='Дата и время последнего изменения лог-файла',
)
size_bytes: int = Field(..., ge=0, description='Размер лог-файла в байтах')
size_chars: int = Field(..., ge=0, description='Количество символов в лог-файле')
preview: str = Field(
default='',
description='Фрагмент содержимого лог-файла, возвращаемый для предпросмотра',
)
preview_chars: int = Field(..., ge=0, description='Размер предпросмотра в символах')
preview_truncated: bool = Field(..., description='Флаг усечения предпросмотра относительно полного файла')
download_url: str | None = Field(
default=None,
description='Относительный путь до endpoint для скачивания лог-файла',
)
class SystemLogFullResponse(BaseModel):
"""Полное содержимое системного лог-файла."""
path: str
exists: bool
updated_at: datetime | None = None
size_bytes: int
size_chars: int
content: str