aws_sdk_accessanalyzer/protocol_serde/
shape_analyzed_resource.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_analyzed_resource<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::AnalyzedResource>, ::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::AnalyzedResourceBuilder::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                        "resourceArn" => {
18                            builder = builder.set_resource_arn(
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                        "resourceType" => {
25                            builder = builder.set_resource_type(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| crate::types::ResourceType::from(u.as_ref())))
28                                    .transpose()?,
29                            );
30                        }
31                        "createdAt" => {
32                            builder = builder.set_created_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
33                                tokens.next(),
34                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
35                            )?);
36                        }
37                        "analyzedAt" => {
38                            builder = builder.set_analyzed_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
39                                tokens.next(),
40                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
41                            )?);
42                        }
43                        "updatedAt" => {
44                            builder = builder.set_updated_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
45                                tokens.next(),
46                                ::aws_smithy_types::date_time::Format::DateTimeWithOffset,
47                            )?);
48                        }
49                        "isPublic" => {
50                            builder = builder.set_is_public(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
51                        }
52                        "actions" => {
53                            builder = builder.set_actions(crate::protocol_serde::shape_action_list::de_action_list(tokens)?);
54                        }
55                        "sharedVia" => {
56                            builder = builder.set_shared_via(crate::protocol_serde::shape_shared_via_list::de_shared_via_list(tokens)?);
57                        }
58                        "status" => {
59                            builder = builder.set_status(
60                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
61                                    .map(|s| s.to_unescaped().map(|u| crate::types::FindingStatus::from(u.as_ref())))
62                                    .transpose()?,
63                            );
64                        }
65                        "resourceOwnerAccount" => {
66                            builder = builder.set_resource_owner_account(
67                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
68                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
69                                    .transpose()?,
70                            );
71                        }
72                        "error" => {
73                            builder = builder.set_error(
74                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
75                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
76                                    .transpose()?,
77                            );
78                        }
79                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
80                    },
81                    other => {
82                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
83                            "expected object key or end object, found: {:?}",
84                            other
85                        )))
86                    }
87                }
88            }
89            Ok(Some(crate::serde_util::analyzed_resource_correct_errors(builder).build().map_err(
90                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
91            )?))
92        }
93        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
94            "expected start object or null",
95        )),
96    }
97}