from typing import List, Optional
from datetime import datetime
from pydantic import BaseModel
from fastapi import UploadFile

# Base schema with common attributes
class FileBase(BaseModel):
    name: str
    path: str
    type: Optional[str] = None
    size: Optional[int] = None
    content_type: Optional[str] = None
    file_metadata: Optional[dict] = None

# Schema for creating a new file
class FileCreate(FileBase):
    pass

# Schema for updating a file
class FileUpdate(FileBase):
    pass

# Schema for reading a file
class FileInDB(FileBase):
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

# Schema for deleting a file
class FileDelete(BaseModel):
    message: str

# Schema for listing files
class FileList(BaseModel):
    files: List[FileInDB]
    total: int
    page: int
    limit: int

# Schema for file upload
class FileUpload(BaseModel):
    file: UploadFile 