aws_sdk_accessanalyzer/protocol_serde/
shape_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_configuration(
3    object_7: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::Configuration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    match input {
7        crate::types::Configuration::EbsSnapshot(inner) => {
8            #[allow(unused_mut)]
9            let mut object_1 = object_7.key("ebsSnapshot").start_object();
10            crate::protocol_serde::shape_ebs_snapshot_configuration::ser_ebs_snapshot_configuration(&mut object_1, inner)?;
11            object_1.finish();
12        }
13        crate::types::Configuration::EcrRepository(inner) => {
14            #[allow(unused_mut)]
15            let mut object_2 = object_7.key("ecrRepository").start_object();
16            crate::protocol_serde::shape_ecr_repository_configuration::ser_ecr_repository_configuration(&mut object_2, inner)?;
17            object_2.finish();
18        }
19        crate::types::Configuration::IamRole(inner) => {
20            #[allow(unused_mut)]
21            let mut object_3 = object_7.key("iamRole").start_object();
22            crate::protocol_serde::shape_iam_role_configuration::ser_iam_role_configuration(&mut object_3, inner)?;
23            object_3.finish();
24        }
25        crate::types::Configuration::EfsFileSystem(inner) => {
26            #[allow(unused_mut)]
27            let mut object_4 = object_7.key("efsFileSystem").start_object();
28            crate::protocol_serde::shape_efs_file_system_configuration::ser_efs_file_system_configuration(&mut object_4, inner)?;
29            object_4.finish();
30        }
31        crate::types::Configuration::KmsKey(inner) => {
32            #[allow(unused_mut)]
33            let mut object_5 = object_7.key("kmsKey").start_object();
34            crate::protocol_serde::shape_kms_key_configuration::ser_kms_key_configuration(&mut object_5, inner)?;
35            object_5.finish();
36        }
37        crate::types::Configuration::RdsDbClusterSnapshot(inner) => {
38            #[allow(unused_mut)]
39            let mut object_6 = object_7.key("rdsDbClusterSnapshot").start_object();
40            crate::protocol_serde::shape_rds_db_cluster_snapshot_configuration::ser_rds_db_cluster_snapshot_configuration(&mut object_6, inner)?;
41            object_6.finish();
42        }
43        crate::types::Configuration::RdsDbSnapshot(inner) => {
44            #[allow(unused_mut)]
45            let mut object_7 = object_7.key("rdsDbSnapshot").start_object();
46            crate::protocol_serde::shape_rds_db_snapshot_configuration::ser_rds_db_snapshot_configuration(&mut object_7, inner)?;
47            object_7.finish();
48        }
49        crate::types::Configuration::SecretsManagerSecret(inner) => {
50            #[allow(unused_mut)]
51            let mut object_8 = object_7.key("secretsManagerSecret").start_object();
52            crate::protocol_serde::shape_secrets_manager_secret_configuration::ser_secrets_manager_secret_configuration(&mut object_8, inner)?;
53            object_8.finish();
54        }
55        crate::types::Configuration::S3Bucket(inner) => {
56            #[allow(unused_mut)]
57            let mut object_9 = object_7.key("s3Bucket").start_object();
58            crate::protocol_serde::shape_s3_bucket_configuration::ser_s3_bucket_configuration(&mut object_9, inner)?;
59            object_9.finish();
60        }
61        crate::types::Configuration::SnsTopic(inner) => {
62            #[allow(unused_mut)]
63            let mut object_10 = object_7.key("snsTopic").start_object();
64            crate::protocol_serde::shape_sns_topic_configuration::ser_sns_topic_configuration(&mut object_10, inner)?;
65            object_10.finish();
66        }
67        crate::types::Configuration::SqsQueue(inner) => {
68            #[allow(unused_mut)]
69            let mut object_11 = object_7.key("sqsQueue").start_object();
70            crate::protocol_serde::shape_sqs_queue_configuration::ser_sqs_queue_configuration(&mut object_11, inner)?;
71            object_11.finish();
72        }
73        crate::types::Configuration::S3ExpressDirectoryBucket(inner) => {
74            #[allow(unused_mut)]
75            let mut object_12 = object_7.key("s3ExpressDirectoryBucket").start_object();
76            crate::protocol_serde::shape_s3_express_directory_bucket_configuration::ser_s3_express_directory_bucket_configuration(
77                &mut object_12,
78                inner,
79            )?;
80            object_12.finish();
81        }
82        crate::types::Configuration::DynamodbStream(inner) => {
83            #[allow(unused_mut)]
84            let mut object_13 = object_7.key("dynamodbStream").start_object();
85            crate::protocol_serde::shape_dynamodb_stream_configuration::ser_dynamodb_stream_configuration(&mut object_13, inner)?;
86            object_13.finish();
87        }
88        crate::types::Configuration::DynamodbTable(inner) => {
89            #[allow(unused_mut)]
90            let mut object_14 = object_7.key("dynamodbTable").start_object();
91            crate::protocol_serde::shape_dynamodb_table_configuration::ser_dynamodb_table_configuration(&mut object_14, inner)?;
92            object_14.finish();
93        }
94        crate::types::Configuration::Unknown => {
95            return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("Configuration"))
96        }
97    }
98    Ok(())
99}
100
101pub(crate) fn de_configuration<'a, I>(
102    tokens: &mut ::std::iter::Peekable<I>,
103) -> ::std::result::Result<Option<crate::types::Configuration>, ::aws_smithy_json::deserialize::error::DeserializeError>
104where
105    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
106{
107    let mut variant = None;
108    match tokens.next().transpose()? {
109        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
110        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
111            match tokens.next().transpose()? {
112                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
113                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
114                    if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
115                        tokens.peek()
116                    {
117                        let _ = tokens.next().expect("peek returned a token")?;
118                        continue;
119                    }
120                    let key = key.to_unescaped()?;
121                    if key == "__type" {
122                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
123                        continue;
124                    }
125                    if variant.is_some() {
126                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
127                            "encountered mixed variants in union",
128                        ));
129                    }
130                    variant = match key.as_ref() {
131                        "ebsSnapshot" => Some(crate::types::Configuration::EbsSnapshot(
132                            crate::protocol_serde::shape_ebs_snapshot_configuration::de_ebs_snapshot_configuration(tokens)?.ok_or_else(|| {
133                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'ebsSnapshot' cannot be null")
134                            })?,
135                        )),
136                        "ecrRepository" => Some(crate::types::Configuration::EcrRepository(
137                            crate::protocol_serde::shape_ecr_repository_configuration::de_ecr_repository_configuration(tokens)?.ok_or_else(|| {
138                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'ecrRepository' cannot be null")
139                            })?,
140                        )),
141                        "iamRole" => Some(crate::types::Configuration::IamRole(
142                            crate::protocol_serde::shape_iam_role_configuration::de_iam_role_configuration(tokens)?.ok_or_else(|| {
143                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'iamRole' cannot be null")
144                            })?,
145                        )),
146                        "efsFileSystem" => Some(crate::types::Configuration::EfsFileSystem(
147                            crate::protocol_serde::shape_efs_file_system_configuration::de_efs_file_system_configuration(tokens)?.ok_or_else(
148                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'efsFileSystem' cannot be null"),
149                            )?,
150                        )),
151                        "kmsKey" => Some(crate::types::Configuration::KmsKey(
152                            crate::protocol_serde::shape_kms_key_configuration::de_kms_key_configuration(tokens)?.ok_or_else(|| {
153                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'kmsKey' cannot be null")
154                            })?,
155                        )),
156                        "rdsDbClusterSnapshot" => Some(crate::types::Configuration::RdsDbClusterSnapshot(
157                            crate::protocol_serde::shape_rds_db_cluster_snapshot_configuration::de_rds_db_cluster_snapshot_configuration(tokens)?
158                                .ok_or_else(|| {
159                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'rdsDbClusterSnapshot' cannot be null")
160                                })?,
161                        )),
162                        "rdsDbSnapshot" => Some(crate::types::Configuration::RdsDbSnapshot(
163                            crate::protocol_serde::shape_rds_db_snapshot_configuration::de_rds_db_snapshot_configuration(tokens)?.ok_or_else(
164                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'rdsDbSnapshot' cannot be null"),
165                            )?,
166                        )),
167                        "secretsManagerSecret" => Some(crate::types::Configuration::SecretsManagerSecret(
168                            crate::protocol_serde::shape_secrets_manager_secret_configuration::de_secrets_manager_secret_configuration(tokens)?
169                                .ok_or_else(|| {
170                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'secretsManagerSecret' cannot be null")
171                                })?,
172                        )),
173                        "s3Bucket" => Some(crate::types::Configuration::S3Bucket(
174                            crate::protocol_serde::shape_s3_bucket_configuration::de_s3_bucket_configuration(tokens)?.ok_or_else(|| {
175                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 's3Bucket' cannot be null")
176                            })?,
177                        )),
178                        "snsTopic" => Some(crate::types::Configuration::SnsTopic(
179                            crate::protocol_serde::shape_sns_topic_configuration::de_sns_topic_configuration(tokens)?.ok_or_else(|| {
180                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'snsTopic' cannot be null")
181                            })?,
182                        )),
183                        "sqsQueue" => Some(crate::types::Configuration::SqsQueue(
184                            crate::protocol_serde::shape_sqs_queue_configuration::de_sqs_queue_configuration(tokens)?.ok_or_else(|| {
185                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'sqsQueue' cannot be null")
186                            })?,
187                        )),
188                        "s3ExpressDirectoryBucket" => Some(crate::types::Configuration::S3ExpressDirectoryBucket(
189                            crate::protocol_serde::shape_s3_express_directory_bucket_configuration::de_s3_express_directory_bucket_configuration(
190                                tokens,
191                            )?
192                            .ok_or_else(|| {
193                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 's3ExpressDirectoryBucket' cannot be null")
194                            })?,
195                        )),
196                        "dynamodbStream" => Some(crate::types::Configuration::DynamodbStream(
197                            crate::protocol_serde::shape_dynamodb_stream_configuration::de_dynamodb_stream_configuration(tokens)?.ok_or_else(
198                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'dynamodbStream' cannot be null"),
199                            )?,
200                        )),
201                        "dynamodbTable" => Some(crate::types::Configuration::DynamodbTable(
202                            crate::protocol_serde::shape_dynamodb_table_configuration::de_dynamodb_table_configuration(tokens)?.ok_or_else(|| {
203                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'dynamodbTable' cannot be null")
204                            })?,
205                        )),
206                        _ => {
207                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
208                            Some(crate::types::Configuration::Unknown)
209                        }
210                    };
211                }
212                other => {
213                    return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
214                        "expected object key or end object, found: {:?}",
215                        other
216                    )))
217                }
218            }
219        },
220        _ => {
221            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
222                "expected start object or null",
223            ))
224        }
225    }
226    if variant.is_none() {
227        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
228            "Union did not contain a valid variant.",
229        ));
230    }
231    Ok(variant)
232}