datadog_api_client/datadogV2/model/
model_google_meet_configuration_reference.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/// A reference to a Google Meet Configuration resource.
10#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct GoogleMeetConfigurationReference {
14    /// The Google Meet configuration relationship data object.
15    #[serialize_always]
16    #[serde(rename = "data")]
17    pub data: Option<crate::datadogV2::model::GoogleMeetConfigurationReferenceData>,
18    #[serde(flatten)]
19    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
20    #[serde(skip)]
21    #[serde(default)]
22    pub(crate) _unparsed: bool,
23}
24
25impl GoogleMeetConfigurationReference {
26    pub fn new(
27        data: Option<crate::datadogV2::model::GoogleMeetConfigurationReferenceData>,
28    ) -> GoogleMeetConfigurationReference {
29        GoogleMeetConfigurationReference {
30            data,
31            additional_properties: std::collections::BTreeMap::new(),
32            _unparsed: false,
33        }
34    }
35
36    pub fn additional_properties(
37        mut self,
38        value: std::collections::BTreeMap<String, serde_json::Value>,
39    ) -> Self {
40        self.additional_properties = value;
41        self
42    }
43}
44
45impl<'de> Deserialize<'de> for GoogleMeetConfigurationReference {
46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
47    where
48        D: Deserializer<'de>,
49    {
50        struct GoogleMeetConfigurationReferenceVisitor;
51        impl<'a> Visitor<'a> for GoogleMeetConfigurationReferenceVisitor {
52            type Value = GoogleMeetConfigurationReference;
53
54            fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
55                f.write_str("a mapping")
56            }
57
58            fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
59            where
60                M: MapAccess<'a>,
61            {
62                let mut data: Option<
63                    Option<crate::datadogV2::model::GoogleMeetConfigurationReferenceData>,
64                > = None;
65                let mut additional_properties: std::collections::BTreeMap<
66                    String,
67                    serde_json::Value,
68                > = std::collections::BTreeMap::new();
69                let mut _unparsed = false;
70
71                while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
72                    match k.as_str() {
73                        "data" => {
74                            data = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
75                        }
76                        &_ => {
77                            if let Ok(value) = serde_json::from_value(v.clone()) {
78                                additional_properties.insert(k, value);
79                            }
80                        }
81                    }
82                }
83                let data = data.ok_or_else(|| M::Error::missing_field("data"))?;
84
85                let content = GoogleMeetConfigurationReference {
86                    data,
87                    additional_properties,
88                    _unparsed,
89                };
90
91                Ok(content)
92            }
93        }
94
95        deserializer.deserialize_any(GoogleMeetConfigurationReferenceVisitor)
96    }
97}