Skip to main content

netbox_openapi/models/
writable_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/// WritableEventRuleRequest : Adds an `owner` field for models which have a ForeignKey to users.Owner.
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct WritableEventRuleRequest {
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", skip_serializing_if = "Option::is_none")]
34    pub action_type: Option<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 WritableEventRuleRequest {
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_object_type: String,
66    ) -> WritableEventRuleRequest {
67        WritableEventRuleRequest {
68            object_types,
69            name,
70            enabled: None,
71            event_types,
72            conditions: None,
73            action_type: None,
74            action_object_type,
75            action_object_id: None,
76            description: None,
77            custom_fields: None,
78            owner: None,
79            tags: None,
80        }
81    }
82}
83
84/// The types of event which will trigger this rule.
85#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
86pub enum EventTypes {
87    #[serde(rename = "object_created")]
88    ObjectCreated,
89    #[serde(rename = "object_updated")]
90    ObjectUpdated,
91    #[serde(rename = "object_deleted")]
92    ObjectDeleted,
93    #[serde(rename = "job_started")]
94    JobStarted,
95    #[serde(rename = "job_completed")]
96    JobCompleted,
97    #[serde(rename = "job_failed")]
98    JobFailed,
99    #[serde(rename = "job_errored")]
100    JobErrored,
101}
102
103impl Default for EventTypes {
104    fn default() -> EventTypes {
105        Self::ObjectCreated
106    }
107}
108/// * `webhook` - Webhook * `script` - Script * `notification` - Notification
109#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
110pub enum ActionType {
111    #[serde(rename = "webhook")]
112    Webhook,
113    #[serde(rename = "script")]
114    Script,
115    #[serde(rename = "notification")]
116    Notification,
117}
118
119impl Default for ActionType {
120    fn default() -> ActionType {
121        Self::Webhook
122    }
123}