feat: scaffold v2 with FastAPI, SQLite database, and project structure
Migrate from raw HTTPServer to FastAPI, add SQLite database with schema for known objects, embeddings, events, and settings. Add centralized config, Pydantic models, and 22 database integration tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
"""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."""
|
||||
|
||||
known_object_id: int
|
||||
match_status: str = Field(default="known", pattern="^(known|unknown|ambiguous)$")
|
||||
|
||||
|
||||
class EventResponse(BaseModel):
|
||||
"""Response model for an event."""
|
||||
|
||||
id: int
|
||||
frigate_event_id: str
|
||||
camera: str
|
||||
label: str
|
||||
score: float
|
||||
match_status: str
|
||||
matched_object_id: Optional[int] = 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."""
|
||||
|
||||
events_processed: int
|
||||
mqtt_connected: bool
|
||||
last_event: Optional[str] = None
|
||||
total_events_stored: int = 0
|
||||
known_objects_count: int = 0
|
||||
Reference in New Issue
Block a user