35 lines
881 B
Python
35 lines
881 B
Python
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class PlatformBase(BaseModel):
|
|
code: str = Field(min_length=1, max_length=64)
|
|
name: str = Field(min_length=1, max_length=64)
|
|
url: str | None = None
|
|
description: str | None = None
|
|
status: str = Field(default="ACTIVE", pattern=r"^(ACTIVE|DISABLED)$")
|
|
|
|
|
|
class PlatformCreate(PlatformBase):
|
|
pass
|
|
|
|
|
|
class PlatformUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=64)
|
|
url: str | None = None
|
|
description: str | None = None
|
|
status: str | None = Field(default=None, pattern=r"^(ACTIVE|DISABLED)$")
|
|
|
|
|
|
class PlatformRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
code: str
|
|
name: str
|
|
url: str | None = None
|
|
description: str | None = None
|
|
status: str
|
|
product_count: int = 0
|