datadog_api_client/datadogV2/model/
model_container_image_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 ContainerImageAttributes {
14 #[serde(rename = "container_count")]
16 pub container_count: Option<i64>,
17 #[serde(rename = "image_flavors")]
20 pub image_flavors: Option<Vec<crate::datadogV2::model::ContainerImageFlavor>>,
21 #[serde(rename = "image_tags")]
23 pub image_tags: Option<Vec<String>>,
24 #[serde(rename = "images_built_at")]
27 pub images_built_at: Option<Vec<String>>,
28 #[serde(rename = "name")]
30 pub name: Option<String>,
31 #[serde(rename = "os_architectures")]
33 pub os_architectures: Option<Vec<String>>,
34 #[serde(rename = "os_names")]
36 pub os_names: Option<Vec<String>>,
37 #[serde(rename = "os_versions")]
39 pub os_versions: Option<Vec<String>>,
40 #[serde(rename = "published_at")]
42 pub published_at: Option<String>,
43 #[serde(rename = "registry")]
45 pub registry: Option<String>,
46 #[serde(rename = "repo_digest")]
48 pub repo_digest: Option<String>,
49 #[serde(rename = "repository")]
51 pub repository: Option<String>,
52 #[serde(rename = "short_image")]
54 pub short_image: Option<String>,
55 #[serde(rename = "sizes")]
58 pub sizes: Option<Vec<i64>>,
59 #[serde(rename = "sources")]
61 pub sources: Option<Vec<String>>,
62 #[serde(rename = "tags")]
64 pub tags: Option<Vec<String>>,
65 #[serde(rename = "vulnerability_count")]
67 pub vulnerability_count: Option<crate::datadogV2::model::ContainerImageVulnerabilities>,
68 #[serde(flatten)]
69 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
70 #[serde(skip)]
71 #[serde(default)]
72 pub(crate) _unparsed: bool,
73}
74
75impl ContainerImageAttributes {
76 pub fn new() -> ContainerImageAttributes {
77 ContainerImageAttributes {
78 container_count: None,
79 image_flavors: None,
80 image_tags: None,
81 images_built_at: None,
82 name: None,
83 os_architectures: None,
84 os_names: None,
85 os_versions: None,
86 published_at: None,
87 registry: None,
88 repo_digest: None,
89 repository: None,
90 short_image: None,
91 sizes: None,
92 sources: None,
93 tags: None,
94 vulnerability_count: None,
95 additional_properties: std::collections::BTreeMap::new(),
96 _unparsed: false,
97 }
98 }
99
100 pub fn container_count(mut self, value: i64) -> Self {
101 self.container_count = Some(value);
102 self
103 }
104
105 pub fn image_flavors(
106 mut self,
107 value: Vec<crate::datadogV2::model::ContainerImageFlavor>,
108 ) -> Self {
109 self.image_flavors = Some(value);
110 self
111 }
112
113 pub fn image_tags(mut self, value: Vec<String>) -> Self {
114 self.image_tags = Some(value);
115 self
116 }
117
118 pub fn images_built_at(mut self, value: Vec<String>) -> Self {
119 self.images_built_at = Some(value);
120 self
121 }
122
123 pub fn name(mut self, value: String) -> Self {
124 self.name = Some(value);
125 self
126 }
127
128 pub fn os_architectures(mut self, value: Vec<String>) -> Self {
129 self.os_architectures = Some(value);
130 self
131 }
132
133 pub fn os_names(mut self, value: Vec<String>) -> Self {
134 self.os_names = Some(value);
135 self
136 }
137
138 pub fn os_versions(mut self, value: Vec<String>) -> Self {
139 self.os_versions = Some(value);
140 self
141 }
142
143 pub fn published_at(mut self, value: String) -> Self {
144 self.published_at = Some(value);
145 self
146 }
147
148 pub fn registry(mut self, value: String) -> Self {
149 self.registry = Some(value);
150 self
151 }
152
153 pub fn repo_digest(mut self, value: String) -> Self {
154 self.repo_digest = Some(value);
155 self
156 }
157
158 pub fn repository(mut self, value: String) -> Self {
159 self.repository = Some(value);
160 self
161 }
162
163 pub fn short_image(mut self, value: String) -> Self {
164 self.short_image = Some(value);
165 self
166 }
167
168 pub fn sizes(mut self, value: Vec<i64>) -> Self {
169 self.sizes = Some(value);
170 self
171 }
172
173 pub fn sources(mut self, value: Vec<String>) -> Self {
174 self.sources = Some(value);
175 self
176 }
177
178 pub fn tags(mut self, value: Vec<String>) -> Self {
179 self.tags = Some(value);
180 self
181 }
182
183 pub fn vulnerability_count(
184 mut self,
185 value: crate::datadogV2::model::ContainerImageVulnerabilities,
186 ) -> Self {
187 self.vulnerability_count = Some(value);
188 self
189 }
190
191 pub fn additional_properties(
192 mut self,
193 value: std::collections::BTreeMap<String, serde_json::Value>,
194 ) -> Self {
195 self.additional_properties = value;
196 self
197 }
198}
199
200impl Default for ContainerImageAttributes {
201 fn default() -> Self {
202 Self::new()
203 }
204}
205
206impl<'de> Deserialize<'de> for ContainerImageAttributes {
207 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
208 where
209 D: Deserializer<'de>,
210 {
211 struct ContainerImageAttributesVisitor;
212 impl<'a> Visitor<'a> for ContainerImageAttributesVisitor {
213 type Value = ContainerImageAttributes;
214
215 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
216 f.write_str("a mapping")
217 }
218
219 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
220 where
221 M: MapAccess<'a>,
222 {
223 let mut container_count: Option<i64> = None;
224 let mut image_flavors: Option<Vec<crate::datadogV2::model::ContainerImageFlavor>> =
225 None;
226 let mut image_tags: Option<Vec<String>> = None;
227 let mut images_built_at: Option<Vec<String>> = None;
228 let mut name: Option<String> = None;
229 let mut os_architectures: Option<Vec<String>> = None;
230 let mut os_names: Option<Vec<String>> = None;
231 let mut os_versions: Option<Vec<String>> = None;
232 let mut published_at: Option<String> = None;
233 let mut registry: Option<String> = None;
234 let mut repo_digest: Option<String> = None;
235 let mut repository: Option<String> = None;
236 let mut short_image: Option<String> = None;
237 let mut sizes: Option<Vec<i64>> = None;
238 let mut sources: Option<Vec<String>> = None;
239 let mut tags: Option<Vec<String>> = None;
240 let mut vulnerability_count: Option<
241 crate::datadogV2::model::ContainerImageVulnerabilities,
242 > = None;
243 let mut additional_properties: std::collections::BTreeMap<
244 String,
245 serde_json::Value,
246 > = std::collections::BTreeMap::new();
247 let mut _unparsed = false;
248
249 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
250 match k.as_str() {
251 "container_count" => {
252 if v.is_null() {
253 continue;
254 }
255 container_count =
256 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
257 }
258 "image_flavors" => {
259 if v.is_null() {
260 continue;
261 }
262 image_flavors =
263 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
264 }
265 "image_tags" => {
266 if v.is_null() {
267 continue;
268 }
269 image_tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
270 }
271 "images_built_at" => {
272 if v.is_null() {
273 continue;
274 }
275 images_built_at =
276 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
277 }
278 "name" => {
279 if v.is_null() {
280 continue;
281 }
282 name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
283 }
284 "os_architectures" => {
285 if v.is_null() {
286 continue;
287 }
288 os_architectures =
289 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
290 }
291 "os_names" => {
292 if v.is_null() {
293 continue;
294 }
295 os_names = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
296 }
297 "os_versions" => {
298 if v.is_null() {
299 continue;
300 }
301 os_versions =
302 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
303 }
304 "published_at" => {
305 if v.is_null() {
306 continue;
307 }
308 published_at =
309 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
310 }
311 "registry" => {
312 if v.is_null() {
313 continue;
314 }
315 registry = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
316 }
317 "repo_digest" => {
318 if v.is_null() {
319 continue;
320 }
321 repo_digest =
322 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
323 }
324 "repository" => {
325 if v.is_null() {
326 continue;
327 }
328 repository = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
329 }
330 "short_image" => {
331 if v.is_null() {
332 continue;
333 }
334 short_image =
335 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
336 }
337 "sizes" => {
338 if v.is_null() {
339 continue;
340 }
341 sizes = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
342 }
343 "sources" => {
344 if v.is_null() {
345 continue;
346 }
347 sources = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
348 }
349 "tags" => {
350 if v.is_null() {
351 continue;
352 }
353 tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
354 }
355 "vulnerability_count" => {
356 if v.is_null() {
357 continue;
358 }
359 vulnerability_count =
360 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
361 }
362 &_ => {
363 if let Ok(value) = serde_json::from_value(v.clone()) {
364 additional_properties.insert(k, value);
365 }
366 }
367 }
368 }
369
370 let content = ContainerImageAttributes {
371 container_count,
372 image_flavors,
373 image_tags,
374 images_built_at,
375 name,
376 os_architectures,
377 os_names,
378 os_versions,
379 published_at,
380 registry,
381 repo_digest,
382 repository,
383 short_image,
384 sizes,
385 sources,
386 tags,
387 vulnerability_count,
388 additional_properties,
389 _unparsed,
390 };
391
392 Ok(content)
393 }
394 }
395
396 deserializer.deserialize_any(ContainerImageAttributesVisitor)
397 }
398}