datadog_api_client/datadogV2/model/
model_datastore_data_attributes.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 DatastoreDataAttributes {
14 #[serde(rename = "created_at")]
16 pub created_at: Option<chrono::DateTime<chrono::Utc>>,
17 #[serde(rename = "creator_user_id")]
19 pub creator_user_id: Option<i64>,
20 #[serde(rename = "creator_user_uuid")]
22 pub creator_user_uuid: Option<String>,
23 #[serde(rename = "description")]
25 pub description: Option<String>,
26 #[serde(rename = "modified_at")]
28 pub modified_at: Option<chrono::DateTime<chrono::Utc>>,
29 #[serde(rename = "name")]
31 pub name: Option<String>,
32 #[serde(rename = "org_id")]
34 pub org_id: Option<i64>,
35 #[serde(rename = "primary_column_name")]
39 pub primary_column_name: Option<String>,
40 #[serde(rename = "primary_key_generation_strategy")]
42 pub primary_key_generation_strategy:
43 Option<crate::datadogV2::model::DatastorePrimaryKeyGenerationStrategy>,
44 #[serde(flatten)]
45 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
46 #[serde(skip)]
47 #[serde(default)]
48 pub(crate) _unparsed: bool,
49}
50
51impl DatastoreDataAttributes {
52 pub fn new() -> DatastoreDataAttributes {
53 DatastoreDataAttributes {
54 created_at: None,
55 creator_user_id: None,
56 creator_user_uuid: None,
57 description: None,
58 modified_at: None,
59 name: None,
60 org_id: None,
61 primary_column_name: None,
62 primary_key_generation_strategy: None,
63 additional_properties: std::collections::BTreeMap::new(),
64 _unparsed: false,
65 }
66 }
67
68 pub fn created_at(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
69 self.created_at = Some(value);
70 self
71 }
72
73 pub fn creator_user_id(mut self, value: i64) -> Self {
74 self.creator_user_id = Some(value);
75 self
76 }
77
78 pub fn creator_user_uuid(mut self, value: String) -> Self {
79 self.creator_user_uuid = Some(value);
80 self
81 }
82
83 pub fn description(mut self, value: String) -> Self {
84 self.description = Some(value);
85 self
86 }
87
88 pub fn modified_at(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
89 self.modified_at = Some(value);
90 self
91 }
92
93 pub fn name(mut self, value: String) -> Self {
94 self.name = Some(value);
95 self
96 }
97
98 pub fn org_id(mut self, value: i64) -> Self {
99 self.org_id = Some(value);
100 self
101 }
102
103 pub fn primary_column_name(mut self, value: String) -> Self {
104 self.primary_column_name = Some(value);
105 self
106 }
107
108 pub fn primary_key_generation_strategy(
109 mut self,
110 value: crate::datadogV2::model::DatastorePrimaryKeyGenerationStrategy,
111 ) -> Self {
112 self.primary_key_generation_strategy = Some(value);
113 self
114 }
115
116 pub fn additional_properties(
117 mut self,
118 value: std::collections::BTreeMap<String, serde_json::Value>,
119 ) -> Self {
120 self.additional_properties = value;
121 self
122 }
123}
124
125impl Default for DatastoreDataAttributes {
126 fn default() -> Self {
127 Self::new()
128 }
129}
130
131impl<'de> Deserialize<'de> for DatastoreDataAttributes {
132 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
133 where
134 D: Deserializer<'de>,
135 {
136 struct DatastoreDataAttributesVisitor;
137 impl<'a> Visitor<'a> for DatastoreDataAttributesVisitor {
138 type Value = DatastoreDataAttributes;
139
140 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
141 f.write_str("a mapping")
142 }
143
144 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
145 where
146 M: MapAccess<'a>,
147 {
148 let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
149 let mut creator_user_id: Option<i64> = None;
150 let mut creator_user_uuid: Option<String> = None;
151 let mut description: Option<String> = None;
152 let mut modified_at: Option<chrono::DateTime<chrono::Utc>> = None;
153 let mut name: Option<String> = None;
154 let mut org_id: Option<i64> = None;
155 let mut primary_column_name: Option<String> = None;
156 let mut primary_key_generation_strategy: Option<
157 crate::datadogV2::model::DatastorePrimaryKeyGenerationStrategy,
158 > = None;
159 let mut additional_properties: std::collections::BTreeMap<
160 String,
161 serde_json::Value,
162 > = std::collections::BTreeMap::new();
163 let mut _unparsed = false;
164
165 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
166 match k.as_str() {
167 "created_at" => {
168 if v.is_null() {
169 continue;
170 }
171 created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
172 }
173 "creator_user_id" => {
174 if v.is_null() {
175 continue;
176 }
177 creator_user_id =
178 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
179 }
180 "creator_user_uuid" => {
181 if v.is_null() {
182 continue;
183 }
184 creator_user_uuid =
185 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
186 }
187 "description" => {
188 if v.is_null() {
189 continue;
190 }
191 description =
192 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
193 }
194 "modified_at" => {
195 if v.is_null() {
196 continue;
197 }
198 modified_at =
199 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
200 }
201 "name" => {
202 if v.is_null() {
203 continue;
204 }
205 name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
206 }
207 "org_id" => {
208 if v.is_null() {
209 continue;
210 }
211 org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
212 }
213 "primary_column_name" => {
214 if v.is_null() {
215 continue;
216 }
217 primary_column_name =
218 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
219 }
220 "primary_key_generation_strategy" => {
221 if v.is_null() {
222 continue;
223 }
224 primary_key_generation_strategy =
225 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
226 if let Some(ref _primary_key_generation_strategy) =
227 primary_key_generation_strategy
228 {
229 match _primary_key_generation_strategy {
230 crate::datadogV2::model::DatastorePrimaryKeyGenerationStrategy::UnparsedObject(_primary_key_generation_strategy) => {
231 _unparsed = true;
232 },
233 _ => {}
234 }
235 }
236 }
237 &_ => {
238 if let Ok(value) = serde_json::from_value(v.clone()) {
239 additional_properties.insert(k, value);
240 }
241 }
242 }
243 }
244
245 let content = DatastoreDataAttributes {
246 created_at,
247 creator_user_id,
248 creator_user_uuid,
249 description,
250 modified_at,
251 name,
252 org_id,
253 primary_column_name,
254 primary_key_generation_strategy,
255 additional_properties,
256 _unparsed,
257 };
258
259 Ok(content)
260 }
261 }
262
263 deserializer.deserialize_any(DatastoreDataAttributesVisitor)
264 }
265}