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