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