omni_orchestrator/schemas/v1/models/
alert.rs1use std::collections::HashMap;
2
3use rocket::serde::json::Json;
4use serde::{Deserialize, Serialize};
5use chrono::{DateTime, NaiveDateTime, Utc};
6use serde_json::Value;
7use sqlx::Row;
8
9#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
11pub struct Alert {
12 pub id: i64,
13 pub alert_type: String,
14 pub severity: String,
15 pub service: String,
16 pub message: String,
17 pub timestamp: DateTime<Utc>,
18 pub status: String,
19 pub resolved_at: Option<DateTime<Utc>>,
20 pub resolved_by: Option<i64>,
21 pub metadata: Option<serde_json::Value>,
22 pub org_id: Option<i64>,
23 pub app_id: Option<i64>,
24 pub instance_id: Option<i64>,
25 pub region_id: Option<i64>,
26 pub node_id: Option<i64>,
27}
28
29#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
31pub struct AlertAcknowledgment {
32 pub id: i64,
33 pub alert_id: i64,
34 pub user_id: i64,
35 pub acknowledged_at: DateTime<Utc>,
36 pub notes: Option<String>,
37}
38
39#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
41pub struct AlertEscalation {
42 pub id: i64,
43 pub alert_id: i64,
44 pub escalation_level: i64,
45 pub escalated_at: DateTime<Utc>,
46 pub escalated_to: serde_json::Value,
47 pub escalation_method: String,
48 pub response_required_by: Option<DateTime<Utc>>,
49}
50
51#[derive(Debug, Serialize, Deserialize)]
54pub struct AlertWithRelatedData {
55 pub alert: Alert,
57 pub acknowledgments: Vec<AlertAcknowledgment>,
59 pub escalations: Vec<AlertEscalation>,
61 pub history: Vec<AlertHistory>
63}
64
65#[derive(Debug, Serialize, Deserialize)]
68pub struct AlertWithAcknowledgments {
69 pub alert: Alert,
71 pub acknowledgments: Vec<AlertAcknowledgment>,
73 pub is_acknowledged: bool,
75 pub acknowledgment_count: i64,
77 pub latest_acknowledgment: Option<chrono::DateTime<chrono::Utc>>,
79}
80
81#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
83pub struct AlertHistory {
84 pub id: i64,
85 pub alert_id: i64,
86 pub action: String,
87 pub performed_by: Option<i64>,
88 pub performed_at: DateTime<Utc>,
89 pub previous_state: Option<serde_json::Value>,
90 pub new_state: Option<serde_json::Value>,
91 pub notes: Option<String>,
92}