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