33 lines
622 B
Python
33 lines
622 B
Python
import uuid
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from barker.schemas import to_camel
|
|
from barker.schemas.section import SectionLink
|
|
|
|
|
|
class DeviceIn(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
section: SectionLink
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class Device(DeviceIn):
|
|
id_: uuid.UUID
|
|
|
|
class Config:
|
|
alias_generator = to_camel
|
|
|
|
|
|
class DeviceLink(BaseModel):
|
|
id_: uuid.UUID = Field(...)
|
|
name: Optional[str]
|
|
|
|
class Config:
|
|
fields = {"id_": "id"}
|
|
alias_generator = to_camel
|