aws_sdk_kms/protocol_serde/
shape_key_metadata.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_key_metadata<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> Result<Option<crate::types::KeyMetadata>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::KeyMetadataBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "AWSAccountId" => {
18                            builder = builder.set_aws_account_id(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "KeyId" => {
25                            builder = builder.set_key_id(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
28                                    .transpose()?,
29                            );
30                        }
31                        "Arn" => {
32                            builder = builder.set_arn(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "CreationDate" => {
39                            builder = builder.set_creation_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
40                                tokens.next(),
41                                ::aws_smithy_types::date_time::Format::EpochSeconds,
42                            )?);
43                        }
44                        "Enabled" => {
45                            builder = builder.set_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
46                        }
47                        "Description" => {
48                            builder = builder.set_description(
49                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
50                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
51                                    .transpose()?,
52                            );
53                        }
54                        "KeyUsage" => {
55                            builder = builder.set_key_usage(
56                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
57                                    .map(|s| s.to_unescaped().map(|u| crate::types::KeyUsageType::from(u.as_ref())))
58                                    .transpose()?,
59                            );
60                        }
61                        "KeyState" => {
62                            builder = builder.set_key_state(
63                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
64                                    .map(|s| s.to_unescaped().map(|u| crate::types::KeyState::from(u.as_ref())))
65                                    .transpose()?,
66                            );
67                        }
68                        "DeletionDate" => {
69                            builder = builder.set_deletion_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
70                                tokens.next(),
71                                ::aws_smithy_types::date_time::Format::EpochSeconds,
72                            )?);
73                        }
74                        "ValidTo" => {
75                            builder = builder.set_valid_to(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
76                                tokens.next(),
77                                ::aws_smithy_types::date_time::Format::EpochSeconds,
78                            )?);
79                        }
80                        "Origin" => {
81                            builder = builder.set_origin(
82                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
83                                    .map(|s| s.to_unescaped().map(|u| crate::types::OriginType::from(u.as_ref())))
84                                    .transpose()?,
85                            );
86                        }
87                        "CustomKeyStoreId" => {
88                            builder = builder.set_custom_key_store_id(
89                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
90                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
91                                    .transpose()?,
92                            );
93                        }
94                        "CloudHsmClusterId" => {
95                            builder = builder.set_cloud_hsm_cluster_id(
96                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
97                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
98                                    .transpose()?,
99                            );
100                        }
101                        "ExpirationModel" => {
102                            builder = builder.set_expiration_model(
103                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
104                                    .map(|s| s.to_unescaped().map(|u| crate::types::ExpirationModelType::from(u.as_ref())))
105                                    .transpose()?,
106                            );
107                        }
108                        "KeyManager" => {
109                            builder = builder.set_key_manager(
110                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
111                                    .map(|s| s.to_unescaped().map(|u| crate::types::KeyManagerType::from(u.as_ref())))
112                                    .transpose()?,
113                            );
114                        }
115                        "CustomerMasterKeySpec" => {
116                            builder = builder.set_customer_master_key_spec(
117                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
118                                    .map(|s| s.to_unescaped().map(|u| crate::types::CustomerMasterKeySpec::from(u.as_ref())))
119                                    .transpose()?,
120                            );
121                        }
122                        "KeySpec" => {
123                            builder = builder.set_key_spec(
124                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
125                                    .map(|s| s.to_unescaped().map(|u| crate::types::KeySpec::from(u.as_ref())))
126                                    .transpose()?,
127                            );
128                        }
129                        "EncryptionAlgorithms" => {
130                            builder = builder.set_encryption_algorithms(
131                                crate::protocol_serde::shape_encryption_algorithm_spec_list::de_encryption_algorithm_spec_list(tokens)?,
132                            );
133                        }
134                        "SigningAlgorithms" => {
135                            builder = builder.set_signing_algorithms(
136                                crate::protocol_serde::shape_signing_algorithm_spec_list::de_signing_algorithm_spec_list(tokens)?,
137                            );
138                        }
139                        "KeyAgreementAlgorithms" => {
140                            builder = builder.set_key_agreement_algorithms(
141                                crate::protocol_serde::shape_key_agreement_algorithm_spec_list::de_key_agreement_algorithm_spec_list(tokens)?,
142                            );
143                        }
144                        "MultiRegion" => {
145                            builder = builder.set_multi_region(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
146                        }
147                        "MultiRegionConfiguration" => {
148                            builder = builder.set_multi_region_configuration(
149                                crate::protocol_serde::shape_multi_region_configuration::de_multi_region_configuration(tokens)?,
150                            );
151                        }
152                        "PendingDeletionWindowInDays" => {
153                            builder = builder.set_pending_deletion_window_in_days(
154                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
155                                    .map(i32::try_from)
156                                    .transpose()?,
157                            );
158                        }
159                        "MacAlgorithms" => {
160                            builder =
161                                builder.set_mac_algorithms(crate::protocol_serde::shape_mac_algorithm_spec_list::de_mac_algorithm_spec_list(tokens)?);
162                        }
163                        "XksKeyConfiguration" => {
164                            builder = builder.set_xks_key_configuration(
165                                crate::protocol_serde::shape_xks_key_configuration_type::de_xks_key_configuration_type(tokens)?,
166                            );
167                        }
168                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
169                    },
170                    other => {
171                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
172                            "expected object key or end object, found: {:?}",
173                            other
174                        )))
175                    }
176                }
177            }
178            Ok(Some(crate::serde_util::key_metadata_correct_errors(builder).build().map_err(|err| {
179                ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
180            })?))
181        }
182        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
183            "expected start object or null",
184        )),
185    }
186}