datadog_api_client/datadogV2/model/
model_security_monitoring_suppression_attributes.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9/// The attributes of the suppression rule.
10#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct SecurityMonitoringSuppressionAttributes {
14    /// A Unix millisecond timestamp given the creation date of the suppression rule.
15    #[serde(rename = "creation_date")]
16    pub creation_date: Option<i64>,
17    /// A user.
18    #[serde(rename = "creator")]
19    pub creator: Option<crate::datadogV2::model::SecurityMonitoringUser>,
20    /// An exclusion query on the input data of the security rules, which could be logs, Agent events, or other types of data based on the security rule. Events matching this query are ignored by any detection rules referenced in the suppression rule.
21    #[serde(rename = "data_exclusion_query")]
22    pub data_exclusion_query: Option<String>,
23    /// A description for the suppression rule.
24    #[serde(rename = "description")]
25    pub description: Option<String>,
26    /// Whether the suppression rule is editable.
27    #[serde(rename = "editable")]
28    pub editable: Option<bool>,
29    /// Whether the suppression rule is enabled.
30    #[serde(rename = "enabled")]
31    pub enabled: Option<bool>,
32    /// A Unix millisecond timestamp giving an expiration date for the suppression rule. After this date, it won't suppress signals anymore.
33    #[serde(rename = "expiration_date")]
34    pub expiration_date: Option<i64>,
35    /// The name of the suppression rule.
36    #[serde(rename = "name")]
37    pub name: Option<String>,
38    /// The rule query of the suppression rule, with the same syntax as the search bar for detection rules.
39    #[serde(rename = "rule_query")]
40    pub rule_query: Option<String>,
41    /// A Unix millisecond timestamp giving the start date for the suppression rule. After this date, it starts suppressing signals.
42    #[serde(rename = "start_date")]
43    pub start_date: Option<i64>,
44    /// The suppression query of the suppression rule. If a signal matches this query, it is suppressed and not triggered. Same syntax as the queries to search signals in the signal explorer.
45    #[serde(rename = "suppression_query")]
46    pub suppression_query: Option<String>,
47    /// A Unix millisecond timestamp given the update date of the suppression rule.
48    #[serde(rename = "update_date")]
49    pub update_date: Option<i64>,
50    /// A user.
51    #[serde(rename = "updater")]
52    pub updater: Option<crate::datadogV2::model::SecurityMonitoringUser>,
53    /// The version of the suppression rule; it starts at 1, and is incremented at each update.
54    #[serde(rename = "version")]
55    pub version: Option<i32>,
56    #[serde(flatten)]
57    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
58    #[serde(skip)]
59    #[serde(default)]
60    pub(crate) _unparsed: bool,
61}
62
63impl SecurityMonitoringSuppressionAttributes {
64    pub fn new() -> SecurityMonitoringSuppressionAttributes {
65        SecurityMonitoringSuppressionAttributes {
66            creation_date: None,
67            creator: None,
68            data_exclusion_query: None,
69            description: None,
70            editable: None,
71            enabled: None,
72            expiration_date: None,
73            name: None,
74            rule_query: None,
75            start_date: None,
76            suppression_query: None,
77            update_date: None,
78            updater: None,
79            version: None,
80            additional_properties: std::collections::BTreeMap::new(),
81            _unparsed: false,
82        }
83    }
84
85    pub fn creation_date(mut self, value: i64) -> Self {
86        self.creation_date = Some(value);
87        self
88    }
89
90    pub fn creator(mut self, value: crate::datadogV2::model::SecurityMonitoringUser) -> Self {
91        self.creator = Some(value);
92        self
93    }
94
95    pub fn data_exclusion_query(mut self, value: String) -> Self {
96        self.data_exclusion_query = Some(value);
97        self
98    }
99
100    pub fn description(mut self, value: String) -> Self {
101        self.description = Some(value);
102        self
103    }
104
105    pub fn editable(mut self, value: bool) -> Self {
106        self.editable = Some(value);
107        self
108    }
109
110    pub fn enabled(mut self, value: bool) -> Self {
111        self.enabled = Some(value);
112        self
113    }
114
115    pub fn expiration_date(mut self, value: i64) -> Self {
116        self.expiration_date = Some(value);
117        self
118    }
119
120    pub fn name(mut self, value: String) -> Self {
121        self.name = Some(value);
122        self
123    }
124
125    pub fn rule_query(mut self, value: String) -> Self {
126        self.rule_query = Some(value);
127        self
128    }
129
130    pub fn start_date(mut self, value: i64) -> Self {
131        self.start_date = Some(value);
132        self
133    }
134
135    pub fn suppression_query(mut self, value: String) -> Self {
136        self.suppression_query = Some(value);
137        self
138    }
139
140    pub fn update_date(mut self, value: i64) -> Self {
141        self.update_date = Some(value);
142        self
143    }
144
145    pub fn updater(mut self, value: crate::datadogV2::model::SecurityMonitoringUser) -> Self {
146        self.updater = Some(value);
147        self
148    }
149
150    pub fn version(mut self, value: i32) -> Self {
151        self.version = Some(value);
152        self
153    }
154
155    pub fn additional_properties(
156        mut self,
157        value: std::collections::BTreeMap<String, serde_json::Value>,
158    ) -> Self {
159        self.additional_properties = value;
160        self
161    }
162}
163
164impl Default for SecurityMonitoringSuppressionAttributes {
165    fn default() -> Self {
166        Self::new()
167    }
168}
169
170impl<'de> Deserialize<'de> for SecurityMonitoringSuppressionAttributes {
171    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
172    where
173        D: Deserializer<'de>,
174    {
175        struct SecurityMonitoringSuppressionAttributesVisitor;
176        impl<'a> Visitor<'a> for SecurityMonitoringSuppressionAttributesVisitor {
177            type Value = SecurityMonitoringSuppressionAttributes;
178
179            fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
180                f.write_str("a mapping")
181            }
182
183            fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
184            where
185                M: MapAccess<'a>,
186            {
187                let mut creation_date: Option<i64> = None;
188                let mut creator: Option<crate::datadogV2::model::SecurityMonitoringUser> = None;
189                let mut data_exclusion_query: Option<String> = None;
190                let mut description: Option<String> = None;
191                let mut editable: Option<bool> = None;
192                let mut enabled: Option<bool> = None;
193                let mut expiration_date: Option<i64> = None;
194                let mut name: Option<String> = None;
195                let mut rule_query: Option<String> = None;
196                let mut start_date: Option<i64> = None;
197                let mut suppression_query: Option<String> = None;
198                let mut update_date: Option<i64> = None;
199                let mut updater: Option<crate::datadogV2::model::SecurityMonitoringUser> = None;
200                let mut version: Option<i32> = None;
201                let mut additional_properties: std::collections::BTreeMap<
202                    String,
203                    serde_json::Value,
204                > = std::collections::BTreeMap::new();
205                let mut _unparsed = false;
206
207                while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
208                    match k.as_str() {
209                        "creation_date" => {
210                            if v.is_null() {
211                                continue;
212                            }
213                            creation_date =
214                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
215                        }
216                        "creator" => {
217                            if v.is_null() {
218                                continue;
219                            }
220                            creator = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
221                        }
222                        "data_exclusion_query" => {
223                            if v.is_null() {
224                                continue;
225                            }
226                            data_exclusion_query =
227                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
228                        }
229                        "description" => {
230                            if v.is_null() {
231                                continue;
232                            }
233                            description =
234                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
235                        }
236                        "editable" => {
237                            if v.is_null() {
238                                continue;
239                            }
240                            editable = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
241                        }
242                        "enabled" => {
243                            if v.is_null() {
244                                continue;
245                            }
246                            enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
247                        }
248                        "expiration_date" => {
249                            if v.is_null() {
250                                continue;
251                            }
252                            expiration_date =
253                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
254                        }
255                        "name" => {
256                            if v.is_null() {
257                                continue;
258                            }
259                            name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
260                        }
261                        "rule_query" => {
262                            if v.is_null() {
263                                continue;
264                            }
265                            rule_query = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
266                        }
267                        "start_date" => {
268                            if v.is_null() {
269                                continue;
270                            }
271                            start_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
272                        }
273                        "suppression_query" => {
274                            if v.is_null() {
275                                continue;
276                            }
277                            suppression_query =
278                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
279                        }
280                        "update_date" => {
281                            if v.is_null() {
282                                continue;
283                            }
284                            update_date =
285                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
286                        }
287                        "updater" => {
288                            if v.is_null() {
289                                continue;
290                            }
291                            updater = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
292                        }
293                        "version" => {
294                            if v.is_null() {
295                                continue;
296                            }
297                            version = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
298                        }
299                        &_ => {
300                            if let Ok(value) = serde_json::from_value(v.clone()) {
301                                additional_properties.insert(k, value);
302                            }
303                        }
304                    }
305                }
306
307                let content = SecurityMonitoringSuppressionAttributes {
308                    creation_date,
309                    creator,
310                    data_exclusion_query,
311                    description,
312                    editable,
313                    enabled,
314                    expiration_date,
315                    name,
316                    rule_query,
317                    start_date,
318                    suppression_query,
319                    update_date,
320                    updater,
321                    version,
322                    additional_properties,
323                    _unparsed,
324                };
325
326                Ok(content)
327            }
328        }
329
330        deserializer.deserialize_any(SecurityMonitoringSuppressionAttributesVisitor)
331    }
332}