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