from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from enum import Enum

class AnalysisStatus(str, Enum):
    PENDING = "pending"
    IN_PROGRESS = "in_progress"
    COMPLETED = "completed"
    FAILED = "failed"

class StockSearchRequest(BaseModel):
    query: str

class StockSearchResponse(BaseModel):
    market: str
    symbol: str
    company_name: str

class AnalysisRequest(BaseModel):
    market: str
    symbol: str
    company_name: str

class ReportSectionSchema(BaseModel):
    section_name: str
    content: str
    created_at: datetime
    
    class Config:
        from_attributes = True

class ReportResponse(BaseModel):
    id: int
    market: str
    symbol: str
    company_name: str
    status: AnalysisStatus
    ai_model: Optional[str] = None
    created_at: datetime
    sections: List[ReportSectionSchema] = []

    class Config:
        from_attributes = True

class ConfigUpdateRequest(BaseModel):
    key: str
    value: str
