Skip to main content

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