49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
"""Pydantic schemas for Audit Log endpoints."""
|
|
|
|
# Import uuid
|
|
import uuid
|
|
|
|
# Import datetime from datetime
|
|
from datetime import datetime
|
|
from typing import Any, Optional
|
|
|
|
# Import BaseModel, ConfigDict from pydantic
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
# Define class AuditLogOut
|
|
class AuditLogOut(BaseModel):
|
|
"""Complete representation of an audit log entry."""
|
|
|
|
# id: uuid.UUID
|
|
id: uuid.UUID
|
|
# Assign user_id = None
|
|
user_id: uuid.UUID | None = None
|
|
# Assign username = None # Populated from user relationship
|
|
username: str | None = None # Populated from user relationship
|
|
# action: str
|
|
action: str
|
|
# Assign entity_type = None
|
|
entity_type: str | None = None
|
|
# Assign entity_id = None
|
|
entity_id: str | None = None
|
|
timestamp: Optional[datetime] = None
|
|
details: dict[str, Any] | None = None
|
|
|
|
# Assign model_config = ConfigDict(from_attributes=True)
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
# Define class AuditLogPage
|
|
class AuditLogPage(BaseModel):
|
|
"""Paginated response for audit logs."""
|
|
|
|
# items: list[AuditLogOut]
|
|
items: list[AuditLogOut]
|
|
# total: int
|
|
total: int
|
|
# offset: int
|
|
offset: int
|
|
# limit: int
|
|
limit: int
|