from pydantic import BaseModel, Field

from app.schemas.common import NaiveDatetime


class ImageEngineCreate(BaseModel):
    name: str = Field(..., max_length=64)
    provider: str = Field(..., max_length=32)
    api_base: str = Field(..., max_length=512)
    api_key: str = Field(default="", max_length=256)
    model_name: str = Field(default="", max_length=128)
    supported_models: str = Field(default='["doubao-seedream-5-0-260128"]')
    supported_sizes: str = Field(default='{}')
    default_size: str = Field(default="2K", max_length=32)
    generate_url: str = Field(default="", max_length=512)
    is_active: bool = True
    priority: int = 0


class ImageEngineOut(ImageEngineCreate):
    id: str
    created_at: NaiveDatetime

    model_config = {"from_attributes": True}


class ImageEnginePublic(BaseModel):
    id: str
    name: str
    provider: str
    supported_models: list[str] = []
    supported_sizes: dict[str, dict[str, str]] = {}
    default_size: str = "2K"


class ImageEngineListResponse(BaseModel):
    items: list[ImageEnginePublic]
