aws_sdk_dax/protocol_serde/
shape_decrease_replication_factor.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_decrease_replication_factor_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::decrease_replication_factor::DecreaseReplicationFactorOutput,
9    crate::operation::decrease_replication_factor::DecreaseReplicationFactorError,
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::decrease_replication_factor::DecreaseReplicationFactorError::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 => {
19            return Err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "ClusterNotFoundFault" => crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::ClusterNotFoundFault({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::ClusterNotFoundFaultBuilder::default();
32                output = crate::protocol_serde::shape_cluster_not_found_fault::de_cluster_not_found_fault_json_err(_response_body, output)
33                    .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::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        "InvalidClusterStateFault" => crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::InvalidClusterStateFault({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InvalidClusterStateFaultBuilder::default();
47                output = crate::protocol_serde::shape_invalid_cluster_state_fault::de_invalid_cluster_state_fault_json_err(_response_body, output)
48                    .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        "InvalidParameterCombinationException" => {
58            crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::InvalidParameterCombinationException({
59                #[allow(unused_mut)]
60                let mut tmp = {
61                    #[allow(unused_mut)]
62                    let mut output = crate::types::error::builders::InvalidParameterCombinationExceptionBuilder::default();
63                    output =
64                        crate::protocol_serde::shape_invalid_parameter_combination_exception::de_invalid_parameter_combination_exception_json_err(
65                            _response_body,
66                            output,
67                        )
68                        .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled)?;
69                    let output = output.meta(generic);
70                    output.build()
71                };
72                if tmp.message.is_none() {
73                    tmp.message = _error_message;
74                }
75                tmp
76            })
77        }
78        "InvalidParameterValueException" => {
79            crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::InvalidParameterValueException({
80                #[allow(unused_mut)]
81                let mut tmp = {
82                    #[allow(unused_mut)]
83                    let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
84                    output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
85                        _response_body,
86                        output,
87                    )
88                    .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled)?;
89                    let output = output.meta(generic);
90                    output.build()
91                };
92                if tmp.message.is_none() {
93                    tmp.message = _error_message;
94                }
95                tmp
96            })
97        }
98        "NodeNotFoundFault" => crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::NodeNotFoundFault({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::NodeNotFoundFaultBuilder::default();
103                output = crate::protocol_serde::shape_node_not_found_fault::de_node_not_found_fault_json_err(_response_body, output)
104                    .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::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        "ServiceLinkedRoleNotFoundFault" => {
114            crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::ServiceLinkedRoleNotFoundFault({
115                #[allow(unused_mut)]
116                let mut tmp = {
117                    #[allow(unused_mut)]
118                    let mut output = crate::types::error::builders::ServiceLinkedRoleNotFoundFaultBuilder::default();
119                    output = crate::protocol_serde::shape_service_linked_role_not_found_fault::de_service_linked_role_not_found_fault_json_err(
120                        _response_body,
121                        output,
122                    )
123                    .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled)?;
124                    let output = output.meta(generic);
125                    output.build()
126                };
127                if tmp.message.is_none() {
128                    tmp.message = _error_message;
129                }
130                tmp
131            })
132        }
133        _ => crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::generic(generic),
134    })
135}
136
137#[allow(clippy::unnecessary_wraps)]
138pub fn de_decrease_replication_factor_http_response(
139    _response_status: u16,
140    _response_headers: &::aws_smithy_runtime_api::http::Headers,
141    _response_body: &[u8],
142) -> std::result::Result<
143    crate::operation::decrease_replication_factor::DecreaseReplicationFactorOutput,
144    crate::operation::decrease_replication_factor::DecreaseReplicationFactorError,
145> {
146    Ok({
147        #[allow(unused_mut)]
148        let mut output = crate::operation::decrease_replication_factor::builders::DecreaseReplicationFactorOutputBuilder::default();
149        output = crate::protocol_serde::shape_decrease_replication_factor::de_decrease_replication_factor(_response_body, output)
150            .map_err(crate::operation::decrease_replication_factor::DecreaseReplicationFactorError::unhandled)?;
151        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
152        output.build()
153    })
154}
155
156pub fn ser_decrease_replication_factor_input(
157    input: &crate::operation::decrease_replication_factor::DecreaseReplicationFactorInput,
158) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
159    let mut out = String::new();
160    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
161    crate::protocol_serde::shape_decrease_replication_factor_input::ser_decrease_replication_factor_input_input(&mut object, input)?;
162    object.finish();
163    Ok(::aws_smithy_types::body::SdkBody::from(out))
164}
165
166pub(crate) fn de_decrease_replication_factor(
167    value: &[u8],
168    mut builder: crate::operation::decrease_replication_factor::builders::DecreaseReplicationFactorOutputBuilder,
169) -> ::std::result::Result<
170    crate::operation::decrease_replication_factor::builders::DecreaseReplicationFactorOutputBuilder,
171    ::aws_smithy_json::deserialize::error::DeserializeError,
172> {
173    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
174    let tokens = &mut tokens_owned;
175    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
176    loop {
177        match tokens.next().transpose()? {
178            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
179            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
180                "Cluster" => {
181                    builder = builder.set_cluster(crate::protocol_serde::shape_cluster::de_cluster(tokens)?);
182                }
183                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
184            },
185            other => {
186                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
187                    "expected object key or end object, found: {:?}",
188                    other
189                )))
190            }
191        }
192    }
193    if tokens.next().is_some() {
194        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
195            "found more JSON tokens after completing parsing",
196        ));
197    }
198    Ok(builder)
199}