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