mirror of
https://github.com/idrainformatica/PecFlow.git
synced 2026-06-16 12:45:42 +02:00
Audit Log
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Schemi Pydantic per Audit Log.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel, field_validator
|
||||
|
||||
from app.core.pagination import PaginatedResponse
|
||||
|
||||
|
||||
class AuditLogResponse(BaseModel):
|
||||
"""Risposta singolo evento audit."""
|
||||
|
||||
id: int
|
||||
tenant_id: Optional[uuid.UUID] = None
|
||||
user_id: Optional[uuid.UUID] = None
|
||||
action: str
|
||||
resource_type: Optional[str] = None
|
||||
resource_id: Optional[uuid.UUID] = None
|
||||
ip_address: Optional[str] = None
|
||||
user_agent: Optional[str] = None
|
||||
payload: Optional[dict] = None
|
||||
outcome: str
|
||||
occurred_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
@field_validator("ip_address", mode="before")
|
||||
@classmethod
|
||||
def coerce_ip_address(cls, v: Any) -> Optional[str]:
|
||||
"""Converte IPv4Address/IPv6Address (tipo PostgreSQL INET) in stringa."""
|
||||
if v is None:
|
||||
return None
|
||||
return str(v)
|
||||
|
||||
|
||||
# Lista paginata
|
||||
AuditLogListResponse = PaginatedResponse[AuditLogResponse]
|
||||
Reference in New Issue
Block a user