50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from enum import StrEnum
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class NotificationStatus(StrEnum):
|
|
PENDING = "PENDING"
|
|
DISPATCHING = "DISPATCHING"
|
|
RETRY_WAIT = "RETRY_WAIT"
|
|
DELIVERED = "DELIVERED"
|
|
FAILED = "FAILED"
|
|
HELD_FOR_REVIEW = "HELD_FOR_REVIEW"
|
|
|
|
|
|
class NotificationKind(StrEnum):
|
|
FIRING = "FIRING"
|
|
RESOLVED = "RESOLVED"
|
|
TEST = "TEST"
|
|
|
|
|
|
class NotificationDeliveryResponse(BaseModel):
|
|
"""Safe operator-facing delivery metadata. Payload and destination are never returned."""
|
|
|
|
model_config = ConfigDict(extra="forbid", from_attributes=True)
|
|
|
|
id: UUID
|
|
alert_history_event_id: UUID | None
|
|
route_key: str
|
|
event_kind: NotificationKind
|
|
severity: str | None
|
|
status: NotificationStatus
|
|
attempt_count: int
|
|
next_attempt_at: datetime | None
|
|
last_attempt_at: datetime | None
|
|
delivered_at: datetime | None
|
|
last_http_status: int | None
|
|
last_error_code: str | None
|
|
created_at: datetime
|
|
|
|
|
|
class NotificationTestResponse(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
delivery: NotificationDeliveryResponse
|
|
message: str
|