datadog_api_client/datadogV2/model/
model_item_api_payload_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 ItemApiPayloadDataAttributes {
14 #[serde(rename = "created_at")]
16 pub created_at: Option<chrono::DateTime<chrono::Utc>>,
17 #[serde(rename = "modified_at")]
19 pub modified_at: Option<chrono::DateTime<chrono::Utc>>,
20 #[serde(rename = "org_id")]
22 pub org_id: Option<i64>,
23 #[serde(rename = "primary_column_name")]
27 pub primary_column_name: Option<String>,
28 #[serde(rename = "signature")]
30 pub signature: Option<String>,
31 #[serde(rename = "store_id")]
33 pub store_id: Option<String>,
34 #[serde(rename = "value")]
36 pub value: Option<std::collections::BTreeMap<String, serde_json::Value>>,
37 #[serde(flatten)]
38 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
39 #[serde(skip)]
40 #[serde(default)]
41 pub(crate) _unparsed: bool,
42}
43
44impl ItemApiPayloadDataAttributes {
45 pub fn new() -> ItemApiPayloadDataAttributes {
46 ItemApiPayloadDataAttributes {
47 created_at: None,
48 modified_at: None,
49 org_id: None,
50 primary_column_name: None,
51 signature: None,
52 store_id: None,
53 value: None,
54 additional_properties: std::collections::BTreeMap::new(),
55 _unparsed: false,
56 }
57 }
58
59 pub fn created_at(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
60 self.created_at = Some(value);
61 self
62 }
63
64 pub fn modified_at(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
65 self.modified_at = Some(value);
66 self
67 }
68
69 pub fn org_id(mut self, value: i64) -> Self {
70 self.org_id = Some(value);
71 self
72 }
73
74 pub fn primary_column_name(mut self, value: String) -> Self {
75 self.primary_column_name = Some(value);
76 self
77 }
78
79 pub fn signature(mut self, value: String) -> Self {
80 self.signature = Some(value);
81 self
82 }
83
84 pub fn store_id(mut self, value: String) -> Self {
85 self.store_id = Some(value);
86 self
87 }
88
89 pub fn value(mut self, value: std::collections::BTreeMap<String, serde_json::Value>) -> Self {
90 self.value = Some(value);
91 self
92 }
93
94 pub fn additional_properties(
95 mut self,
96 value: std::collections::BTreeMap<String, serde_json::Value>,
97 ) -> Self {
98 self.additional_properties = value;
99 self
100 }
101}
102
103impl Default for ItemApiPayloadDataAttributes {
104 fn default() -> Self {
105 Self::new()
106 }
107}
108
109impl<'de> Deserialize<'de> for ItemApiPayloadDataAttributes {
110 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
111 where
112 D: Deserializer<'de>,
113 {
114 struct ItemApiPayloadDataAttributesVisitor;
115 impl<'a> Visitor<'a> for ItemApiPayloadDataAttributesVisitor {
116 type Value = ItemApiPayloadDataAttributes;
117
118 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
119 f.write_str("a mapping")
120 }
121
122 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
123 where
124 M: MapAccess<'a>,
125 {
126 let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
127 let mut modified_at: Option<chrono::DateTime<chrono::Utc>> = None;
128 let mut org_id: Option<i64> = None;
129 let mut primary_column_name: Option<String> = None;
130 let mut signature: Option<String> = None;
131 let mut store_id: Option<String> = None;
132 let mut value: Option<std::collections::BTreeMap<String, serde_json::Value>> = None;
133 let mut additional_properties: std::collections::BTreeMap<
134 String,
135 serde_json::Value,
136 > = std::collections::BTreeMap::new();
137 let mut _unparsed = false;
138
139 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
140 match k.as_str() {
141 "created_at" => {
142 if v.is_null() {
143 continue;
144 }
145 created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
146 }
147 "modified_at" => {
148 if v.is_null() {
149 continue;
150 }
151 modified_at =
152 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
153 }
154 "org_id" => {
155 if v.is_null() {
156 continue;
157 }
158 org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
159 }
160 "primary_column_name" => {
161 if v.is_null() {
162 continue;
163 }
164 primary_column_name =
165 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
166 }
167 "signature" => {
168 if v.is_null() {
169 continue;
170 }
171 signature = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
172 }
173 "store_id" => {
174 if v.is_null() {
175 continue;
176 }
177 store_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
178 }
179 "value" => {
180 if v.is_null() {
181 continue;
182 }
183 value = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
184 }
185 &_ => {
186 if let Ok(value) = serde_json::from_value(v.clone()) {
187 additional_properties.insert(k, value);
188 }
189 }
190 }
191 }
192
193 let content = ItemApiPayloadDataAttributes {
194 created_at,
195 modified_at,
196 org_id,
197 primary_column_name,
198 signature,
199 store_id,
200 value,
201 additional_properties,
202 _unparsed,
203 };
204
205 Ok(content)
206 }
207 }
208
209 deserializer.deserialize_any(ItemApiPayloadDataAttributesVisitor)
210 }
211}