from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field


class ProxyConfigBase(BaseModel):
    name: str = Field(description="名称")
    proxy_type: str = Field(description="代理类型: http/socks/tunnel")
    platform: str = Field("all", description="目标平台: boss/qcwy/zhilian/all")
    proxy_url: str = Field(description="代理地址")
    is_active: bool = Field(True, description="是否可用")


class ProxyConfigCreate(ProxyConfigBase):
    pass


class ProxyConfigUpdate(BaseModel):
    id: int = Field(description="主键ID")
    name: Optional[str] = Field(None, description="名称")
    proxy_type: Optional[str] = Field(None, description="代理类型: http/socks/tunnel")
    platform: Optional[str] = Field(None, description="目标平台: boss/qcwy/zhilian/all")
    proxy_url: Optional[str] = Field(None, description="代理地址")
    is_active: Optional[bool] = Field(None, description="是否可用")


class ProxyConfigOut(ProxyConfigBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
