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.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// WritableEventRuleRequest : Adds support for custom fields and tags.
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(rename = "tags", skip_serializing_if = "Option::is_none")]
49    pub tags: Option<Vec<crate::models::NestedTagRequest>>,
50}
51
52impl WritableEventRuleRequest {
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_object_type: String,
59    ) -> WritableEventRuleRequest {
60        WritableEventRuleRequest {
61            object_types,
62            name,
63            enabled: None,
64            event_types,
65            conditions: None,
66            action_type: None,
67            action_object_type,
68            action_object_id: None,
69            description: None,
70            custom_fields: None,
71            tags: None,
72        }
73    }
74}
75
76/// The types of event which will trigger this rule.
77#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
78pub enum EventTypes {
79    #[serde(rename = "object_created")]
80    ObjectCreated,
81    #[serde(rename = "object_updated")]
82    ObjectUpdated,
83    #[serde(rename = "object_deleted")]
84    ObjectDeleted,
85    #[serde(rename = "job_started")]
86    JobStarted,
87    #[serde(rename = "job_completed")]
88    JobCompleted,
89    #[serde(rename = "job_failed")]
90    JobFailed,
91    #[serde(rename = "job_errored")]
92    JobErrored,
93    #[serde(rename = "branch_provisioned")]
94    BranchProvisioned,
95    #[serde(rename = "branch_deprovisioned")]
96    BranchDeprovisioned,
97    #[serde(rename = "branch_synced")]
98    BranchSynced,
99    #[serde(rename = "branch_merged")]
100    BranchMerged,
101    #[serde(rename = "branch_reverted")]
102    BranchReverted,
103}
104
105impl Default for EventTypes {
106    fn default() -> EventTypes {
107        Self::ObjectCreated
108    }
109}
110/// * `webhook` - Webhook * `script` - Script * `notification` - Notification
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum ActionType {
113    #[serde(rename = "webhook")]
114    Webhook,
115    #[serde(rename = "script")]
116    Script,
117    #[serde(rename = "notification")]
118    Notification,
119}
120
121impl Default for ActionType {
122    fn default() -> ActionType {
123        Self::Webhook
124    }
125}