39 lines
835 B
Python
39 lines
835 B
Python
from pydantic import BaseModel
|
|
from typing import List, Optional
|
|
|
|
|
|
class BuiltMelodyCreate(BaseModel):
|
|
name: str
|
|
pid: str
|
|
steps: str # raw step string e.g. "1,2,2+1,1,2,3+1"
|
|
|
|
|
|
class BuiltMelodyUpdate(BaseModel):
|
|
name: Optional[str] = None
|
|
pid: Optional[str] = None
|
|
steps: Optional[str] = None
|
|
|
|
|
|
class BuiltMelodyInDB(BaseModel):
|
|
id: str
|
|
name: str
|
|
pid: str
|
|
steps: str
|
|
binary_path: Optional[str] = None
|
|
binary_url: Optional[str] = None
|
|
progmem_code: Optional[str] = None
|
|
assigned_melody_ids: List[str] = []
|
|
created_at: str
|
|
updated_at: str
|
|
|
|
@property
|
|
def step_count(self) -> int:
|
|
if not self.steps:
|
|
return 0
|
|
return len(self.steps.split(","))
|
|
|
|
|
|
class BuiltMelodyListResponse(BaseModel):
|
|
melodies: List[BuiltMelodyInDB]
|
|
total: int
|