"""Job Schemas"""
from pydantic import BaseModel
from typing import Optional, List, Dict, Any
from datetime import datetime
from uuid import UUID


class JobBase(BaseModel):
    module: str
    action: str
    priority: int = 5
    input_data: Dict[str, Any]


class JobCreate(JobBase):
    user_id: Optional[UUID] = None
    project_id: Optional[UUID] = None
    input_asset_ids: Optional[List[UUID]] = None


class JobUpdate(BaseModel):
    status: Optional[str] = None
    progress: Optional[int] = None
    output_data: Optional[Dict[str, Any]] = None
    output_asset_ids: Optional[List[UUID]] = None
    error_message: Optional[str] = None


class JobResponse(JobBase):
    id: UUID
    user_id: Optional[UUID] = None
    project_id: Optional[UUID] = None
    status: str
    progress: int
    output_data: Optional[Dict[str, Any]] = None
    input_asset_ids: Optional[List[UUID]] = None
    output_asset_ids: Optional[List[UUID]] = None
    error_message: Optional[str] = None
    api_provider: Optional[str] = None
    api_model: Optional[str] = None
    queued_at: Optional[datetime] = None
    started_at: Optional[datetime] = None
    completed_at: Optional[datetime] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
