2026-06-03 21:40:26 +00:00
|
|
|
"""Pydantic schemas for Note endpoints."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
|
|
|
|
from app.models.note import NoteParentType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoteCreate(BaseModel):
|
|
|
|
|
"""Body for POST /api/v1/notes/."""
|
|
|
|
|
|
|
|
|
|
body: str = Field(..., min_length=1)
|
|
|
|
|
parent_type: NoteParentType
|
|
|
|
|
parent_id: int = Field(..., ge=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoteUpdate(BaseModel):
|
|
|
|
|
"""Body for PATCH /api/v1/notes/{id}."""
|
|
|
|
|
|
2026-06-10 20:52:56 +00:00
|
|
|
body: str | None = Field(None, min_length=1)
|
2026-06-03 21:40:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoteOut(BaseModel):
|
|
|
|
|
"""Response schema for a note."""
|
|
|
|
|
|
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
|
|
id: int
|
|
|
|
|
org_id: int
|
|
|
|
|
body: str
|
|
|
|
|
author_id: int
|
|
|
|
|
parent_type: NoteParentType
|
|
|
|
|
parent_id: int
|
|
|
|
|
created_at: datetime
|
|
|
|
|
updated_at: datetime
|
2026-06-10 20:52:56 +00:00
|
|
|
deleted_at: datetime | None = None
|
2026-06-03 21:40:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["NoteCreate", "NoteOut", "NoteUpdate"]
|