from typing import Optional
from pydantic import BaseModel, Field


class StartWorkflowRequest(BaseModel):
    """Request to start a video processing workflow."""

    video_path: str = Field(
        ..., description="Path or URL to video file (e.g., s3://bucket/video.mp4)"
    )
    video_id: str = Field(..., description="Unique identifier for this video")
    processor_kwargs: Optional[dict] = Field(
        default_factory=dict,
        description="Additional kwargs passed to all processors (e.g., {'num_frames': 10})",
    )


class StartWorkflowResponse(BaseModel):
    """Response after starting a workflow."""

    workflow_id: str = Field(..., description="Temporal workflow ID for tracking")
    video_id: str = Field(..., description="Video identifier")
    status: str = Field(..., description="Workflow status (started)")
    message: str = Field(..., description="Human-readable message")


class WorkflowProgressResponse(BaseModel):
    """Workflow progress information."""

    workflow_id: str = Field(..., description="Workflow ID")
    status: str = Field(
        ...,
        description="Workflow status (running, completed, failed, cancelled, terminated, timed_out)",
    )
    total_processors: int = Field(..., description="Total number of processors to execute")
    completed_processors: int = Field(..., description="Number of completed processors")
    current_processor: str = Field(..., description="Currently executing processor")
    progress_pct: float = Field(..., description="Progress percentage (0-100)")
    completed_processor_names: list[str] = Field(
        default_factory=list, description="List of completed processor names"
    )


class WorkflowResultResponse(BaseModel):
    """Complete workflow result."""

    workflow_id: str = Field(..., description="Workflow ID")
    video_id: str = Field(..., description="Video identifier")
    status: str = Field(..., description="Workflow status")
    results: dict = Field(..., description="Results from all processors")
    total_processors: int = Field(..., description="Total processors executed")
    completed_processors: int = Field(..., description="Successfully completed processors")
