51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
|
|
"""
|
||
|
|
Pydantic schemas for the example plugin.
|
||
|
|
|
||
|
|
Customize these for your plugin's API request/response models.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from uuid import UUID
|
||
|
|
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleItemBase(BaseModel):
|
||
|
|
"""Base schema for an example item."""
|
||
|
|
|
||
|
|
name: str = Field(..., min_length=1, max_length=200, description="Item name")
|
||
|
|
description: str | None = Field(None, max_length=1000, description="Item description")
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleItemCreate(ExampleItemBase):
|
||
|
|
"""Schema for creating an example item."""
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleItemUpdate(BaseModel):
|
||
|
|
"""Schema for updating an example item."""
|
||
|
|
|
||
|
|
name: str | None = Field(None, min_length=1, max_length=200)
|
||
|
|
description: str | None = Field(None, max_length=1000)
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleItemResponse(ExampleItemBase):
|
||
|
|
"""Schema for returning an example item."""
|
||
|
|
|
||
|
|
id: UUID
|
||
|
|
tenant_id: UUID
|
||
|
|
is_active: bool
|
||
|
|
created_at: datetime
|
||
|
|
updated_at: datetime
|
||
|
|
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleItemListResponse(BaseModel):
|
||
|
|
"""Schema for a paginated list of example items."""
|
||
|
|
|
||
|
|
items: list[ExampleItemResponse]
|
||
|
|
total: int
|