Files
IPCam_OrangePi_Dashboard/api/app/models.py
T

43 lines
1.2 KiB
Python

import os
from pydantic import BaseModel, Field
class Camera(BaseModel):
name: str = Field(min_length=1, max_length=64, pattern=r"^[a-zA-Z0-9_\-\/]+$")
rtsp_url: str = Field(min_length=1, max_length=2048)
class Schedule(BaseModel):
enabled: bool = True
weekdays_from: str = Field(default="18:00", pattern=r"^\d{2}:\d{2}$")
weekdays_to: str = Field(default="08:00", pattern=r"^\d{2}:\d{2}$")
weekend_all_day: bool = True
class AppConfig(BaseModel):
mediamtx_api_url: str = Field(
default_factory=lambda: os.getenv("MEDIAMTX_API_URL", "http://127.0.0.1:9997")
)
mediamtx_webrtc_url: str = Field(
default_factory=lambda: os.getenv("MEDIAMTX_WEBRTC_URL", "http://127.0.0.1:8889")
)
recordings_dir: str = Field(default_factory=lambda: os.getenv("RECORDINGS_DIR", "/recordings"))
cameras: list[Camera] = Field(default_factory=list)
schedule: Schedule = Field(default_factory=Schedule)
class RecordingToggle(BaseModel):
enabled: bool
class SchedulerEnabled(BaseModel):
enabled: bool
class ScheduleUpdate(BaseModel):
weekdays_from: str = Field(pattern=r"^\d{2}:\d{2}$")
weekdays_to: str = Field(pattern=r"^\d{2}:\d{2}$")
weekend_all_day: bool