nomad_client_rs/models/
event.rs1use serde::{Deserialize, Serialize};
2
3use crate::models::allocation::Allocation;
4use crate::models::deployment::Deployment;
5use crate::models::evaluation::Evaluation;
6use crate::models::job::Job;
7use crate::models::node::Node;
8use crate::models::service::Service;
9
10#[derive(Clone, Debug, Default, Deserialize, Serialize)]
11#[serde(rename_all = "PascalCase")]
12pub struct EventCollection {
13 #[serde(rename = "Index")]
14 pub index: i32,
15 #[serde(rename = "Events")]
16 pub events: Vec<Event>,
17}
18
19#[derive(Clone, Debug, Default, Deserialize, Serialize)]
20#[serde(rename_all = "PascalCase")]
21pub struct Event {
22 #[serde(rename = "Index")]
23 pub index: i32,
24 #[serde(rename = "Key")]
25 pub key: String,
26 #[serde(rename = "Namespace")]
27 pub namespace: String,
28 #[serde(rename = "Topic", skip_serializing_if = "Option::is_none")]
29 pub topic: Option<EventTopic>,
30 #[serde(rename = "Type", skip_serializing_if = "Option::is_none")]
31 pub _type: Option<EventType>,
32 #[serde(rename = "Payload", skip_serializing_if = "Option::is_none")]
33 pub payload: Option<EventPayload>,
34}
35
36#[derive(Clone, Debug, Deserialize, Serialize)]
37pub enum EventPayload {
38 Allocation(Box<Allocation>),
39 Deployment(Box<Deployment>),
40 Evaluation(Box<Evaluation>),
41 Job(Box<Job>),
42 Node(Box<Node>),
43 Service(Box<Service>),
44}
45
46#[derive(Clone, Debug, Deserialize, Serialize)]
47pub enum EventTopic {
48 ACLToken,
49 ACLPolicy,
50 ACLRole,
51 Job,
52 Allocation,
53 Deployment,
54 Evaluation,
55 Node,
56 Service,
57}
58
59#[derive(Clone, Debug, Deserialize, Serialize)]
60pub enum EventType {
61 ACLTokenUpserted,
62 ACLTokenDeleted,
63 ACLPolicyUpserted,
64 ACLPolicyDeleted,
65 ACLRoleUpserted,
66 ACLRoleDeleted,
67 AllocationCreated,
68 AllocationUpdated,
69 AllocationUpdateDesiredStatus,
70 DeploymentStatusUpdate,
71 DeploymentPromotion,
72 DeploymentAllocHealth,
73 EvaluationUpdated,
74 JobRegistered,
75 JobDeregistered,
76 JobBatchDeregistered,
77 NodeRegistration,
78 NodeDeregistration,
79 NodeEligibility,
80 NodeStreamEvent,
81 NodeDrain,
82 NodeEvent,
83 PlanResult,
84 ServiceRegistration,
85 ServiceDeregistration,
86}