datadog_api_client/datadogV2/model/
model_observability_pipeline_aws_auth.rs1use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9#[non_exhaustive]
13#[skip_serializing_none]
14#[derive(Clone, Debug, PartialEq, Serialize)]
15pub struct ObservabilityPipelineAwsAuth {
16 #[serde(rename = "assume_role")]
18 pub assume_role: Option<String>,
19 #[serde(rename = "external_id")]
21 pub external_id: Option<String>,
22 #[serde(rename = "session_name")]
24 pub session_name: Option<String>,
25 #[serde(flatten)]
26 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
27 #[serde(skip)]
28 #[serde(default)]
29 pub(crate) _unparsed: bool,
30}
31
32impl ObservabilityPipelineAwsAuth {
33 pub fn new() -> ObservabilityPipelineAwsAuth {
34 ObservabilityPipelineAwsAuth {
35 assume_role: None,
36 external_id: None,
37 session_name: None,
38 additional_properties: std::collections::BTreeMap::new(),
39 _unparsed: false,
40 }
41 }
42
43 pub fn assume_role(mut self, value: String) -> Self {
44 self.assume_role = Some(value);
45 self
46 }
47
48 pub fn external_id(mut self, value: String) -> Self {
49 self.external_id = Some(value);
50 self
51 }
52
53 pub fn session_name(mut self, value: String) -> Self {
54 self.session_name = Some(value);
55 self
56 }
57
58 pub fn additional_properties(
59 mut self,
60 value: std::collections::BTreeMap<String, serde_json::Value>,
61 ) -> Self {
62 self.additional_properties = value;
63 self
64 }
65}
66
67impl Default for ObservabilityPipelineAwsAuth {
68 fn default() -> Self {
69 Self::new()
70 }
71}
72
73impl<'de> Deserialize<'de> for ObservabilityPipelineAwsAuth {
74 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
75 where
76 D: Deserializer<'de>,
77 {
78 struct ObservabilityPipelineAwsAuthVisitor;
79 impl<'a> Visitor<'a> for ObservabilityPipelineAwsAuthVisitor {
80 type Value = ObservabilityPipelineAwsAuth;
81
82 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
83 f.write_str("a mapping")
84 }
85
86 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
87 where
88 M: MapAccess<'a>,
89 {
90 let mut assume_role: Option<String> = None;
91 let mut external_id: Option<String> = None;
92 let mut session_name: Option<String> = None;
93 let mut additional_properties: std::collections::BTreeMap<
94 String,
95 serde_json::Value,
96 > = std::collections::BTreeMap::new();
97 let mut _unparsed = false;
98
99 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
100 match k.as_str() {
101 "assume_role" => {
102 if v.is_null() {
103 continue;
104 }
105 assume_role =
106 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
107 }
108 "external_id" => {
109 if v.is_null() {
110 continue;
111 }
112 external_id =
113 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
114 }
115 "session_name" => {
116 if v.is_null() {
117 continue;
118 }
119 session_name =
120 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
121 }
122 &_ => {
123 if let Ok(value) = serde_json::from_value(v.clone()) {
124 additional_properties.insert(k, value);
125 }
126 }
127 }
128 }
129
130 let content = ObservabilityPipelineAwsAuth {
131 assume_role,
132 external_id,
133 session_name,
134 additional_properties,
135 _unparsed,
136 };
137
138 Ok(content)
139 }
140 }
141
142 deserializer.deserialize_any(ObservabilityPipelineAwsAuthVisitor)
143 }
144}