datadog_api_client/datadogV2/model/
model_csm_serverless_coverage_analysis_data.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 CsmServerlessCoverageAnalysisData {
14 #[serde(rename = "attributes")]
16 pub attributes: Option<crate::datadogV2::model::CsmServerlessCoverageAnalysisAttributes>,
17 #[serde(rename = "id")]
19 pub id: Option<String>,
20 #[serde(rename = "type")]
22 pub type_: Option<String>,
23 #[serde(flatten)]
24 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
25 #[serde(skip)]
26 #[serde(default)]
27 pub(crate) _unparsed: bool,
28}
29
30impl CsmServerlessCoverageAnalysisData {
31 pub fn new() -> CsmServerlessCoverageAnalysisData {
32 CsmServerlessCoverageAnalysisData {
33 attributes: None,
34 id: None,
35 type_: None,
36 additional_properties: std::collections::BTreeMap::new(),
37 _unparsed: false,
38 }
39 }
40
41 pub fn attributes(
42 mut self,
43 value: crate::datadogV2::model::CsmServerlessCoverageAnalysisAttributes,
44 ) -> Self {
45 self.attributes = Some(value);
46 self
47 }
48
49 pub fn id(mut self, value: String) -> Self {
50 self.id = Some(value);
51 self
52 }
53
54 pub fn type_(mut self, value: String) -> Self {
55 self.type_ = Some(value);
56 self
57 }
58
59 pub fn additional_properties(
60 mut self,
61 value: std::collections::BTreeMap<String, serde_json::Value>,
62 ) -> Self {
63 self.additional_properties = value;
64 self
65 }
66}
67
68impl Default for CsmServerlessCoverageAnalysisData {
69 fn default() -> Self {
70 Self::new()
71 }
72}
73
74impl<'de> Deserialize<'de> for CsmServerlessCoverageAnalysisData {
75 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
76 where
77 D: Deserializer<'de>,
78 {
79 struct CsmServerlessCoverageAnalysisDataVisitor;
80 impl<'a> Visitor<'a> for CsmServerlessCoverageAnalysisDataVisitor {
81 type Value = CsmServerlessCoverageAnalysisData;
82
83 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
84 f.write_str("a mapping")
85 }
86
87 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
88 where
89 M: MapAccess<'a>,
90 {
91 let mut attributes: Option<
92 crate::datadogV2::model::CsmServerlessCoverageAnalysisAttributes,
93 > = None;
94 let mut id: Option<String> = None;
95 let mut type_: Option<String> = None;
96 let mut additional_properties: std::collections::BTreeMap<
97 String,
98 serde_json::Value,
99 > = std::collections::BTreeMap::new();
100 let mut _unparsed = false;
101
102 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
103 match k.as_str() {
104 "attributes" => {
105 if v.is_null() {
106 continue;
107 }
108 attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
109 }
110 "id" => {
111 if v.is_null() {
112 continue;
113 }
114 id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
115 }
116 "type" => {
117 if v.is_null() {
118 continue;
119 }
120 type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
121 }
122 &_ => {
123 if let Ok(value) = serde_json::from_value(v.clone()) {
124 additional_properties.insert(k, value);
125 }
126 }
127 }
128 }
129
130 let content = CsmServerlessCoverageAnalysisData {
131 attributes,
132 id,
133 type_,
134 additional_properties,
135 _unparsed,
136 };
137
138 Ok(content)
139 }
140 }
141
142 deserializer.deserialize_any(CsmServerlessCoverageAnalysisDataVisitor)
143 }
144}