"""Scenario schemas."""

from datetime import datetime
from decimal import Decimal
from typing import Optional, List
from uuid import UUID
from pydantic import BaseModel, Field, ConfigDict


class ScenarioBase(BaseModel):
    """Base scenario schema."""

    name: str = Field(..., min_length=1, max_length=255)
    description: Optional[str] = None
    tags: List[str] = Field(default_factory=list)
    region: str = Field(default="us-east-1", pattern=r"^[a-z]{2}-[a-z]+-[0-9]$")


class ScenarioCreate(ScenarioBase):
    """Schema for creating a scenario."""

    pass


class ScenarioUpdate(BaseModel):
    """Schema for updating a scenario."""

    name: Optional[str] = Field(None, min_length=1, max_length=255)
    description: Optional[str] = None
    tags: Optional[List[str]] = None


class ScenarioResponse(ScenarioBase):
    """Schema for scenario response."""

    model_config = ConfigDict(from_attributes=True)

    id: UUID
    status: str
    created_at: datetime
    updated_at: datetime
    completed_at: Optional[datetime] = None
    started_at: Optional[datetime] = None
    total_requests: int
    total_cost_estimate: Decimal


class ScenarioList(BaseModel):
    """Schema for list of scenarios."""

    items: List[ScenarioResponse]
    total: int
    page: int
    page_size: int
