datadog_api_client/datadogV2/model/
model_get_device_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 device attributes
10#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct GetDeviceAttributes {
14    /// A description of the device.
15    #[serde(rename = "description")]
16    pub description: Option<String>,
17    /// The type of the device.
18    #[serde(rename = "device_type")]
19    pub device_type: Option<String>,
20    /// The integration of the device.
21    #[serde(rename = "integration")]
22    pub integration: Option<String>,
23    /// The IP address of the device.
24    #[serde(rename = "ip_address")]
25    pub ip_address: Option<String>,
26    /// The location of the device.
27    #[serde(rename = "location")]
28    pub location: Option<String>,
29    /// The model of the device.
30    #[serde(rename = "model")]
31    pub model: Option<String>,
32    /// The name of the device.
33    #[serde(rename = "name")]
34    pub name: Option<String>,
35    /// The operating system hostname of the device.
36    #[serde(rename = "os_hostname")]
37    pub os_hostname: Option<String>,
38    /// The operating system name of the device.
39    #[serde(rename = "os_name")]
40    pub os_name: Option<String>,
41    /// The operating system version of the device.
42    #[serde(rename = "os_version")]
43    pub os_version: Option<String>,
44    /// The ping status of the device.
45    #[serde(rename = "ping_status")]
46    pub ping_status: Option<String>,
47    /// The product name of the device.
48    #[serde(rename = "product_name")]
49    pub product_name: Option<String>,
50    /// The serial number of the device.
51    #[serde(rename = "serial_number")]
52    pub serial_number: Option<String>,
53    /// The status of the device.
54    #[serde(rename = "status")]
55    pub status: Option<String>,
56    /// The subnet of the device.
57    #[serde(rename = "subnet")]
58    pub subnet: Option<String>,
59    /// The device `sys_object_id`.
60    #[serde(rename = "sys_object_id")]
61    pub sys_object_id: Option<String>,
62    /// A list of tags associated with the device.
63    #[serde(rename = "tags")]
64    pub tags: Option<Vec<String>>,
65    /// The vendor of the device.
66    #[serde(rename = "vendor")]
67    pub vendor: Option<String>,
68    /// The version of the device.
69    #[serde(rename = "version")]
70    pub version: Option<String>,
71    #[serde(flatten)]
72    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
73    #[serde(skip)]
74    #[serde(default)]
75    pub(crate) _unparsed: bool,
76}
77
78impl GetDeviceAttributes {
79    pub fn new() -> GetDeviceAttributes {
80        GetDeviceAttributes {
81            description: None,
82            device_type: None,
83            integration: None,
84            ip_address: None,
85            location: None,
86            model: None,
87            name: None,
88            os_hostname: None,
89            os_name: None,
90            os_version: None,
91            ping_status: None,
92            product_name: None,
93            serial_number: None,
94            status: None,
95            subnet: None,
96            sys_object_id: None,
97            tags: None,
98            vendor: None,
99            version: None,
100            additional_properties: std::collections::BTreeMap::new(),
101            _unparsed: false,
102        }
103    }
104
105    pub fn description(mut self, value: String) -> Self {
106        self.description = Some(value);
107        self
108    }
109
110    pub fn device_type(mut self, value: String) -> Self {
111        self.device_type = Some(value);
112        self
113    }
114
115    pub fn integration(mut self, value: String) -> Self {
116        self.integration = Some(value);
117        self
118    }
119
120    pub fn ip_address(mut self, value: String) -> Self {
121        self.ip_address = Some(value);
122        self
123    }
124
125    pub fn location(mut self, value: String) -> Self {
126        self.location = Some(value);
127        self
128    }
129
130    pub fn model(mut self, value: String) -> Self {
131        self.model = Some(value);
132        self
133    }
134
135    pub fn name(mut self, value: String) -> Self {
136        self.name = Some(value);
137        self
138    }
139
140    pub fn os_hostname(mut self, value: String) -> Self {
141        self.os_hostname = Some(value);
142        self
143    }
144
145    pub fn os_name(mut self, value: String) -> Self {
146        self.os_name = Some(value);
147        self
148    }
149
150    pub fn os_version(mut self, value: String) -> Self {
151        self.os_version = Some(value);
152        self
153    }
154
155    pub fn ping_status(mut self, value: String) -> Self {
156        self.ping_status = Some(value);
157        self
158    }
159
160    pub fn product_name(mut self, value: String) -> Self {
161        self.product_name = Some(value);
162        self
163    }
164
165    pub fn serial_number(mut self, value: String) -> Self {
166        self.serial_number = Some(value);
167        self
168    }
169
170    pub fn status(mut self, value: String) -> Self {
171        self.status = Some(value);
172        self
173    }
174
175    pub fn subnet(mut self, value: String) -> Self {
176        self.subnet = Some(value);
177        self
178    }
179
180    pub fn sys_object_id(mut self, value: String) -> Self {
181        self.sys_object_id = Some(value);
182        self
183    }
184
185    pub fn tags(mut self, value: Vec<String>) -> Self {
186        self.tags = Some(value);
187        self
188    }
189
190    pub fn vendor(mut self, value: String) -> Self {
191        self.vendor = Some(value);
192        self
193    }
194
195    pub fn version(mut self, value: String) -> Self {
196        self.version = Some(value);
197        self
198    }
199
200    pub fn additional_properties(
201        mut self,
202        value: std::collections::BTreeMap<String, serde_json::Value>,
203    ) -> Self {
204        self.additional_properties = value;
205        self
206    }
207}
208
209impl Default for GetDeviceAttributes {
210    fn default() -> Self {
211        Self::new()
212    }
213}
214
215impl<'de> Deserialize<'de> for GetDeviceAttributes {
216    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
217    where
218        D: Deserializer<'de>,
219    {
220        struct GetDeviceAttributesVisitor;
221        impl<'a> Visitor<'a> for GetDeviceAttributesVisitor {
222            type Value = GetDeviceAttributes;
223
224            fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
225                f.write_str("a mapping")
226            }
227
228            fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
229            where
230                M: MapAccess<'a>,
231            {
232                let mut description: Option<String> = None;
233                let mut device_type: Option<String> = None;
234                let mut integration: Option<String> = None;
235                let mut ip_address: Option<String> = None;
236                let mut location: Option<String> = None;
237                let mut model: Option<String> = None;
238                let mut name: Option<String> = None;
239                let mut os_hostname: Option<String> = None;
240                let mut os_name: Option<String> = None;
241                let mut os_version: Option<String> = None;
242                let mut ping_status: Option<String> = None;
243                let mut product_name: Option<String> = None;
244                let mut serial_number: Option<String> = None;
245                let mut status: Option<String> = None;
246                let mut subnet: Option<String> = None;
247                let mut sys_object_id: Option<String> = None;
248                let mut tags: Option<Vec<String>> = None;
249                let mut vendor: Option<String> = None;
250                let mut version: Option<String> = None;
251                let mut additional_properties: std::collections::BTreeMap<
252                    String,
253                    serde_json::Value,
254                > = std::collections::BTreeMap::new();
255                let mut _unparsed = false;
256
257                while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
258                    match k.as_str() {
259                        "description" => {
260                            if v.is_null() {
261                                continue;
262                            }
263                            description =
264                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
265                        }
266                        "device_type" => {
267                            if v.is_null() {
268                                continue;
269                            }
270                            device_type =
271                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
272                        }
273                        "integration" => {
274                            if v.is_null() {
275                                continue;
276                            }
277                            integration =
278                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
279                        }
280                        "ip_address" => {
281                            if v.is_null() {
282                                continue;
283                            }
284                            ip_address = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
285                        }
286                        "location" => {
287                            if v.is_null() {
288                                continue;
289                            }
290                            location = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
291                        }
292                        "model" => {
293                            if v.is_null() {
294                                continue;
295                            }
296                            model = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
297                        }
298                        "name" => {
299                            if v.is_null() {
300                                continue;
301                            }
302                            name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
303                        }
304                        "os_hostname" => {
305                            if v.is_null() {
306                                continue;
307                            }
308                            os_hostname =
309                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
310                        }
311                        "os_name" => {
312                            if v.is_null() {
313                                continue;
314                            }
315                            os_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
316                        }
317                        "os_version" => {
318                            if v.is_null() {
319                                continue;
320                            }
321                            os_version = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
322                        }
323                        "ping_status" => {
324                            if v.is_null() {
325                                continue;
326                            }
327                            ping_status =
328                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
329                        }
330                        "product_name" => {
331                            if v.is_null() {
332                                continue;
333                            }
334                            product_name =
335                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
336                        }
337                        "serial_number" => {
338                            if v.is_null() {
339                                continue;
340                            }
341                            serial_number =
342                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
343                        }
344                        "status" => {
345                            if v.is_null() {
346                                continue;
347                            }
348                            status = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
349                        }
350                        "subnet" => {
351                            if v.is_null() {
352                                continue;
353                            }
354                            subnet = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
355                        }
356                        "sys_object_id" => {
357                            if v.is_null() {
358                                continue;
359                            }
360                            sys_object_id =
361                                Some(serde_json::from_value(v).map_err(M::Error::custom)?);
362                        }
363                        "tags" => {
364                            if v.is_null() {
365                                continue;
366                            }
367                            tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
368                        }
369                        "vendor" => {
370                            if v.is_null() {
371                                continue;
372                            }
373                            vendor = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
374                        }
375                        "version" => {
376                            if v.is_null() {
377                                continue;
378                            }
379                            version = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
380                        }
381                        &_ => {
382                            if let Ok(value) = serde_json::from_value(v.clone()) {
383                                additional_properties.insert(k, value);
384                            }
385                        }
386                    }
387                }
388
389                let content = GetDeviceAttributes {
390                    description,
391                    device_type,
392                    integration,
393                    ip_address,
394                    location,
395                    model,
396                    name,
397                    os_hostname,
398                    os_name,
399                    os_version,
400                    ping_status,
401                    product_name,
402                    serial_number,
403                    status,
404                    subnet,
405                    sys_object_id,
406                    tags,
407                    vendor,
408                    version,
409                    additional_properties,
410                    _unparsed,
411                };
412
413                Ok(content)
414            }
415        }
416
417        deserializer.deserialize_any(GetDeviceAttributesVisitor)
418    }
419}