aws_sdk_sagemaker/protocol_serde/
shape_describe_algorithm.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_algorithm_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::describe_algorithm::DescribeAlgorithmOutput, crate::operation::describe_algorithm::DescribeAlgorithmError>
8{
9 #[allow(unused_mut)]
10 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11 .map_err(crate::operation::describe_algorithm::DescribeAlgorithmError::unhandled)?;
12 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13 let generic = generic_builder.build();
14 Err(crate::operation::describe_algorithm::DescribeAlgorithmError::generic(generic))
15}
16
17#[allow(clippy::unnecessary_wraps)]
18pub fn de_describe_algorithm_http_response(
19 _response_status: u16,
20 _response_headers: &::aws_smithy_runtime_api::http::Headers,
21 _response_body: &[u8],
22) -> std::result::Result<crate::operation::describe_algorithm::DescribeAlgorithmOutput, crate::operation::describe_algorithm::DescribeAlgorithmError>
23{
24 Ok({
25 #[allow(unused_mut)]
26 let mut output = crate::operation::describe_algorithm::builders::DescribeAlgorithmOutputBuilder::default();
27 output = crate::protocol_serde::shape_describe_algorithm::de_describe_algorithm(_response_body, output)
28 .map_err(crate::operation::describe_algorithm::DescribeAlgorithmError::unhandled)?;
29 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
30 crate::serde_util::describe_algorithm_output_output_correct_errors(output).build()
31 })
32}
33
34pub fn ser_describe_algorithm_input(
35 input: &crate::operation::describe_algorithm::DescribeAlgorithmInput,
36) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
37 let mut out = String::new();
38 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
39 crate::protocol_serde::shape_describe_algorithm_input::ser_describe_algorithm_input_input(&mut object, input)?;
40 object.finish();
41 Ok(::aws_smithy_types::body::SdkBody::from(out))
42}
43
44pub(crate) fn de_describe_algorithm(
45 value: &[u8],
46 mut builder: crate::operation::describe_algorithm::builders::DescribeAlgorithmOutputBuilder,
47) -> ::std::result::Result<
48 crate::operation::describe_algorithm::builders::DescribeAlgorithmOutputBuilder,
49 ::aws_smithy_json::deserialize::error::DeserializeError,
50> {
51 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
52 let tokens = &mut tokens_owned;
53 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
54 loop {
55 match tokens.next().transpose()? {
56 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
57 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
58 "AlgorithmName" => {
59 builder = builder.set_algorithm_name(
60 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
61 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
62 .transpose()?,
63 );
64 }
65 "AlgorithmArn" => {
66 builder = builder.set_algorithm_arn(
67 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
68 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
69 .transpose()?,
70 );
71 }
72 "AlgorithmDescription" => {
73 builder = builder.set_algorithm_description(
74 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
75 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
76 .transpose()?,
77 );
78 }
79 "CreationTime" => {
80 builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
81 tokens.next(),
82 ::aws_smithy_types::date_time::Format::EpochSeconds,
83 )?);
84 }
85 "TrainingSpecification" => {
86 builder =
87 builder.set_training_specification(crate::protocol_serde::shape_training_specification::de_training_specification(tokens)?);
88 }
89 "InferenceSpecification" => {
90 builder = builder
91 .set_inference_specification(crate::protocol_serde::shape_inference_specification::de_inference_specification(tokens)?);
92 }
93 "ValidationSpecification" => {
94 builder = builder.set_validation_specification(
95 crate::protocol_serde::shape_algorithm_validation_specification::de_algorithm_validation_specification(tokens)?,
96 );
97 }
98 "AlgorithmStatus" => {
99 builder = builder.set_algorithm_status(
100 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
101 .map(|s| s.to_unescaped().map(|u| crate::types::AlgorithmStatus::from(u.as_ref())))
102 .transpose()?,
103 );
104 }
105 "AlgorithmStatusDetails" => {
106 builder = builder.set_algorithm_status_details(
107 crate::protocol_serde::shape_algorithm_status_details::de_algorithm_status_details(tokens)?,
108 );
109 }
110 "ProductId" => {
111 builder = builder.set_product_id(
112 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
113 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
114 .transpose()?,
115 );
116 }
117 "CertifyForMarketplace" => {
118 builder = builder.set_certify_for_marketplace(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
119 }
120 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
121 },
122 other => {
123 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
124 "expected object key or end object, found: {:?}",
125 other
126 )))
127 }
128 }
129 }
130 if tokens.next().is_some() {
131 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
132 "found more JSON tokens after completing parsing",
133 ));
134 }
135 Ok(builder)
136}