bmc_hub/app/models/schemas.py
2025-12-05 14:22:39 +01:00

52 lines
949 B
Python

"""
Pydantic Models and Schemas
"""
from pydantic import BaseModel
from typing import Optional
from datetime import datetime
class CustomerBase(BaseModel):
"""Base customer schema"""
name: str
email: Optional[str] = None
phone: Optional[str] = None
address: Optional[str] = None
class CustomerCreate(CustomerBase):
"""Schema for creating a customer"""
pass
class Customer(CustomerBase):
"""Full customer schema"""
id: int
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class HardwareBase(BaseModel):
"""Base hardware schema"""
serial_number: str
model: str
customer_id: int
class HardwareCreate(HardwareBase):
"""Schema for creating hardware"""
pass
class Hardware(HardwareBase):
"""Full hardware schema"""
id: int
created_at: datetime
class Config:
from_attributes = True