Added external ID fields to filaments and vendors

This commit is contained in:
Donkie
2024-05-12 19:31:12 +02:00
parent 36945f449d
commit 1e4c73138c
7 changed files with 69 additions and 0 deletions

View File

@@ -82,6 +82,13 @@ class FilamentParameters(BaseModel):
description="Hexadecimal color code of the filament, e.g. FF0000 for red. Supports alpha channel at the end.",
example="FF0000",
)
external_id: Optional[str] = Field(
max_length=256,
description=(
"Set if this filament comes from an external database. This contains the ID in the external database."
),
example="polymaker_pla_polysonicblack_1000_175",
)
extra: Optional[dict[str, str]] = Field(
None,
description="Extra fields for this filament.",
@@ -357,6 +364,7 @@ async def create( # noqa: ANN201
settings_extruder_temp=body.settings_extruder_temp,
settings_bed_temp=body.settings_bed_temp,
color_hex=body.color_hex,
external_id=body.external_id,
extra=body.extra,
)

View File

@@ -61,6 +61,13 @@ class Vendor(BaseModel):
name: str = Field(max_length=64, description="Vendor name.", example="Polymaker")
comment: Optional[str] = Field(max_length=1024, description="Free text comment about this vendor.", example="")
empty_spool_weight: Optional[float] = Field(gt=0, description="The empty spool weight, in grams.", example=140)
external_id: Optional[str] = Field(
max_length=256,
description=(
"Set if this vendor comes from an external database. This contains the ID in the external database."
),
example="eSun",
)
extra: dict[str, str] = Field(
description=(
"Extra fields for this vendor. All values are JSON-encoded data. "
@@ -77,6 +84,7 @@ class Vendor(BaseModel):
name=item.name,
comment=item.comment,
empty_spool_weight=item.empty_spool_weight,
external_id=item.external_id,
extra={field.key: field.value for field in item.extra},
)
@@ -137,6 +145,13 @@ class Filament(BaseModel):
description="Hexadecimal color code of the filament, e.g. FF0000 for red. Supports alpha channel at the end.",
example="FF0000",
)
external_id: Optional[str] = Field(
max_length=256,
description=(
"Set if this filament comes from an external database. This contains the ID in the external database."
),
example="polymaker_pla_polysonicblack_1000_175",
)
extra: dict[str, str] = Field(
description=(
"Extra fields for this filament. All values are JSON-encoded data. "
@@ -163,6 +178,7 @@ class Filament(BaseModel):
settings_extruder_temp=item.settings_extruder_temp,
settings_bed_temp=item.settings_bed_temp,
color_hex=item.color_hex,
external_id=item.external_id,
extra={field.key: field.value for field in item.extra},
)

View File

@@ -38,6 +38,13 @@ class VendorParameters(BaseModel):
description="The weight of an empty spool, in grams.",
example=200,
)
external_id: Optional[str] = Field(
max_length=256,
description=(
"Set if this vendor comes from an external database. This contains the ID in the external database."
),
example="eSun",
)
extra: Optional[dict[str, str]] = Field(
None,
description="Extra fields for this vendor.",
@@ -191,6 +198,7 @@ async def create( # noqa: ANN201
name=body.name,
comment=body.comment,
empty_spool_weight=body.empty_spool_weight,
external_id=body.external_id,
extra=body.extra,
)