96 lines
2.9 KiB
Python
96 lines
2.9 KiB
Python
|
|
"""Pydantic schemas for Equipment (inventory catalog)."""
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class EquipmentCreateRequest(BaseModel):
|
||
|
|
"""Request body for creating new equipment."""
|
||
|
|
name: str = Field(..., max_length=255)
|
||
|
|
category: str | None = Field(None, max_length=100)
|
||
|
|
brand: str | None = Field(None, max_length=255)
|
||
|
|
serial_number: str | None = Field(None, max_length=100)
|
||
|
|
barcode: str | None = Field(None, max_length=100)
|
||
|
|
qr_code: str | None = Field(None, max_length=500)
|
||
|
|
status: str = Field("available", max_length=20)
|
||
|
|
purchase_price: float | None = None
|
||
|
|
current_value: float | None = None
|
||
|
|
weight_kg: float | None = None
|
||
|
|
dimensions: str | None = Field(None, max_length=255)
|
||
|
|
power_watt: float | None = None
|
||
|
|
notes: str | None = None
|
||
|
|
custom_fields: str | None = None
|
||
|
|
location_id: str | None = None
|
||
|
|
supplier_id: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class EquipmentUpdateRequest(BaseModel):
|
||
|
|
"""Request body for updating existing equipment."""
|
||
|
|
name: str | None = Field(None, max_length=255)
|
||
|
|
category: str | None = Field(None, max_length=100)
|
||
|
|
brand: str | None = Field(None, max_length=255)
|
||
|
|
serial_number: str | None = Field(None, max_length=100)
|
||
|
|
barcode: str | None = Field(None, max_length=100)
|
||
|
|
qr_code: str | None = Field(None, max_length=500)
|
||
|
|
status: str | None = Field(None, max_length=20)
|
||
|
|
purchase_price: float | None = None
|
||
|
|
current_value: float | None = None
|
||
|
|
weight_kg: float | None = None
|
||
|
|
dimensions: str | None = Field(None, max_length=255)
|
||
|
|
power_watt: float | None = None
|
||
|
|
notes: str | None = None
|
||
|
|
custom_fields: str | None = None
|
||
|
|
location_id: str | None = None
|
||
|
|
supplier_id: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class LocationRef(BaseModel):
|
||
|
|
"""Minimal stock location reference."""
|
||
|
|
id: str
|
||
|
|
name: str
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class SupplierRef(BaseModel):
|
||
|
|
"""Minimal supplier (contact) reference."""
|
||
|
|
id: str
|
||
|
|
name: str | None = None
|
||
|
|
company_name: str | None = None
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class EquipmentResponse(BaseModel):
|
||
|
|
"""Public equipment representation."""
|
||
|
|
id: str
|
||
|
|
account_id: str
|
||
|
|
name: str
|
||
|
|
category: str | None = None
|
||
|
|
brand: str | None = None
|
||
|
|
serial_number: str | None = None
|
||
|
|
barcode: str | None = None
|
||
|
|
qr_code: str | None = None
|
||
|
|
status: str
|
||
|
|
purchase_price: float | None = None
|
||
|
|
current_value: float | None = None
|
||
|
|
weight_kg: float | None = None
|
||
|
|
dimensions: str | None = None
|
||
|
|
power_watt: float | None = None
|
||
|
|
notes: str | None = None
|
||
|
|
custom_fields: str | None = None
|
||
|
|
location: LocationRef | None = None
|
||
|
|
supplier: SupplierRef | None = None
|
||
|
|
created_at: str
|
||
|
|
updated_at: str
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class EquipmentListResponse(BaseModel):
|
||
|
|
"""Paginated list of equipment."""
|
||
|
|
items: list[EquipmentResponse]
|
||
|
|
total: int
|
||
|
|
page: int
|
||
|
|
size: int
|