slicer.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """Pydantic schemas for slice requests."""
  2. from pydantic import BaseModel, Field
  3. class SliceRequest(BaseModel):
  4. """Body for `POST /library/files/{file_id}/slice`."""
  5. printer_preset_id: int = Field(..., description="LocalPreset id with preset_type='printer'")
  6. process_preset_id: int = Field(..., description="LocalPreset id with preset_type='process'")
  7. filament_preset_id: int = Field(..., description="LocalPreset id with preset_type='filament'")
  8. plate: int | None = Field(
  9. default=None,
  10. ge=1,
  11. description="Plate number to slice (1-indexed). Defaults to plate 1 on the sidecar.",
  12. )
  13. export_3mf: bool = Field(
  14. default=False,
  15. description="If true, request a 3MF response with embedded G-code instead of raw G-code.",
  16. )
  17. class SliceResponse(BaseModel):
  18. """Response from `POST /library/files/{file_id}/slice`. The result lands
  19. in the user's library as a new ``LibraryFile`` (in the same folder as
  20. the source)."""
  21. library_file_id: int
  22. name: str
  23. print_time_seconds: int
  24. filament_used_g: float
  25. filament_used_mm: float
  26. used_embedded_settings: bool = False
  27. class SliceArchiveResponse(BaseModel):
  28. """Response from `POST /archives/{archive_id}/slice`. The result lands
  29. in the user's archives as a new ``PrintArchive`` row, inheriting
  30. printer / project metadata from the source archive."""
  31. archive_id: int
  32. name: str
  33. print_time_seconds: int
  34. filament_used_g: float
  35. filament_used_mm: float
  36. used_embedded_settings: bool = False