Skip to main content

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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// EventRuleRequest : Adds an `owner` field for models which have a ForeignKey to users.Owner.
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(
49        rename = "owner",
50        default,
51        with = "::serde_with::rust::double_option",
52        skip_serializing_if = "Option::is_none"
53    )]
54    pub owner: Option<Option<Box<crate::models::AsnRangeRequestOwner>>>,
55    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
56    pub tags: Option<Vec<crate::models::NestedTagRequest>>,
57}
58
59impl EventRuleRequest {
60    /// Adds an `owner` field for models which have a ForeignKey to users.Owner.
61    pub fn new(
62        object_types: Vec<String>,
63        name: String,
64        event_types: Vec<EventTypes>,
65        action_type: ActionType,
66        action_object_type: String,
67    ) -> EventRuleRequest {
68        EventRuleRequest {
69            object_types,
70            name,
71            enabled: None,
72            event_types,
73            conditions: None,
74            action_type,
75            action_object_type,
76            action_object_id: None,
77            description: None,
78            custom_fields: None,
79            owner: None,
80            tags: None,
81        }
82    }
83}
84
85/// The types of event which will trigger this rule.
86#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
87pub enum EventTypes {
88    #[serde(rename = "object_created")]
89    ObjectCreated,
90    #[serde(rename = "object_updated")]
91    ObjectUpdated,
92    #[serde(rename = "object_deleted")]
93    ObjectDeleted,
94    #[serde(rename = "job_started")]
95    JobStarted,
96    #[serde(rename = "job_completed")]
97    JobCompleted,
98    #[serde(rename = "job_failed")]
99    JobFailed,
100    #[serde(rename = "job_errored")]
101    JobErrored,
102}
103
104impl Default for EventTypes {
105    fn default() -> EventTypes {
106        Self::ObjectCreated
107    }
108}
109/// * `webhook` - Webhook * `script` - Script * `notification` - Notification
110#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
111pub enum ActionType {
112    #[serde(rename = "webhook")]
113    Webhook,
114    #[serde(rename = "script")]
115    Script,
116    #[serde(rename = "notification")]
117    Notification,
118}
119
120impl Default for ActionType {
121    fn default() -> ActionType {
122        Self::Webhook
123    }
124}