TaskPulse/backend/app/schemas/notification.py
Steven 521cf0269c feat: initial TaskPulse release
AI Agent 定时任务跟踪、监控、状态看板系统。

- FastAPI + Vue3 单体应用
- AI Agent 一键接入(批量注册 API)
- 暗色主题 Dashboard
- 后台调度器 + 超时告警
- 飞书/邮件/Webhook 多渠道通知
- Base URL 可配置
- Gunicorn 生产部署
2026-06-14 22:39:23 +08:00

71 lines
1.9 KiB
Python

"""Pydantic schemas — Notifications & Alerts."""
from datetime import datetime
from pydantic import BaseModel, Field
# ── Notification Channel ──────────────────────────────────────────────
class NotificationChannelCreate(BaseModel):
name: str = Field(..., max_length=128)
channel_type: str = Field(..., pattern=r"^(feishu_cli|email|webhook)$")
config: str = Field(..., description="JSON 配置字符串")
class NotificationChannelUpdate(BaseModel):
name: str | None = Field(None, max_length=128)
config: str | None = None
enabled: bool | None = None
class NotificationChannelOut(BaseModel):
id: int
name: str
channel_type: str
config: str
enabled: bool
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}
# ── Alert Rule ────────────────────────────────────────────────────────
class AlertRuleCreate(BaseModel):
task_id: int
channel_id: int
alert_type: str = Field(default="missed_run", pattern=r"^(missed_run|failure)$")
class AlertRuleOut(BaseModel):
id: int
task_id: int
channel_id: int
channel_name: str = ""
alert_type: str
enabled: bool
created_at: datetime
model_config = {"from_attributes": True}
# ── Alert ─────────────────────────────────────────────────────────────
class AlertOut(BaseModel):
id: int
task_id: int | None = None
task_name: str = ""
alert_type: str
message: str
status: str
acknowledged_at: datetime | None = None
created_at: datetime
model_config = {"from_attributes": True}
class AlertAcknowledge(BaseModel):
pass