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