46 lines
1011 B
Python
46 lines
1011 B
Python
from pydantic import BaseModel, field_validator
|
|
from typing import Literal
|
|
|
|
|
|
class CaptureRequest(BaseModel):
|
|
id: str
|
|
created_at: str
|
|
kind: Literal["note", "todo"]
|
|
body: str
|
|
tags: list[str]
|
|
device: str
|
|
|
|
@field_validator("body")
|
|
@classmethod
|
|
def body_must_not_be_empty(cls, v: str) -> str:
|
|
stripped = v.strip()
|
|
if not stripped:
|
|
raise ValueError("body must not be empty")
|
|
return stripped
|
|
|
|
@field_validator("id")
|
|
@classmethod
|
|
def id_must_not_be_empty(cls, v: str) -> str:
|
|
if not v.strip():
|
|
raise ValueError("id must not be empty")
|
|
return v
|
|
|
|
@field_validator("device")
|
|
@classmethod
|
|
def device_must_not_be_empty(cls, v: str) -> str:
|
|
if not v.strip():
|
|
raise ValueError("device must not be empty")
|
|
return v
|
|
|
|
|
|
class CaptureResponse(BaseModel):
|
|
ok: bool
|
|
status: str
|
|
id: str
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
ok: bool
|
|
service: str
|
|
version: str
|