from datetime import datetime from typing import Optional from pydantic import BaseModel, Field # Shared properties class ItemBase(BaseModel): title: str = Field( ..., min_length=1, max_length=100, description="Title of the item" ) description: Optional[str] = Field( None, description="Optional description of the item" ) is_active: bool = Field(True, description="Is this item active") # Properties to receive via API on creation class ItemCreate(ItemBase): pass # Properties to receive via API on update class ItemUpdate(BaseModel): title: Optional[str] = Field( None, min_length=1, max_length=100, description="Title of the item" ) description: Optional[str] = Field( None, description="Optional description of the item" ) is_active: Optional[bool] = Field(None, description="Is this item active") # Properties shared by models stored in DB class ItemInDBBase(ItemBase): id: int created_at: datetime updated_at: datetime class Config: from_attributes = True # Properties to return to client class Item(ItemInDBBase): pass