from pydantic import BaseModel, Field

from app.schemas.common import NaiveDatetime


class VideoEngineCreate(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_ratios: str = Field(default='["16:9","4:3","1:1","3:4","9:16","21:9"]')
    supported_resolutions: str = Field(default='["480p","720p","1080p"]')
    supported_durations: str = Field(default='[4,5,6,7,8,9,10,11,12,13,14,15]')
    max_duration: int = Field(default=15)
    generate_url: str = Field(default="", max_length=512)
    query_url: str = Field(default="", max_length=512)
    is_active: bool = True
    priority: int = 0


class VideoEngineOut(VideoEngineCreate):
    id: str
    created_at: NaiveDatetime

    model_config = {"from_attributes": True}


class VideoEnginePublic(BaseModel):
    id: str
    name: str
    provider: str
    supported_ratios: list[str] = []
    supported_resolutions: list[str] = []
    supported_durations: list[int] = []


class VideoEngineListResponse(BaseModel):
    items: list[VideoEnginePublic]
