netbox_openapi/models/
event_rule.rs

1/*
2 * NetBox REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 4.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// EventRule : Adds support for custom fields and tags.
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct EventRule {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<i32>,
17    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
18    pub url: Option<String>,
19    #[serde(rename = "display_url", skip_serializing_if = "Option::is_none")]
20    pub display_url: Option<String>,
21    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
22    pub display: Option<String>,
23    #[serde(rename = "object_types")]
24    pub object_types: Vec<String>,
25    #[serde(rename = "name")]
26    pub name: String,
27    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
28    pub enabled: Option<bool>,
29    /// The types of event which will trigger this rule.
30    #[serde(rename = "event_types")]
31    pub event_types: Vec<EventTypes>,
32    /// A set of conditions which determine whether the event will be generated.
33    #[serde(
34        rename = "conditions",
35        default,
36        with = "::serde_with::rust::double_option",
37        skip_serializing_if = "Option::is_none"
38    )]
39    pub conditions: Option<Option<serde_json::Value>>,
40    #[serde(rename = "action_type")]
41    pub action_type: Box<crate::models::EventRuleActionType>,
42    #[serde(rename = "action_object_type")]
43    pub action_object_type: String,
44    #[serde(
45        rename = "action_object_id",
46        default,
47        with = "::serde_with::rust::double_option",
48        skip_serializing_if = "Option::is_none"
49    )]
50    pub action_object_id: Option<Option<i64>>,
51    #[serde(rename = "action_object", skip_serializing_if = "Option::is_none")]
52    pub action_object: Option<::std::collections::HashMap<String, serde_json::Value>>,
53    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
54    pub description: Option<String>,
55    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
56    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
57    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
58    pub tags: Option<Vec<crate::models::NestedTag>>,
59    #[serde(
60        rename = "created",
61        default,
62        with = "::serde_with::rust::double_option",
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub created: Option<Option<String>>,
66    #[serde(
67        rename = "last_updated",
68        default,
69        with = "::serde_with::rust::double_option",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub last_updated: Option<Option<String>>,
73}
74
75impl EventRule {
76    /// Adds support for custom fields and tags.
77    pub fn new(
78        object_types: Vec<String>,
79        name: String,
80        event_types: Vec<EventTypes>,
81        action_type: crate::models::EventRuleActionType,
82        action_object_type: String,
83    ) -> EventRule {
84        EventRule {
85            id: None,
86            url: None,
87            display_url: None,
88            display: None,
89            object_types,
90            name,
91            enabled: None,
92            event_types,
93            conditions: None,
94            action_type: Box::new(action_type),
95            action_object_type,
96            action_object_id: None,
97            action_object: None,
98            description: None,
99            custom_fields: None,
100            tags: None,
101            created: None,
102            last_updated: None,
103        }
104    }
105}
106
107/// The types of event which will trigger this rule.
108#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
109pub enum EventTypes {
110    #[serde(rename = "object_created")]
111    ObjectCreated,
112    #[serde(rename = "object_updated")]
113    ObjectUpdated,
114    #[serde(rename = "object_deleted")]
115    ObjectDeleted,
116    #[serde(rename = "job_started")]
117    JobStarted,
118    #[serde(rename = "job_completed")]
119    JobCompleted,
120    #[serde(rename = "job_failed")]
121    JobFailed,
122    #[serde(rename = "job_errored")]
123    JobErrored,
124    #[serde(rename = "branch_provisioned")]
125    BranchProvisioned,
126    #[serde(rename = "branch_deprovisioned")]
127    BranchDeprovisioned,
128    #[serde(rename = "branch_synced")]
129    BranchSynced,
130    #[serde(rename = "branch_merged")]
131    BranchMerged,
132    #[serde(rename = "branch_reverted")]
133    BranchReverted,
134}
135
136impl Default for EventTypes {
137    fn default() -> EventTypes {
138        Self::ObjectCreated
139    }
140}