b7c729d331
Routes package with CRUD endpoints: event listing/filtering/tagging/dismissal, known object management with thumbnails, settings CRUD, and stats. 64 tests passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96 lines
2.3 KiB
Python
96 lines
2.3 KiB
Python
"""Pydantic models for frigate-notify v2 API."""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# --- Known Objects ---
|
|
|
|
|
|
class KnownObjectCreate(BaseModel):
|
|
"""Request model for creating a known object."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
type: str = Field(..., pattern="^(person|vehicle|pet)$")
|
|
action: str = Field(default="quiet", pattern="^(quiet|suppress|alert)$")
|
|
|
|
|
|
class KnownObjectUpdate(BaseModel):
|
|
"""Request model for updating a known object."""
|
|
|
|
name: Optional[str] = Field(default=None, min_length=1, max_length=255)
|
|
type: Optional[str] = Field(default=None, pattern="^(person|vehicle|pet)$")
|
|
action: Optional[str] = Field(default=None, pattern="^(quiet|suppress|alert)$")
|
|
|
|
|
|
class KnownObjectResponse(BaseModel):
|
|
"""Response model for a known object."""
|
|
|
|
id: int
|
|
name: str
|
|
type: str
|
|
action: str
|
|
created_at: str
|
|
updated_at: str
|
|
|
|
|
|
# --- Events ---
|
|
|
|
|
|
class TagEventRequest(BaseModel):
|
|
"""Request model for tagging an event with a known object.
|
|
|
|
Either provide known_object_id to link to an existing object,
|
|
or provide name + type to create a new known object.
|
|
"""
|
|
|
|
known_object_id: Optional[int] = None
|
|
name: Optional[str] = Field(default=None, min_length=1, max_length=255)
|
|
type: Optional[str] = Field(default=None, pattern="^(person|vehicle|pet)$")
|
|
|
|
|
|
class EventResponse(BaseModel):
|
|
"""Response model for an event."""
|
|
|
|
id: int
|
|
frigate_event_id: str
|
|
camera: str
|
|
label: str
|
|
score: float
|
|
has_snapshot: bool = False
|
|
snapshot_base64: Optional[str] = None
|
|
match_status: str
|
|
matched_object_id: Optional[int] = None
|
|
matched_object_name: Optional[str] = None
|
|
match_confidence: Optional[float] = None
|
|
ai_description: Optional[str] = None
|
|
notified: bool
|
|
created_at: str
|
|
|
|
|
|
# --- Settings ---
|
|
|
|
|
|
class SettingsResponse(BaseModel):
|
|
"""Response model for application settings."""
|
|
|
|
vision_backend: str
|
|
recognition_enabled: bool
|
|
event_retention_days: int
|
|
|
|
|
|
# --- Stats ---
|
|
|
|
|
|
class StatsResponse(BaseModel):
|
|
"""Response model for application statistics."""
|
|
|
|
total_events: int = 0
|
|
known_matches: int = 0
|
|
unknown_events: int = 0
|
|
unreviewed: int = 0
|
|
known_objects_count: int = 0
|
|
events_today: int = 0
|