Files
TieMeasureFlow/src/backend/models/api/station.py
T

71 lines
1.9 KiB
Python

"""Pydantic schemas for Station and StationRecipeAssignment."""
from src.backend.models.api.tipi import UtcDateTime
from typing import Optional
from pydantic import BaseModel, ConfigDict, Field
class StationCreate(BaseModel):
code: str = Field(..., min_length=1, max_length=100)
name: str = Field(..., min_length=1, max_length=255)
location: Optional[str] = Field(default=None, max_length=255)
notes: Optional[str] = None
active: bool = True
class StationUpdate(BaseModel):
name: Optional[str] = Field(default=None, min_length=1, max_length=255)
location: Optional[str] = Field(default=None, max_length=255)
notes: Optional[str] = None
active: Optional[bool] = None
class StationResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
code: str
name: str
location: Optional[str]
notes: Optional[str]
active: bool
created_by: int
created_at: UtcDateTime
class StationRecipeAssignmentCreate(BaseModel):
recipe_id: int = Field(..., gt=0)
class StationRecipeAssignmentResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
station_id: int
recipe_id: int
assigned_by: int
assigned_at: UtcDateTime
class RecipeSummary(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
code: str
name: str
active: bool
image_path: Optional[str] = None
description: Optional[str] = None
# The selection screen has to know before the operator starts: what a recipe
# demands is the difference between an enabled Avvia and a disabled one.
requires_lot: bool = False
requires_serial: bool = False
class StationWithRecipesResponse(StationResponse):
recipes: list[RecipeSummary] = Field(default_factory=list)
class StationResetResponse(BaseModel):
"""Outcome of clearing every recipe assignment of a station."""
station_id: int
removed: int