datadog_api_client/datadogV2/model/
model_notion_credentials.rs1use serde::{Deserialize, Deserializer, Serialize};
5
6#[non_exhaustive]
8#[derive(Clone, Debug, PartialEq, Serialize)]
9#[serde(untagged)]
10pub enum NotionCredentials {
11 NotionAPIKey(Box<crate::datadogV2::model::NotionAPIKey>),
12 UnparsedObject(crate::datadog::UnparsedObject),
13}
14
15impl<'de> Deserialize<'de> for NotionCredentials {
16 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
17 where
18 D: Deserializer<'de>,
19 {
20 let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
21 if let Ok(_v) =
22 serde_json::from_value::<Box<crate::datadogV2::model::NotionAPIKey>>(value.clone())
23 {
24 if !_v._unparsed {
25 return Ok(NotionCredentials::NotionAPIKey(_v));
26 }
27 }
28
29 return Ok(NotionCredentials::UnparsedObject(
30 crate::datadog::UnparsedObject { value },
31 ));
32 }
33}