datadog_api_client/datadogV2/model/
model_authn_mapping_included.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::{Deserialize, Deserializer, Serialize};
5
6/// Included data in the AuthN Mapping response.
7#[non_exhaustive]
8#[derive(Clone, Debug, PartialEq, Serialize)]
9#[serde(untagged)]
10pub enum AuthNMappingIncluded {
11    SAMLAssertionAttribute(Box<crate::datadogV2::model::SAMLAssertionAttribute>),
12    Role(Box<crate::datadogV2::model::Role>),
13    AuthNMappingTeam(Box<crate::datadogV2::model::AuthNMappingTeam>),
14    UnparsedObject(crate::datadog::UnparsedObject),
15}
16
17impl<'de> Deserialize<'de> for AuthNMappingIncluded {
18    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
19    where
20        D: Deserializer<'de>,
21    {
22        let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
23        if let Ok(_v) = serde_json::from_value::<Box<crate::datadogV2::model::SAMLAssertionAttribute>>(
24            value.clone(),
25        ) {
26            if !_v._unparsed {
27                return Ok(AuthNMappingIncluded::SAMLAssertionAttribute(_v));
28            }
29        }
30        if let Ok(_v) = serde_json::from_value::<Box<crate::datadogV2::model::Role>>(value.clone())
31        {
32            if !_v._unparsed {
33                return Ok(AuthNMappingIncluded::Role(_v));
34            }
35        }
36        if let Ok(_v) =
37            serde_json::from_value::<Box<crate::datadogV2::model::AuthNMappingTeam>>(value.clone())
38        {
39            if !_v._unparsed {
40                return Ok(AuthNMappingIncluded::AuthNMappingTeam(_v));
41            }
42        }
43
44        return Ok(AuthNMappingIncluded::UnparsedObject(
45            crate::datadog::UnparsedObject { value },
46        ));
47    }
48}