aws_sdk_accessanalyzer/protocol_serde/
shape_get_archive_rule.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_archive_rule_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::get_archive_rule::GetArchiveRuleOutput, crate::operation::get_archive_rule::GetArchiveRuleError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "AccessDeniedException" => crate::operation::get_archive_rule::GetArchiveRuleError::AccessDeniedException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
27                let output = output.meta(generic);
28                crate::serde_util::access_denied_exception_correct_errors(output)
29                    .build()
30                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?
31            };
32            tmp
33        }),
34        "InternalServerException" => crate::operation::get_archive_rule::GetArchiveRuleError::InternalServerException({
35            #[allow(unused_mut)]
36            let mut tmp = {
37                #[allow(unused_mut)]
38                let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
39                output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
40                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
41                output = output.set_retry_after_seconds(
42                    crate::protocol_serde::shape_internal_server_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
43                        crate::operation::get_archive_rule::GetArchiveRuleError::unhandled(
44                            "Failed to parse retryAfterSeconds from header `Retry-After",
45                        )
46                    })?,
47                );
48                let output = output.meta(generic);
49                crate::serde_util::internal_server_exception_correct_errors(output)
50                    .build()
51                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?
52            };
53            tmp
54        }),
55        "ResourceNotFoundException" => crate::operation::get_archive_rule::GetArchiveRuleError::ResourceNotFoundException({
56            #[allow(unused_mut)]
57            let mut tmp = {
58                #[allow(unused_mut)]
59                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
60                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
61                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
62                let output = output.meta(generic);
63                crate::serde_util::resource_not_found_exception_correct_errors(output)
64                    .build()
65                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?
66            };
67            tmp
68        }),
69        "ThrottlingException" => crate::operation::get_archive_rule::GetArchiveRuleError::ThrottlingException({
70            #[allow(unused_mut)]
71            let mut tmp = {
72                #[allow(unused_mut)]
73                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
74                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
75                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
76                output = output.set_retry_after_seconds(
77                    crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
78                        crate::operation::get_archive_rule::GetArchiveRuleError::unhandled(
79                            "Failed to parse retryAfterSeconds from header `Retry-After",
80                        )
81                    })?,
82                );
83                let output = output.meta(generic);
84                crate::serde_util::throttling_exception_correct_errors(output)
85                    .build()
86                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?
87            };
88            tmp
89        }),
90        "ValidationException" => crate::operation::get_archive_rule::GetArchiveRuleError::ValidationException({
91            #[allow(unused_mut)]
92            let mut tmp = {
93                #[allow(unused_mut)]
94                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
95                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
96                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
97                let output = output.meta(generic);
98                crate::serde_util::validation_exception_correct_errors(output)
99                    .build()
100                    .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?
101            };
102            tmp
103        }),
104        _ => crate::operation::get_archive_rule::GetArchiveRuleError::generic(generic),
105    })
106}
107
108#[allow(clippy::unnecessary_wraps)]
109pub fn de_get_archive_rule_http_response(
110    _response_status: u16,
111    _response_headers: &::aws_smithy_runtime_api::http::Headers,
112    _response_body: &[u8],
113) -> std::result::Result<crate::operation::get_archive_rule::GetArchiveRuleOutput, crate::operation::get_archive_rule::GetArchiveRuleError> {
114    Ok({
115        #[allow(unused_mut)]
116        let mut output = crate::operation::get_archive_rule::builders::GetArchiveRuleOutputBuilder::default();
117        output = crate::protocol_serde::shape_get_archive_rule::de_get_archive_rule(_response_body, output)
118            .map_err(crate::operation::get_archive_rule::GetArchiveRuleError::unhandled)?;
119        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
120        crate::serde_util::get_archive_rule_output_output_correct_errors(output).build()
121    })
122}
123
124pub(crate) fn de_get_archive_rule(
125    value: &[u8],
126    mut builder: crate::operation::get_archive_rule::builders::GetArchiveRuleOutputBuilder,
127) -> ::std::result::Result<
128    crate::operation::get_archive_rule::builders::GetArchiveRuleOutputBuilder,
129    ::aws_smithy_json::deserialize::error::DeserializeError,
130> {
131    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
132    let tokens = &mut tokens_owned;
133    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
134    loop {
135        match tokens.next().transpose()? {
136            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
137            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
138                "archiveRule" => {
139                    builder = builder.set_archive_rule(crate::protocol_serde::shape_archive_rule_summary::de_archive_rule_summary(tokens)?);
140                }
141                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
142            },
143            other => {
144                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
145                    "expected object key or end object, found: {:?}",
146                    other
147                )))
148            }
149        }
150    }
151    if tokens.next().is_some() {
152        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
153            "found more JSON tokens after completing parsing",
154        ));
155    }
156    Ok(builder)
157}