aws_sdk_wafv2/protocol_serde/
shape_sampled_http_request.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_sampled_http_request<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::SampledHttpRequest>, ::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::SampledHttpRequestBuilder::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                        "Request" => {
18                            builder = builder.set_request(crate::protocol_serde::shape_http_request::de_http_request(tokens)?);
19                        }
20                        "Weight" => {
21                            builder = builder.set_weight(
22                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
23                                    .map(i64::try_from)
24                                    .transpose()?,
25                            );
26                        }
27                        "Timestamp" => {
28                            builder = builder.set_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
29                                tokens.next(),
30                                ::aws_smithy_types::date_time::Format::EpochSeconds,
31                            )?);
32                        }
33                        "Action" => {
34                            builder = builder.set_action(
35                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
36                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
37                                    .transpose()?,
38                            );
39                        }
40                        "RuleNameWithinRuleGroup" => {
41                            builder = builder.set_rule_name_within_rule_group(
42                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
43                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
44                                    .transpose()?,
45                            );
46                        }
47                        "RequestHeadersInserted" => {
48                            builder = builder.set_request_headers_inserted(crate::protocol_serde::shape_http_headers::de_http_headers(tokens)?);
49                        }
50                        "ResponseCodeSent" => {
51                            builder = builder.set_response_code_sent(
52                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
53                                    .map(i32::try_from)
54                                    .transpose()?,
55                            );
56                        }
57                        "Labels" => {
58                            builder = builder.set_labels(crate::protocol_serde::shape_labels::de_labels(tokens)?);
59                        }
60                        "CaptchaResponse" => {
61                            builder = builder.set_captcha_response(crate::protocol_serde::shape_captcha_response::de_captcha_response(tokens)?);
62                        }
63                        "ChallengeResponse" => {
64                            builder = builder.set_challenge_response(crate::protocol_serde::shape_challenge_response::de_challenge_response(tokens)?);
65                        }
66                        "OverriddenAction" => {
67                            builder = builder.set_overridden_action(
68                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
69                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
70                                    .transpose()?,
71                            );
72                        }
73                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
74                    },
75                    other => {
76                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
77                            "expected object key or end object, found: {:?}",
78                            other
79                        )))
80                    }
81                }
82            }
83            Ok(Some(crate::serde_util::sampled_http_request_correct_errors(builder).build()))
84        }
85        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
86            "expected start object or null",
87        )),
88    }
89}