nomad_client_rs/models/
event.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use serde::{Deserialize, Serialize};

use crate::models::allocation::Allocation;
use crate::models::deployment::Deployment;
use crate::models::evaluation::Evaluation;
use crate::models::job::Job;
use crate::models::node::Node;
use crate::models::service::Service;

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct EventCollection {
    #[serde(rename = "Index")]
    pub index: i32,
    #[serde(rename = "Events")]
    pub events: Vec<Event>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct Event {
    #[serde(rename = "Index")]
    pub index: i32,
    #[serde(rename = "Key")]
    pub key: String,
    #[serde(rename = "Namespace")]
    pub namespace: String,
    #[serde(rename = "Topic", skip_serializing_if = "Option::is_none")]
    pub topic: Option<EventTopic>,
    #[serde(rename = "Type", skip_serializing_if = "Option::is_none")]
    pub _type: Option<EventType>,
    #[serde(rename = "Payload", skip_serializing_if = "Option::is_none")]
    pub payload: Option<EventPayload>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum EventPayload {
    Allocation(Box<Allocation>),
    Deployment(Box<Deployment>),
    Evaluation(Box<Evaluation>),
    Job(Box<Job>),
    Node(Box<Node>),
    Service(Box<Service>),
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum EventTopic {
    ACLToken,
    ACLPolicy,
    ACLRole,
    Job,
    Allocation,
    Deployment,
    Evaluation,
    Node,
    Service,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum EventType {
    ACLTokenUpserted,
    ACLTokenDeleted,
    ACLPolicyUpserted,
    ACLPolicyDeleted,
    ACLRoleUpserted,
    ACLRoleDeleted,
    AllocationCreated,
    AllocationUpdated,
    AllocationUpdateDesiredStatus,
    DeploymentStatusUpdate,
    DeploymentPromotion,
    DeploymentAllocHealth,
    EvaluationUpdated,
    JobRegistered,
    JobDeregistered,
    JobBatchDeregistered,
    NodeRegistration,
    NodeDeregistration,
    NodeEligibility,
    NodeStreamEvent,
    NodeDrain,
    NodeEvent,
    PlanResult,
    ServiceRegistration,
    ServiceDeregistration,
}