Files

57 lines
1.2 KiB
Python

"""Pydantic schemas for Tag and TagLink endpoints."""
from __future__ import annotations
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from app.models.tag_link import TagLinkParentType
class TagCreate(BaseModel):
"""Body for POST /api/v1/tags/."""
name: str = Field(..., min_length=1, max_length=64)
color: str = Field(default="#3B82F6", pattern=r"^#[0-9A-Fa-f]{6}$")
class TagOut(BaseModel):
"""Response schema for a tag."""
model_config = ConfigDict(from_attributes=True)
id: int
org_id: int
name: str
color: str
created_at: datetime
updated_at: datetime
deleted_at: datetime | None = None
class TagLinkCreate(BaseModel):
"""Body for POST /api/v1/tags/link."""
tag_id: int = Field(..., ge=1)
parent_type: TagLinkParentType
parent_id: int = Field(..., ge=1)
class TagLinkOut(BaseModel):
"""Response schema for a tag link."""
model_config = ConfigDict(from_attributes=True)
id: int
org_id: int
tag_id: int
parent_type: TagLinkParentType
parent_id: int
created_at: datetime
updated_at: datetime
deleted_at: datetime | None = None
__all__ = ["TagCreate", "TagLinkCreate", "TagLinkOut", "TagOut"]