from __future__ import annotations

from enum import Enum

from pydantic import BaseModel, ConfigDict


class Pd4castrBaseModel(BaseModel):
    model_config = ConfigDict(extra="ignore")


class FileFormat(str, Enum):
    json = "json"
    csv = "csv"
    parquet = "parquet"


class TimeHorizon(Pd4castrBaseModel):
    name: str
    shortName: str
    key: str


class ModelMetadata(Pd4castrBaseModel):
    description: str | None = None
    releaseDate: str | None = None
    resolution: str | None = None
    baseComparisonModel: str | None = None


class UISpecification(Pd4castrBaseModel):
    seriesKey: bool | None = None
    colours: list[str] | None = None


class ColumnSpecification(Pd4castrBaseModel):
    name: str
    type: str
    ui: UISpecification | None = None


class SensitivitySpecification(Pd4castrBaseModel):
    name: str
    categories: list[str]


class ForecastVariableSpecification(Pd4castrBaseModel):
    name: str
    shortName: str
    key: str


class Model(Pd4castrBaseModel):
    id: str
    modelGroupId: str
    name: str
    displayName: str
    notes: str
    revision: int
    dockerImage: str
    createdAt: str
    horizon: TimeHorizon
    modelMetadata: ModelMetadata
    outputSpecification: list[ColumnSpecification]
    tags: list[str]
    sensitivities: list[SensitivitySpecification]
    outputFileFormat: FileFormat
    displayTimezone: str
    forecastVariable: ForecastVariableSpecification


class Organisation(Pd4castrBaseModel):
    id: str
    displayName: str
    slug: str
    domains: list[str]
    permissions: list[str]


class User(Pd4castrBaseModel):
    id: str
    email: str
    organisation: Organisation | None = None
