aws_sdk_backup/protocol_serde/
shape_get_recovery_point_index_details.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_recovery_point_index_details_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsOutput,
9    crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => return Err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "InvalidParameterValueException" => {
24            crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::InvalidParameterValueException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
30                        _response_body,
31                        output,
32                    )
33                    .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
34                    let output = output.meta(generic);
35                    output.build()
36                };
37                if tmp.message.is_none() {
38                    tmp.message = _error_message;
39                }
40                tmp
41            })
42        }
43        "MissingParameterValueException" => {
44            crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::MissingParameterValueException({
45                #[allow(unused_mut)]
46                let mut tmp = {
47                    #[allow(unused_mut)]
48                    let mut output = crate::types::error::builders::MissingParameterValueExceptionBuilder::default();
49                    output = crate::protocol_serde::shape_missing_parameter_value_exception::de_missing_parameter_value_exception_json_err(
50                        _response_body,
51                        output,
52                    )
53                    .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
54                    let output = output.meta(generic);
55                    output.build()
56                };
57                if tmp.message.is_none() {
58                    tmp.message = _error_message;
59                }
60                tmp
61            })
62        }
63        "ResourceNotFoundException" => {
64            crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::ResourceNotFoundException({
65                #[allow(unused_mut)]
66                let mut tmp = {
67                    #[allow(unused_mut)]
68                    let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
69                    output =
70                        crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
71                            .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
72                    let output = output.meta(generic);
73                    output.build()
74                };
75                if tmp.message.is_none() {
76                    tmp.message = _error_message;
77                }
78                tmp
79            })
80        }
81        "ServiceUnavailableException" => {
82            crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::ServiceUnavailableException({
83                #[allow(unused_mut)]
84                let mut tmp = {
85                    #[allow(unused_mut)]
86                    let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
87                    output =
88                        crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
89                            .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
90                    let output = output.meta(generic);
91                    output.build()
92                };
93                if tmp.message.is_none() {
94                    tmp.message = _error_message;
95                }
96                tmp
97            })
98        }
99        _ => crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::generic(generic),
100    })
101}
102
103#[allow(clippy::unnecessary_wraps)]
104pub fn de_get_recovery_point_index_details_http_response(
105    _response_status: u16,
106    _response_headers: &::aws_smithy_runtime_api::http::Headers,
107    _response_body: &[u8],
108) -> std::result::Result<
109    crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsOutput,
110    crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError,
111> {
112    Ok({
113        #[allow(unused_mut)]
114        let mut output = crate::operation::get_recovery_point_index_details::builders::GetRecoveryPointIndexDetailsOutputBuilder::default();
115        output = crate::protocol_serde::shape_get_recovery_point_index_details::de_get_recovery_point_index_details(_response_body, output)
116            .map_err(crate::operation::get_recovery_point_index_details::GetRecoveryPointIndexDetailsError::unhandled)?;
117        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
118        output.build()
119    })
120}
121
122pub(crate) fn de_get_recovery_point_index_details(
123    value: &[u8],
124    mut builder: crate::operation::get_recovery_point_index_details::builders::GetRecoveryPointIndexDetailsOutputBuilder,
125) -> ::std::result::Result<
126    crate::operation::get_recovery_point_index_details::builders::GetRecoveryPointIndexDetailsOutputBuilder,
127    ::aws_smithy_json::deserialize::error::DeserializeError,
128> {
129    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
130    let tokens = &mut tokens_owned;
131    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
132    loop {
133        match tokens.next().transpose()? {
134            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
135            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
136                "BackupVaultArn" => {
137                    builder = builder.set_backup_vault_arn(
138                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
139                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
140                            .transpose()?,
141                    );
142                }
143                "IndexCompletionDate" => {
144                    builder = builder.set_index_completion_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
145                        tokens.next(),
146                        ::aws_smithy_types::date_time::Format::EpochSeconds,
147                    )?);
148                }
149                "IndexCreationDate" => {
150                    builder = builder.set_index_creation_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
151                        tokens.next(),
152                        ::aws_smithy_types::date_time::Format::EpochSeconds,
153                    )?);
154                }
155                "IndexDeletionDate" => {
156                    builder = builder.set_index_deletion_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
157                        tokens.next(),
158                        ::aws_smithy_types::date_time::Format::EpochSeconds,
159                    )?);
160                }
161                "IndexStatus" => {
162                    builder = builder.set_index_status(
163                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
164                            .map(|s| s.to_unescaped().map(|u| crate::types::IndexStatus::from(u.as_ref())))
165                            .transpose()?,
166                    );
167                }
168                "IndexStatusMessage" => {
169                    builder = builder.set_index_status_message(
170                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
171                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
172                            .transpose()?,
173                    );
174                }
175                "RecoveryPointArn" => {
176                    builder = builder.set_recovery_point_arn(
177                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
178                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
179                            .transpose()?,
180                    );
181                }
182                "SourceResourceArn" => {
183                    builder = builder.set_source_resource_arn(
184                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
185                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
186                            .transpose()?,
187                    );
188                }
189                "TotalItemsIndexed" => {
190                    builder = builder.set_total_items_indexed(
191                        ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
192                            .map(i64::try_from)
193                            .transpose()?,
194                    );
195                }
196                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
197            },
198            other => {
199                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
200                    "expected object key or end object, found: {:?}",
201                    other
202                )))
203            }
204        }
205    }
206    if tokens.next().is_some() {
207        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
208            "found more JSON tokens after completing parsing",
209        ));
210    }
211    Ok(builder)
212}