aws_sdk_secretsmanager/protocol_serde/
shape_batch_get_secret_value.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_get_secret_value_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::batch_get_secret_value::BatchGetSecretValueOutput,
9    crate::operation::batch_get_secret_value::BatchGetSecretValueError,
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::batch_get_secret_value::BatchGetSecretValueError::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::batch_get_secret_value::BatchGetSecretValueError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "DecryptionFailure" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::DecryptionFailure({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::DecryptionFailureBuilder::default();
28                output = crate::protocol_serde::shape_decryption_failure::de_decryption_failure_json_err(_response_body, output)
29                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "InternalServiceError" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::InternalServiceError({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InternalServiceErrorBuilder::default();
43                output = crate::protocol_serde::shape_internal_service_error::de_internal_service_error_json_err(_response_body, output)
44                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "InvalidNextTokenException" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::InvalidNextTokenException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::InvalidNextTokenExceptionBuilder::default();
58                output = crate::protocol_serde::shape_invalid_next_token_exception::de_invalid_next_token_exception_json_err(_response_body, output)
59                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
60                let output = output.meta(generic);
61                output.build()
62            };
63            if tmp.message.is_none() {
64                tmp.message = _error_message;
65            }
66            tmp
67        }),
68        "InvalidParameterException" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::InvalidParameterException({
69            #[allow(unused_mut)]
70            let mut tmp = {
71                #[allow(unused_mut)]
72                let mut output = crate::types::error::builders::InvalidParameterExceptionBuilder::default();
73                output = crate::protocol_serde::shape_invalid_parameter_exception::de_invalid_parameter_exception_json_err(_response_body, output)
74                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
75                let output = output.meta(generic);
76                output.build()
77            };
78            if tmp.message.is_none() {
79                tmp.message = _error_message;
80            }
81            tmp
82        }),
83        "InvalidRequestException" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::InvalidRequestException({
84            #[allow(unused_mut)]
85            let mut tmp = {
86                #[allow(unused_mut)]
87                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
88                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
89                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::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        "ResourceNotFoundException" => crate::operation::batch_get_secret_value::BatchGetSecretValueError::ResourceNotFoundException({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
103                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
104                    .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
105                let output = output.meta(generic);
106                output.build()
107            };
108            if tmp.message.is_none() {
109                tmp.message = _error_message;
110            }
111            tmp
112        }),
113        _ => crate::operation::batch_get_secret_value::BatchGetSecretValueError::generic(generic),
114    })
115}
116
117#[allow(clippy::unnecessary_wraps)]
118pub fn de_batch_get_secret_value_http_response(
119    _response_status: u16,
120    _response_headers: &::aws_smithy_runtime_api::http::Headers,
121    _response_body: &[u8],
122) -> std::result::Result<
123    crate::operation::batch_get_secret_value::BatchGetSecretValueOutput,
124    crate::operation::batch_get_secret_value::BatchGetSecretValueError,
125> {
126    Ok({
127        #[allow(unused_mut)]
128        let mut output = crate::operation::batch_get_secret_value::builders::BatchGetSecretValueOutputBuilder::default();
129        output = crate::protocol_serde::shape_batch_get_secret_value::de_batch_get_secret_value(_response_body, output)
130            .map_err(crate::operation::batch_get_secret_value::BatchGetSecretValueError::unhandled)?;
131        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
132        output.build()
133    })
134}
135
136pub fn ser_batch_get_secret_value_input(
137    input: &crate::operation::batch_get_secret_value::BatchGetSecretValueInput,
138) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
139    let mut out = String::new();
140    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
141    crate::protocol_serde::shape_batch_get_secret_value_input::ser_batch_get_secret_value_input_input(&mut object, input)?;
142    object.finish();
143    Ok(::aws_smithy_types::body::SdkBody::from(out))
144}
145
146pub(crate) fn de_batch_get_secret_value(
147    value: &[u8],
148    mut builder: crate::operation::batch_get_secret_value::builders::BatchGetSecretValueOutputBuilder,
149) -> ::std::result::Result<
150    crate::operation::batch_get_secret_value::builders::BatchGetSecretValueOutputBuilder,
151    ::aws_smithy_json::deserialize::error::DeserializeError,
152> {
153    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
154    let tokens = &mut tokens_owned;
155    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
156    loop {
157        match tokens.next().transpose()? {
158            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
159            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
160                "SecretValues" => {
161                    builder = builder.set_secret_values(crate::protocol_serde::shape_secret_values_type::de_secret_values_type(tokens)?);
162                }
163                "NextToken" => {
164                    builder = builder.set_next_token(
165                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
166                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
167                            .transpose()?,
168                    );
169                }
170                "Errors" => {
171                    builder = builder.set_errors(crate::protocol_serde::shape_api_error_list_type::de_api_error_list_type(tokens)?);
172                }
173                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
174            },
175            other => {
176                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
177                    "expected object key or end object, found: {other:?}"
178                )))
179            }
180        }
181    }
182    if tokens.next().is_some() {
183        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
184            "found more JSON tokens after completing parsing",
185        ));
186    }
187    Ok(builder)
188}