scouter_types/alert/
alerts.rs

1use crate::util::PyHelperFuncs;
2use chrono::{DateTime, Utc};
3use pyo3::prelude::*;
4use serde::{Deserialize, Serialize};
5use std::collections::BTreeMap;
6
7#[pyclass]
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Alert {
10    #[pyo3(get)]
11    pub created_at: DateTime<Utc>,
12
13    #[pyo3(get)]
14    pub name: String,
15
16    #[pyo3(get)]
17    pub space: String,
18
19    #[pyo3(get)]
20    pub version: String,
21
22    #[pyo3(get)]
23    pub entity_name: String,
24
25    #[pyo3(get)]
26    pub alert: BTreeMap<String, String>,
27
28    #[pyo3(get)]
29    pub id: i32,
30
31    #[pyo3(get)]
32    pub drift_type: String,
33
34    #[pyo3(get)]
35    pub active: bool,
36}
37
38#[pymethods]
39impl Alert {
40    pub fn __str__(&self) -> String {
41        // serialize the struct to a string
42        PyHelperFuncs::__str__(self)
43    }
44}
45
46#[derive(Serialize, Deserialize, Debug, Clone)]
47pub struct Alerts {
48    pub alerts: Vec<Alert>,
49}