aws_sdk_sagemaker/protocol_serde/
shape_batch_delete_cluster_nodes.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_delete_cluster_nodes_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_delete_cluster_nodes::BatchDeleteClusterNodesOutput,
9    crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError,
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_delete_cluster_nodes::BatchDeleteClusterNodesError::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::batch_delete_cluster_nodes::BatchDeleteClusterNodesError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "ResourceNotFound" => crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError::ResourceNotFound({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::ResourceNotFoundBuilder::default();
32                output = crate::protocol_serde::shape_resource_not_found::de_resource_not_found_json_err(_response_body, output)
33                    .map_err(crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError::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        _ => crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError::generic(generic),
43    })
44}
45
46#[allow(clippy::unnecessary_wraps)]
47pub fn de_batch_delete_cluster_nodes_http_response(
48    _response_status: u16,
49    _response_headers: &::aws_smithy_runtime_api::http::Headers,
50    _response_body: &[u8],
51) -> std::result::Result<
52    crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesOutput,
53    crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError,
54> {
55    Ok({
56        #[allow(unused_mut)]
57        let mut output = crate::operation::batch_delete_cluster_nodes::builders::BatchDeleteClusterNodesOutputBuilder::default();
58        output = crate::protocol_serde::shape_batch_delete_cluster_nodes::de_batch_delete_cluster_nodes(_response_body, output)
59            .map_err(crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesError::unhandled)?;
60        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
61        output.build()
62    })
63}
64
65pub fn ser_batch_delete_cluster_nodes_input(
66    input: &crate::operation::batch_delete_cluster_nodes::BatchDeleteClusterNodesInput,
67) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
68    let mut out = String::new();
69    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
70    crate::protocol_serde::shape_batch_delete_cluster_nodes_input::ser_batch_delete_cluster_nodes_input_input(&mut object, input)?;
71    object.finish();
72    Ok(::aws_smithy_types::body::SdkBody::from(out))
73}
74
75pub(crate) fn de_batch_delete_cluster_nodes(
76    value: &[u8],
77    mut builder: crate::operation::batch_delete_cluster_nodes::builders::BatchDeleteClusterNodesOutputBuilder,
78) -> ::std::result::Result<
79    crate::operation::batch_delete_cluster_nodes::builders::BatchDeleteClusterNodesOutputBuilder,
80    ::aws_smithy_json::deserialize::error::DeserializeError,
81> {
82    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
83    let tokens = &mut tokens_owned;
84    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
85    loop {
86        match tokens.next().transpose()? {
87            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
88            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
89                "Failed" => {
90                    builder = builder.set_failed(
91                        crate::protocol_serde::shape_batch_delete_cluster_nodes_error_list::de_batch_delete_cluster_nodes_error_list(tokens)?,
92                    );
93                }
94                "Successful" => {
95                    builder = builder.set_successful(crate::protocol_serde::shape_cluster_node_ids::de_cluster_node_ids(tokens)?);
96                }
97                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
98            },
99            other => {
100                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
101                    "expected object key or end object, found: {:?}",
102                    other
103                )))
104            }
105        }
106    }
107    if tokens.next().is_some() {
108        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
109            "found more JSON tokens after completing parsing",
110        ));
111    }
112    Ok(builder)
113}