netbox_openapi/models/
event_rule_request.rs1#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct EventRuleRequest {
15 #[serde(rename = "object_types")]
16 pub object_types: Vec<String>,
17 #[serde(rename = "name")]
18 pub name: String,
19 #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
20 pub enabled: Option<bool>,
21 #[serde(rename = "event_types")]
23 pub event_types: Vec<EventTypes>,
24 #[serde(
26 rename = "conditions",
27 default,
28 with = "::serde_with::rust::double_option",
29 skip_serializing_if = "Option::is_none"
30 )]
31 pub conditions: Option<Option<serde_json::Value>>,
32 #[serde(rename = "action_type")]
34 pub action_type: ActionType,
35 #[serde(rename = "action_object_type")]
36 pub action_object_type: String,
37 #[serde(
38 rename = "action_object_id",
39 default,
40 with = "::serde_with::rust::double_option",
41 skip_serializing_if = "Option::is_none"
42 )]
43 pub action_object_id: Option<Option<i64>>,
44 #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
45 pub description: Option<String>,
46 #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
47 pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
48 #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
49 pub tags: Option<Vec<crate::models::NestedTagRequest>>,
50}
51
52impl EventRuleRequest {
53 pub fn new(
55 object_types: Vec<String>,
56 name: String,
57 event_types: Vec<EventTypes>,
58 action_type: ActionType,
59 action_object_type: String,
60 ) -> EventRuleRequest {
61 EventRuleRequest {
62 object_types,
63 name,
64 enabled: None,
65 event_types,
66 conditions: None,
67 action_type,
68 action_object_type,
69 action_object_id: None,
70 description: None,
71 custom_fields: None,
72 tags: None,
73 }
74 }
75}
76
77#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
79pub enum EventTypes {
80 #[serde(rename = "object_created")]
81 ObjectCreated,
82 #[serde(rename = "object_updated")]
83 ObjectUpdated,
84 #[serde(rename = "object_deleted")]
85 ObjectDeleted,
86 #[serde(rename = "job_started")]
87 JobStarted,
88 #[serde(rename = "job_completed")]
89 JobCompleted,
90 #[serde(rename = "job_failed")]
91 JobFailed,
92 #[serde(rename = "job_errored")]
93 JobErrored,
94}
95
96impl Default for EventTypes {
97 fn default() -> EventTypes {
98 Self::ObjectCreated
99 }
100}
101#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
103pub enum ActionType {
104 #[serde(rename = "webhook")]
105 Webhook,
106 #[serde(rename = "script")]
107 Script,
108 #[serde(rename = "notification")]
109 Notification,
110}
111
112impl Default for ActionType {
113 fn default() -> ActionType {
114 Self::Webhook
115 }
116}