"""Base request/response models and the list envelope.""" from datetime import datetime from typing import Generic, TypeVar from uuid import UUID from pydantic import BaseModel, ConfigDict T = TypeVar("T") class RequestModel(BaseModel): """Request bodies reject unknown fields and trim strings.""" model_config = ConfigDict(extra="forbid", str_strip_whitespace=True) class ResponseModel(BaseModel): model_config = ConfigDict(from_attributes=True) class Page(ResponseModel, Generic[T]): items: list[T] next_cursor: str | None = None class Items(ResponseModel, Generic[T]): """A complete (unpaginated) list.""" items: list[T] class MediaRef(ResponseModel): """A short-lived authorised read URL for stored media. Refetch the owning resource when it expires.""" upload_id: UUID url: str expires_at: datetime seconds: float | None = None