import uuid
from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class ReleaseCreate(BaseModel):
    name: str = Field(min_length=1, max_length=200)
    description: str | None = Field(default=None, max_length=1000)


class ReleaseRead(BaseModel):
    model_config = ConfigDict(from_attributes=True)
    id: uuid.UUID
    tenant_id: uuid.UUID
    name: str
    description: str | None
    snapshot: dict
    created_by: uuid.UUID | None
    created_at: datetime
    updated_at: datetime


class ReleaseSummary(BaseModel):
    """A lighter read model for the list view — the full snapshot is only
    fetched when a specific release is opened."""

    model_config = ConfigDict(from_attributes=True)
    id: uuid.UUID
    tenant_id: uuid.UUID
    name: str
    description: str | None
    created_by: uuid.UUID | None
    created_at: datetime
    counts: dict[str, int]
