netbox_openapi/models/
event_rule_request.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/// EventRuleRequest : Adds support for custom fields and tags.
12
13#[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    /// The types of event which will trigger this rule.
22    #[serde(rename = "event_types")]
23    pub event_types: Vec<EventTypes>,
24    /// A set of conditions which determine whether the event will be generated.
25    #[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    /// * `webhook` - Webhook * `script` - Script * `notification` - Notification
33    #[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    /// Adds support for custom fields and tags.
54    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/// The types of event which will trigger this rule.
78#[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    #[serde(rename = "branch_provisioned")]
95    BranchProvisioned,
96    #[serde(rename = "branch_deprovisioned")]
97    BranchDeprovisioned,
98    #[serde(rename = "branch_synced")]
99    BranchSynced,
100    #[serde(rename = "branch_merged")]
101    BranchMerged,
102    #[serde(rename = "branch_reverted")]
103    BranchReverted,
104}
105
106impl Default for EventTypes {
107    fn default() -> EventTypes {
108        Self::ObjectCreated
109    }
110}
111/// * `webhook` - Webhook * `script` - Script * `notification` - Notification
112#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
113pub enum ActionType {
114    #[serde(rename = "webhook")]
115    Webhook,
116    #[serde(rename = "script")]
117    Script,
118    #[serde(rename = "notification")]
119    Notification,
120}
121
122impl Default for ActionType {
123    fn default() -> ActionType {
124        Self::Webhook
125    }
126}