""" Pydantic schemas for Annotation API. Defines request and response models for annotation operations. """ from datetime import datetime from typing import Any from pydantic import BaseModel, Field class AnnotationCreate(BaseModel): """Schema for creating a new annotation.""" task_id: str = Field(..., min_length=1, description="Task ID this annotation belongs to") user_id: str = Field(..., min_length=1, description="User ID who created this annotation") result: dict = Field(..., description="Annotation result data (JSON object)") class Config: json_schema_extra = { "example": { "task_id": "task_456def", "user_id": "user_001", "result": { "annotations": [ { "id": "ann_1", "type": "rectanglelabels", "value": { "x": 10, "y": 20, "width": 100, "height": 50, "rectanglelabels": ["Cat"] } } ] } } } class AnnotationUpdate(BaseModel): """Schema for updating an existing annotation.""" result: dict = Field(..., description="Updated annotation result data (JSON object)") class Config: json_schema_extra = { "example": { "result": { "annotations": [ { "id": "ann_1", "type": "rectanglelabels", "value": { "x": 15, "y": 25, "width": 110, "height": 55, "rectanglelabels": ["Dog"] } } ] } } } class AnnotationResponse(BaseModel): """Schema for annotation response.""" id: str = Field(..., description="Annotation unique identifier") task_id: str = Field(..., description="Task ID this annotation belongs to") user_id: str = Field(..., description="User ID who created this annotation") result: dict = Field(..., description="Annotation result data (JSON object)") created_at: datetime = Field(..., description="Annotation creation timestamp") updated_at: datetime = Field(..., description="Annotation last update timestamp") class Config: json_schema_extra = { "example": { "id": "ann_789ghi", "task_id": "task_456def", "user_id": "user_001", "result": { "annotations": [ { "id": "ann_1", "type": "rectanglelabels", "value": { "x": 10, "y": 20, "width": 100, "height": 50, "rectanglelabels": ["Cat"] } } ] }, "created_at": "2024-01-12T12:00:00", "updated_at": "2024-01-12T12:30:00" } }