datadog_api_client/datadogV2/model/
model_authn_mapping_create_relationships.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/// Relationship of AuthN Mapping create object to a Role or Team.
7#[non_exhaustive]
8#[derive(Clone, Debug, PartialEq, Serialize)]
9#[serde(untagged)]
10pub enum AuthNMappingCreateRelationships {
11    AuthNMappingRelationshipToRole(Box<crate::datadogV2::model::AuthNMappingRelationshipToRole>),
12    AuthNMappingRelationshipToTeam(Box<crate::datadogV2::model::AuthNMappingRelationshipToTeam>),
13    UnparsedObject(crate::datadog::UnparsedObject),
14}
15
16impl<'de> Deserialize<'de> for AuthNMappingCreateRelationships {
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::<
23            Box<crate::datadogV2::model::AuthNMappingRelationshipToRole>,
24        >(value.clone())
25        {
26            if !_v._unparsed {
27                return Ok(AuthNMappingCreateRelationships::AuthNMappingRelationshipToRole(_v));
28            }
29        }
30        if let Ok(_v) = serde_json::from_value::<
31            Box<crate::datadogV2::model::AuthNMappingRelationshipToTeam>,
32        >(value.clone())
33        {
34            if !_v._unparsed {
35                return Ok(AuthNMappingCreateRelationships::AuthNMappingRelationshipToTeam(_v));
36            }
37        }
38
39        return Ok(AuthNMappingCreateRelationships::UnparsedObject(
40            crate::datadog::UnparsedObject { value },
41        ));
42    }
43}