aws_sdk_accessanalyzer/protocol_serde/
shape_finding.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_finding<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::Finding>, ::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::FindingBuilder::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                        "id" => {
18                            builder = builder.set_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                        "principal" => {
25                            builder = builder.set_principal(crate::protocol_serde::shape_principal_map::de_principal_map(tokens)?);
26                        }
27                        "action" => {
28                            builder = builder.set_action(crate::protocol_serde::shape_action_list::de_action_list(tokens)?);
29                        }
30                        "resource" => {
31                            builder = builder.set_resource(
32                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
33                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
34                                    .transpose()?,
35                            );
36                        }
37                        "isPublic" => {
38                            builder = builder.set_is_public(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
39                        }
40                        "resourceType" => {
41                            builder = builder.set_resource_type(
42                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
43                                    .map(|s| s.to_unescaped().map(|u| crate::types::ResourceType::from(u.as_ref())))
44                                    .transpose()?,
45                            );
46                        }
47                        "condition" => {
48                            builder = builder.set_condition(crate::protocol_serde::shape_condition_key_map::de_condition_key_map(tokens)?);
49                        }
50                        "createdAt" => {
51                            builder = builder.set_created_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
52                                tokens.next(),
53                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
54                            )?);
55                        }
56                        "analyzedAt" => {
57                            builder = builder.set_analyzed_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
58                                tokens.next(),
59                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
60                            )?);
61                        }
62                        "updatedAt" => {
63                            builder = builder.set_updated_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
64                                tokens.next(),
65                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
66                            )?);
67                        }
68                        "status" => {
69                            builder = builder.set_status(
70                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
71                                    .map(|s| s.to_unescaped().map(|u| crate::types::FindingStatus::from(u.as_ref())))
72                                    .transpose()?,
73                            );
74                        }
75                        "resourceOwnerAccount" => {
76                            builder = builder.set_resource_owner_account(
77                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
78                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
79                                    .transpose()?,
80                            );
81                        }
82                        "error" => {
83                            builder = builder.set_error(
84                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
85                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
86                                    .transpose()?,
87                            );
88                        }
89                        "sources" => {
90                            builder = builder.set_sources(crate::protocol_serde::shape_finding_source_list::de_finding_source_list(tokens)?);
91                        }
92                        "resourceControlPolicyRestriction" => {
93                            builder = builder.set_resource_control_policy_restriction(
94                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
95                                    .map(|s| s.to_unescaped().map(|u| crate::types::ResourceControlPolicyRestriction::from(u.as_ref())))
96                                    .transpose()?,
97                            );
98                        }
99                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
100                    },
101                    other => {
102                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
103                            "expected object key or end object, found: {:?}",
104                            other
105                        )))
106                    }
107                }
108            }
109            Ok(Some(crate::serde_util::finding_correct_errors(builder).build().map_err(|err| {
110                ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
111            })?))
112        }
113        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
114            "expected start object or null",
115        )),
116    }
117}