"""
Schema Pydantic per i preset di permessi (sottoruoli nominati).
"""

import uuid
from datetime import datetime

from pydantic import BaseModel, Field


class PermissionPresetCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=100, description="Nome del preset")
    description: str | None = Field(None, description="Descrizione opzionale")
    can_read: bool = Field(True, description="Permesso lettura messaggi")
    can_send: bool = Field(False, description="Permesso invio PEC")
    can_manage: bool = Field(False, description="Permesso gestione casella")
    can_conserve: bool = Field(False, description="Permesso conservazione documenti")


class PermissionPresetUpdate(BaseModel):
    name: str | None = Field(None, min_length=1, max_length=100)
    description: str | None = None
    can_read: bool | None = None
    can_send: bool | None = None
    can_manage: bool | None = None
    can_conserve: bool | None = None


class PermissionPresetResponse(BaseModel):
    id: uuid.UUID
    tenant_id: uuid.UUID
    name: str
    description: str | None
    can_read: bool
    can_send: bool
    can_manage: bool
    can_conserve: bool
    created_by: uuid.UUID | None
    created_at: datetime
    updated_at: datetime

    model_config = {"from_attributes": True}
