datadog_api_client/datadogV2/model/
model_security_monitoring_reference_table.rs1use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct SecurityMonitoringReferenceTable {
14 #[serde(rename = "checkPresence")]
16 pub check_presence: Option<bool>,
17 #[serde(rename = "columnName")]
19 pub column_name: Option<String>,
20 #[serde(rename = "logFieldPath")]
22 pub log_field_path: Option<String>,
23 #[serde(rename = "ruleQueryName")]
25 pub rule_query_name: Option<String>,
26 #[serde(rename = "tableName")]
28 pub table_name: Option<String>,
29 #[serde(flatten)]
30 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
31 #[serde(skip)]
32 #[serde(default)]
33 pub(crate) _unparsed: bool,
34}
35
36impl SecurityMonitoringReferenceTable {
37 pub fn new() -> SecurityMonitoringReferenceTable {
38 SecurityMonitoringReferenceTable {
39 check_presence: None,
40 column_name: None,
41 log_field_path: None,
42 rule_query_name: None,
43 table_name: None,
44 additional_properties: std::collections::BTreeMap::new(),
45 _unparsed: false,
46 }
47 }
48
49 pub fn check_presence(mut self, value: bool) -> Self {
50 self.check_presence = Some(value);
51 self
52 }
53
54 pub fn column_name(mut self, value: String) -> Self {
55 self.column_name = Some(value);
56 self
57 }
58
59 pub fn log_field_path(mut self, value: String) -> Self {
60 self.log_field_path = Some(value);
61 self
62 }
63
64 pub fn rule_query_name(mut self, value: String) -> Self {
65 self.rule_query_name = Some(value);
66 self
67 }
68
69 pub fn table_name(mut self, value: String) -> Self {
70 self.table_name = Some(value);
71 self
72 }
73
74 pub fn additional_properties(
75 mut self,
76 value: std::collections::BTreeMap<String, serde_json::Value>,
77 ) -> Self {
78 self.additional_properties = value;
79 self
80 }
81}
82
83impl Default for SecurityMonitoringReferenceTable {
84 fn default() -> Self {
85 Self::new()
86 }
87}
88
89impl<'de> Deserialize<'de> for SecurityMonitoringReferenceTable {
90 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
91 where
92 D: Deserializer<'de>,
93 {
94 struct SecurityMonitoringReferenceTableVisitor;
95 impl<'a> Visitor<'a> for SecurityMonitoringReferenceTableVisitor {
96 type Value = SecurityMonitoringReferenceTable;
97
98 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
99 f.write_str("a mapping")
100 }
101
102 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
103 where
104 M: MapAccess<'a>,
105 {
106 let mut check_presence: Option<bool> = None;
107 let mut column_name: Option<String> = None;
108 let mut log_field_path: Option<String> = None;
109 let mut rule_query_name: Option<String> = None;
110 let mut table_name: Option<String> = None;
111 let mut additional_properties: std::collections::BTreeMap<
112 String,
113 serde_json::Value,
114 > = std::collections::BTreeMap::new();
115 let mut _unparsed = false;
116
117 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
118 match k.as_str() {
119 "checkPresence" => {
120 if v.is_null() {
121 continue;
122 }
123 check_presence =
124 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
125 }
126 "columnName" => {
127 if v.is_null() {
128 continue;
129 }
130 column_name =
131 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
132 }
133 "logFieldPath" => {
134 if v.is_null() {
135 continue;
136 }
137 log_field_path =
138 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
139 }
140 "ruleQueryName" => {
141 if v.is_null() {
142 continue;
143 }
144 rule_query_name =
145 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
146 }
147 "tableName" => {
148 if v.is_null() {
149 continue;
150 }
151 table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
152 }
153 &_ => {
154 if let Ok(value) = serde_json::from_value(v.clone()) {
155 additional_properties.insert(k, value);
156 }
157 }
158 }
159 }
160
161 let content = SecurityMonitoringReferenceTable {
162 check_presence,
163 column_name,
164 log_field_path,
165 rule_query_name,
166 table_name,
167 additional_properties,
168 _unparsed,
169 };
170
171 Ok(content)
172 }
173 }
174
175 deserializer.deserialize_any(SecurityMonitoringReferenceTableVisitor)
176 }
177}