datadog_api_client/datadogV2/model/
model_get_app_response_data_attributes.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9/// The app definition attributes, such as name, description, and components.
10#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct GetAppResponseDataAttributes {
14    /// The UI components that make up the app.
15    #[serde(rename = "components")]
16    pub components: Option<Vec<crate::datadogV2::model::ComponentGrid>>,
17    /// A human-readable description for the app.
18    #[serde(rename = "description")]
19    pub description: Option<String>,
20    /// Whether the app is marked as a favorite by the current user.
21    #[serde(rename = "favorite")]
22    pub favorite: Option<bool>,
23    /// The name of the app.
24    #[serde(rename = "name")]
25    pub name: Option<String>,
26    /// An array of queries, such as external actions and state variables, that the app uses.
27    #[serde(rename = "queries")]
28    pub queries: Option<Vec<crate::datadogV2::model::Query>>,
29    /// The name of the root component of the app. This must be a `grid` component that contains all other components.
30    #[serde(rename = "rootInstanceName")]
31    pub root_instance_name: Option<String>,
32    /// A list of tags for the app, which can be used to filter apps.
33    #[serde(rename = "tags")]
34    pub tags: Option<Vec<String>>,
35    #[serde(flatten)]
36    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
37    #[serde(skip)]
38    #[serde(default)]
39    pub(crate) _unparsed: bool,
40}
41
42impl GetAppResponseDataAttributes {
43    pub fn new() -> GetAppResponseDataAttributes {
44        GetAppResponseDataAttributes {
45            components: None,
46            description: None,
47            favorite: None,
48            name: None,
49            queries: None,
50            root_instance_name: None,
51            tags: None,
52            additional_properties: std::collections::BTreeMap::new(),
53            _unparsed: false,
54        }
55    }
56
57    pub fn components(mut self, value: Vec<crate::datadogV2::model::ComponentGrid>) -> Self {
58        self.components = Some(value);
59        self
60    }
61
62    pub fn description(mut self, value: String) -> Self {
63        self.description = Some(value);
64        self
65    }
66
67    pub fn favorite(mut self, value: bool) -> Self {
68        self.favorite = Some(value);
69        self
70    }
71
72    pub fn name(mut self, value: String) -> Self {
73        self.name = Some(value);
74        self
75    }
76
77    pub fn queries(mut self, value: Vec<crate::datadogV2::model::Query>) -> Self {
78        self.queries = Some(value);
79        self
80    }
81
82    pub fn root_instance_name(mut self, value: String) -> Self {
83        self.root_instance_name = Some(value);
84        self
85    }
86
87    pub fn tags(mut self, value: Vec<String>) -> Self {
88        self.tags = Some(value);
89        self
90    }
91
92    pub fn additional_properties(
93        mut self,
94        value: std::collections::BTreeMap<String, serde_json::Value>,
95    ) -> Self {
96        self.additional_properties = value;
97        self
98    }
99}
100
101impl Default for GetAppResponseDataAttributes {
102    fn default() -> Self {
103        Self::new()
104    }
105}
106
107impl<'de> Deserialize<'de> for GetAppResponseDataAttributes {
108    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
109    where
110        D: Deserializer<'de>,
111    {
112        struct GetAppResponseDataAttributesVisitor;
113        impl<'a> Visitor<'a> for GetAppResponseDataAttributesVisitor {
114            type Value = GetAppResponseDataAttributes;
115
116            fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
117                f.write_str("a mapping")
118            }
119
120            fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
121            where
122                M: MapAccess<'a>,
123            {
124                let mut components: Option<Vec<crate::datadogV2::model::ComponentGrid>> = None;
125                let mut description: Option<String> = None;
126                let mut favorite: Option<bool> = None;
127                let mut name: Option<String> = None;
128                let mut queries: Option<Vec<crate::datadogV2::model::Query>> = None;
129                let mut root_instance_name: Option<String> = None;
130                let mut tags: Option<Vec<String>> = None;
131                let mut additional_properties: std::collections::BTreeMap<
132                    String,
133                    serde_json::Value,
134                > = std::collections::BTreeMap::new();
135                let mut _unparsed = false;
136
137                while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
138                    match k.as_str() {
139                        "components" => {
140                            if v.is_null() {
141                                continue;
142                            }
143                            components = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
144                        }
145                        "description" => {
146                            if v.is_null() {
147                                continue;
148                            }
149                            description =
150                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
151                        }
152                        "favorite" => {
153                            if v.is_null() {
154                                continue;
155                            }
156                            favorite = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
157                        }
158                        "name" => {
159                            if v.is_null() {
160                                continue;
161                            }
162                            name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
163                        }
164                        "queries" => {
165                            if v.is_null() {
166                                continue;
167                            }
168                            queries = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
169                        }
170                        "rootInstanceName" => {
171                            if v.is_null() {
172                                continue;
173                            }
174                            root_instance_name =
175                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
176                        }
177                        "tags" => {
178                            if v.is_null() {
179                                continue;
180                            }
181                            tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
182                        }
183                        &_ => {
184                            if let Ok(value) = serde_json::from_value(v.clone()) {
185                                additional_properties.insert(k, value);
186                            }
187                        }
188                    }
189                }
190
191                let content = GetAppResponseDataAttributes {
192                    components,
193                    description,
194                    favorite,
195                    name,
196                    queries,
197                    root_instance_name,
198                    tags,
199                    additional_properties,
200                    _unparsed,
201                };
202
203                Ok(content)
204            }
205        }
206
207        deserializer.deserialize_any(GetAppResponseDataAttributesVisitor)
208    }
209}