unifly_api/model/
event.rs1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6use super::common::DataSource;
7use super::entity_id::{EntityId, MacAddress};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10#[non_exhaustive]
11pub enum EventCategory {
12 Device,
13 Client,
14 Network,
15 System,
16 Admin,
17 Firewall,
18 Vpn,
19 Unknown,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
23#[non_exhaustive]
24pub enum EventSeverity {
25 Info,
26 Warning,
27 Error,
28 Critical,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct Event {
34 pub id: Option<EntityId>,
35 pub timestamp: DateTime<Utc>,
36 pub category: EventCategory,
37 pub severity: EventSeverity,
38 pub event_type: String,
39 pub message: String,
40
41 pub device_mac: Option<MacAddress>,
43 pub client_mac: Option<MacAddress>,
44 pub site_id: Option<EntityId>,
45
46 pub raw_key: Option<String>,
48
49 #[serde(skip)]
50 #[allow(dead_code)]
51 pub(crate) source: DataSource,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct Alarm {
57 pub id: EntityId,
58 pub timestamp: DateTime<Utc>,
59 pub category: EventCategory,
60 pub severity: EventSeverity,
61 pub message: String,
62 pub archived: bool,
63
64 pub device_mac: Option<MacAddress>,
65 pub site_id: Option<EntityId>,
66}