aws_sdk_sagemaker/protocol_serde/
shape_batch_add_cluster_nodes.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_add_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_add_cluster_nodes::BatchAddClusterNodesOutput,
9 crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError,
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_add_cluster_nodes::BatchAddClusterNodesError::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_add_cluster_nodes::BatchAddClusterNodesError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ResourceLimitExceeded" => crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::ResourceLimitExceeded({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ResourceLimitExceededBuilder::default();
28 output = crate::protocol_serde::shape_resource_limit_exceeded::de_resource_limit_exceeded_json_err(_response_body, output)
29 .map_err(crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::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 "ResourceNotFound" => crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::ResourceNotFound({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::ResourceNotFoundBuilder::default();
43 output = crate::protocol_serde::shape_resource_not_found::de_resource_not_found_json_err(_response_body, output)
44 .map_err(crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::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 _ => crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::generic(generic),
54 })
55}
56
57#[allow(clippy::unnecessary_wraps)]
58pub fn de_batch_add_cluster_nodes_http_response(
59 _response_status: u16,
60 _response_headers: &::aws_smithy_runtime_api::http::Headers,
61 _response_body: &[u8],
62) -> std::result::Result<
63 crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesOutput,
64 crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError,
65> {
66 Ok({
67 #[allow(unused_mut)]
68 let mut output = crate::operation::batch_add_cluster_nodes::builders::BatchAddClusterNodesOutputBuilder::default();
69 output = crate::protocol_serde::shape_batch_add_cluster_nodes::de_batch_add_cluster_nodes(_response_body, output)
70 .map_err(crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::unhandled)?;
71 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
72 crate::serde_util::batch_add_cluster_nodes_output_output_correct_errors(output)
73 .build()
74 .map_err(crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesError::unhandled)?
75 })
76}
77
78pub fn ser_batch_add_cluster_nodes_input(
79 input: &crate::operation::batch_add_cluster_nodes::BatchAddClusterNodesInput,
80) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
81 let mut out = String::new();
82 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
83 crate::protocol_serde::shape_batch_add_cluster_nodes_input::ser_batch_add_cluster_nodes_input_input(&mut object, input)?;
84 object.finish();
85 Ok(::aws_smithy_types::body::SdkBody::from(out))
86}
87
88pub(crate) fn de_batch_add_cluster_nodes(
89 value: &[u8],
90 mut builder: crate::operation::batch_add_cluster_nodes::builders::BatchAddClusterNodesOutputBuilder,
91) -> ::std::result::Result<
92 crate::operation::batch_add_cluster_nodes::builders::BatchAddClusterNodesOutputBuilder,
93 ::aws_smithy_json::deserialize::error::DeserializeError,
94> {
95 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
96 let tokens = &mut tokens_owned;
97 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
98 loop {
99 match tokens.next().transpose()? {
100 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
101 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
102 "Successful" => {
103 builder = builder.set_successful(crate::protocol_serde::shape_node_addition_result_list::de_node_addition_result_list(
104 tokens,
105 )?);
106 }
107 "Failed" => {
108 builder = builder
109 .set_failed(crate::protocol_serde::shape_batch_add_cluster_nodes_error_list::de_batch_add_cluster_nodes_error_list(tokens)?);
110 }
111 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
112 },
113 other => {
114 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
115 "expected object key or end object, found: {:?}",
116 other
117 )))
118 }
119 }
120 }
121 if tokens.next().is_some() {
122 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
123 "found more JSON tokens after completing parsing",
124 ));
125 }
126 Ok(builder)
127}