"""Schemas Pydantic du service de prediction (contrat d'entree/sortie de l'API)."""

import datetime

from pydantic import BaseModel, Field


class PredictionRequest(BaseModel):
    """Ce que le client fournit : QUI et QUAND, pas les features (calculees cote serveur)."""

    client_id: str = Field(
        ...,
        description="Identifiant du client (ex. 'MT_124').",
        examples=["MT_124"],
    )
    date: datetime.date | None = Field(
        default=None,
        description="Date de la prediction (parametre de requete). Optionnelle.",
        examples=["2015-01-01"],
    )


class BatchPredictionRequest(BaseModel):
    """Prediction pour plusieurs clients en une seule requete (inference batch)."""

    client_ids: list[str] = Field(
        ...,
        description="Liste d'identifiants clients.",
        examples=[["MT_124", "MT_156", "MT_158"]],
    )
    date: datetime.date | None = None


class PredictionResponse(BaseModel):
    client_id: str
    prediction_kwh: float = Field(description="Consommation predite (kWh).")
    model_name: str
    model_version: str


class BatchPredictionResponse(BaseModel):
    predictions: list[PredictionResponse]
    # Clients ignores (features introuvables) : on ne fait pas echouer tout le lot.
    unknown_client_ids: list[str] = Field(default_factory=list)
