from datetime import datetime from typing import Literal, Optional from pydantic import BaseModel, ConfigDict, Field class LocalStorageConfig(BaseModel): path: str = Field(..., min_length=1, description="本地存储根目录绝对路径") class S3StorageConfig(BaseModel): endpoint_url: Optional[str] = Field(None, description="MinIO/Ceph 自定义 endpoint,留空使用 AWS") region: str = Field("us-east-1") bucket: str = Field(..., min_length=1) access_key: str = Field(..., min_length=1) secret_key: str = Field(..., min_length=1) use_ssl: bool = True path_prefix: str = Field("", description="对象 key 前缀,可空") addressing_style: Literal["auto", "path", "virtual"] = "auto" class StorageBase(BaseModel): name: str = Field(..., min_length=1, max_length=64) type: Literal["local", "s3"] is_default: bool = False class StorageCreate(StorageBase): config: dict class StorageUpdate(BaseModel): name: Optional[str] = Field(None, min_length=1, max_length=64) is_default: Optional[bool] = None config: Optional[dict] = None class StorageOut(BaseModel): model_config = ConfigDict(from_attributes=True) id: int name: str type: str is_default: bool created_at: datetime updated_at: datetime class StorageTestResponse(BaseModel): ok: bool message: str