aws_sdk_appsync/protocol_serde/
shape_lambda_authorizer_config.rs1pub fn ser_lambda_authorizer_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::LambdaAuthorizerConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if input.authorizer_result_ttl_in_seconds != 0 {
7 object.key("authorizerResultTtlInSeconds").number(
8 #[allow(clippy::useless_conversion)]
9 ::aws_smithy_types::Number::NegInt((input.authorizer_result_ttl_in_seconds).into()),
10 );
11 }
12 {
13 object.key("authorizerUri").string(input.authorizer_uri.as_str());
14 }
15 if let Some(var_1) = &input.identity_validation_expression {
16 object.key("identityValidationExpression").string(var_1.as_str());
17 }
18 Ok(())
19}
20
21pub(crate) fn de_lambda_authorizer_config<'a, I>(
22 tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::LambdaAuthorizerConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
24where
25 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
26{
27 match tokens.next().transpose()? {
28 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
29 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
30 #[allow(unused_mut)]
31 let mut builder = crate::types::builders::LambdaAuthorizerConfigBuilder::default();
32 loop {
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
35 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
36 "authorizerResultTtlInSeconds" => {
37 builder = builder.set_authorizer_result_ttl_in_seconds(
38 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
39 .map(i32::try_from)
40 .transpose()?,
41 );
42 }
43 "authorizerUri" => {
44 builder = builder.set_authorizer_uri(
45 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
46 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
47 .transpose()?,
48 );
49 }
50 "identityValidationExpression" => {
51 builder = builder.set_identity_validation_expression(
52 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
53 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
54 .transpose()?,
55 );
56 }
57 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
58 },
59 other => {
60 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
61 "expected object key or end object, found: {:?}",
62 other
63 )))
64 }
65 }
66 }
67 Ok(Some(
68 crate::serde_util::lambda_authorizer_config_correct_errors(builder)
69 .build()
70 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
71 ))
72 }
73 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
74 "expected start object or null",
75 )),
76 }
77}