aws_sdk_sagemaker/protocol_serde/
shape_update_hub.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_hub_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<crate::operation::update_hub::UpdateHubOutput, crate::operation::update_hub::UpdateHubError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::update_hub::UpdateHubError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::update_hub::UpdateHubError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "ResourceNotFound" => crate::operation::update_hub::UpdateHubError::ResourceNotFound({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::ResourceNotFoundBuilder::default();
25                output = crate::protocol_serde::shape_resource_not_found::de_resource_not_found_json_err(_response_body, output)
26                    .map_err(crate::operation::update_hub::UpdateHubError::unhandled)?;
27                let output = output.meta(generic);
28                output.build()
29            };
30            if tmp.message.is_none() {
31                tmp.message = _error_message;
32            }
33            tmp
34        }),
35        _ => crate::operation::update_hub::UpdateHubError::generic(generic),
36    })
37}
38
39#[allow(clippy::unnecessary_wraps)]
40pub fn de_update_hub_http_response(
41    _response_status: u16,
42    _response_headers: &::aws_smithy_runtime_api::http::Headers,
43    _response_body: &[u8],
44) -> std::result::Result<crate::operation::update_hub::UpdateHubOutput, crate::operation::update_hub::UpdateHubError> {
45    Ok({
46        #[allow(unused_mut)]
47        let mut output = crate::operation::update_hub::builders::UpdateHubOutputBuilder::default();
48        output = crate::protocol_serde::shape_update_hub::de_update_hub(_response_body, output)
49            .map_err(crate::operation::update_hub::UpdateHubError::unhandled)?;
50        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
51        crate::serde_util::update_hub_output_output_correct_errors(output).build()
52    })
53}
54
55pub fn ser_update_hub_input(
56    input: &crate::operation::update_hub::UpdateHubInput,
57) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
58    let mut out = String::new();
59    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
60    crate::protocol_serde::shape_update_hub_input::ser_update_hub_input_input(&mut object, input)?;
61    object.finish();
62    Ok(::aws_smithy_types::body::SdkBody::from(out))
63}
64
65pub(crate) fn de_update_hub(
66    value: &[u8],
67    mut builder: crate::operation::update_hub::builders::UpdateHubOutputBuilder,
68) -> ::std::result::Result<crate::operation::update_hub::builders::UpdateHubOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
69    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
70    let tokens = &mut tokens_owned;
71    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
72    loop {
73        match tokens.next().transpose()? {
74            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
75            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
76                "HubArn" => {
77                    builder = builder.set_hub_arn(
78                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
79                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
80                            .transpose()?,
81                    );
82                }
83                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
84            },
85            other => {
86                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
87                    "expected object key or end object, found: {:?}",
88                    other
89                )))
90            }
91        }
92    }
93    if tokens.next().is_some() {
94        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
95            "found more JSON tokens after completing parsing",
96        ));
97    }
98    Ok(builder)
99}