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