aws_sdk_sagemaker/protocol_serde/
shape_create_workforce.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_workforce_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::create_workforce::CreateWorkforceOutput, crate::operation::create_workforce::CreateWorkforceError> {
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::create_workforce::CreateWorkforceError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    Err(crate::operation::create_workforce::CreateWorkforceError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_create_workforce_http_response(
18    _response_status: u16,
19    _response_headers: &::aws_smithy_runtime_api::http::Headers,
20    _response_body: &[u8],
21) -> std::result::Result<crate::operation::create_workforce::CreateWorkforceOutput, crate::operation::create_workforce::CreateWorkforceError> {
22    Ok({
23        #[allow(unused_mut)]
24        let mut output = crate::operation::create_workforce::builders::CreateWorkforceOutputBuilder::default();
25        output = crate::protocol_serde::shape_create_workforce::de_create_workforce(_response_body, output)
26            .map_err(crate::operation::create_workforce::CreateWorkforceError::unhandled)?;
27        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
28        crate::serde_util::create_workforce_output_output_correct_errors(output).build()
29    })
30}
31
32pub fn ser_create_workforce_input(
33    input: &crate::operation::create_workforce::CreateWorkforceInput,
34) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
35    let mut out = String::new();
36    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
37    crate::protocol_serde::shape_create_workforce_input::ser_create_workforce_input_input(&mut object, input)?;
38    object.finish();
39    Ok(::aws_smithy_types::body::SdkBody::from(out))
40}
41
42pub(crate) fn de_create_workforce(
43    value: &[u8],
44    mut builder: crate::operation::create_workforce::builders::CreateWorkforceOutputBuilder,
45) -> ::std::result::Result<
46    crate::operation::create_workforce::builders::CreateWorkforceOutputBuilder,
47    ::aws_smithy_json::deserialize::error::DeserializeError,
48> {
49    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
50    let tokens = &mut tokens_owned;
51    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
52    loop {
53        match tokens.next().transpose()? {
54            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
55            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
56                "WorkforceArn" => {
57                    builder = builder.set_workforce_arn(
58                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60                            .transpose()?,
61                    );
62                }
63                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
64            },
65            other => {
66                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
67                    "expected object key or end object, found: {:?}",
68                    other
69                )))
70            }
71        }
72    }
73    if tokens.next().is_some() {
74        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
75            "found more JSON tokens after completing parsing",
76        ));
77    }
78    Ok(builder)
79}