Skip to main content

netbox_openapi/models/
extras_event_rules_create_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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
12pub struct ExtrasEventRulesCreateRequest {
13    #[serde(rename = "object_types")]
14    pub object_types: Vec<String>,
15    #[serde(rename = "name")]
16    pub name: String,
17    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
18    pub enabled: Option<bool>,
19    /// The types of event which will trigger this rule.
20    #[serde(rename = "event_types")]
21    pub event_types: Vec<EventTypes>,
22    /// A set of conditions which determine whether the event will be generated.
23    #[serde(
24        rename = "conditions",
25        default,
26        with = "::serde_with::rust::double_option",
27        skip_serializing_if = "Option::is_none"
28    )]
29    pub conditions: Option<Option<serde_json::Value>>,
30    /// * `webhook` - Webhook * `script` - Script * `notification` - Notification
31    #[serde(rename = "action_type", skip_serializing_if = "Option::is_none")]
32    pub action_type: Option<ActionType>,
33    #[serde(rename = "action_object_type")]
34    pub action_object_type: String,
35    #[serde(
36        rename = "action_object_id",
37        default,
38        with = "::serde_with::rust::double_option",
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub action_object_id: Option<Option<i64>>,
42    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
43    pub description: Option<String>,
44    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
45    pub custom_fields: Option<::std::collections::HashMap<String, serde_json::Value>>,
46    #[serde(
47        rename = "owner",
48        default,
49        with = "::serde_with::rust::double_option",
50        skip_serializing_if = "Option::is_none"
51    )]
52    pub owner: Option<Option<Box<crate::models::AsnRangeRequestOwner>>>,
53    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
54    pub tags: Option<Vec<crate::models::NestedTagRequest>>,
55}
56
57impl ExtrasEventRulesCreateRequest {
58    pub fn new(
59        object_types: Vec<String>,
60        name: String,
61        event_types: Vec<EventTypes>,
62        action_object_type: String,
63    ) -> ExtrasEventRulesCreateRequest {
64        ExtrasEventRulesCreateRequest {
65            object_types,
66            name,
67            enabled: None,
68            event_types,
69            conditions: None,
70            action_type: None,
71            action_object_type,
72            action_object_id: None,
73            description: None,
74            custom_fields: None,
75            owner: None,
76            tags: None,
77        }
78    }
79}
80
81/// The types of event which will trigger this rule.
82#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
83pub enum EventTypes {
84    #[serde(rename = "object_created")]
85    ObjectCreated,
86    #[serde(rename = "object_updated")]
87    ObjectUpdated,
88    #[serde(rename = "object_deleted")]
89    ObjectDeleted,
90    #[serde(rename = "job_started")]
91    JobStarted,
92    #[serde(rename = "job_completed")]
93    JobCompleted,
94    #[serde(rename = "job_failed")]
95    JobFailed,
96    #[serde(rename = "job_errored")]
97    JobErrored,
98}
99
100impl Default for EventTypes {
101    fn default() -> EventTypes {
102        Self::ObjectCreated
103    }
104}
105/// * `webhook` - Webhook * `script` - Script * `notification` - Notification
106#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
107pub enum ActionType {
108    #[serde(rename = "webhook")]
109    Webhook,
110    #[serde(rename = "script")]
111    Script,
112    #[serde(rename = "notification")]
113    Notification,
114}
115
116impl Default for ActionType {
117    fn default() -> ActionType {
118        Self::Webhook
119    }
120}