aws_sdk_sagemaker/protocol_serde/
shape_describe_experiment.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_experiment_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::describe_experiment::DescribeExperimentOutput,
9 crate::operation::describe_experiment::DescribeExperimentError,
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::describe_experiment::DescribeExperimentError::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::describe_experiment::DescribeExperimentError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ResourceNotFound" => crate::operation::describe_experiment::DescribeExperimentError::ResourceNotFound({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ResourceNotFoundBuilder::default();
28 output = crate::protocol_serde::shape_resource_not_found::de_resource_not_found_json_err(_response_body, output)
29 .map_err(crate::operation::describe_experiment::DescribeExperimentError::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 _ => crate::operation::describe_experiment::DescribeExperimentError::generic(generic),
39 })
40}
41
42#[allow(clippy::unnecessary_wraps)]
43pub fn de_describe_experiment_http_response(
44 _response_status: u16,
45 _response_headers: &::aws_smithy_runtime_api::http::Headers,
46 _response_body: &[u8],
47) -> std::result::Result<
48 crate::operation::describe_experiment::DescribeExperimentOutput,
49 crate::operation::describe_experiment::DescribeExperimentError,
50> {
51 Ok({
52 #[allow(unused_mut)]
53 let mut output = crate::operation::describe_experiment::builders::DescribeExperimentOutputBuilder::default();
54 output = crate::protocol_serde::shape_describe_experiment::de_describe_experiment(_response_body, output)
55 .map_err(crate::operation::describe_experiment::DescribeExperimentError::unhandled)?;
56 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
57 output.build()
58 })
59}
60
61pub fn ser_describe_experiment_input(
62 input: &crate::operation::describe_experiment::DescribeExperimentInput,
63) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
64 let mut out = String::new();
65 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
66 crate::protocol_serde::shape_describe_experiment_input::ser_describe_experiment_input_input(&mut object, input)?;
67 object.finish();
68 Ok(::aws_smithy_types::body::SdkBody::from(out))
69}
70
71pub(crate) fn de_describe_experiment(
72 value: &[u8],
73 mut builder: crate::operation::describe_experiment::builders::DescribeExperimentOutputBuilder,
74) -> ::std::result::Result<
75 crate::operation::describe_experiment::builders::DescribeExperimentOutputBuilder,
76 ::aws_smithy_json::deserialize::error::DeserializeError,
77> {
78 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
79 let tokens = &mut tokens_owned;
80 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
81 loop {
82 match tokens.next().transpose()? {
83 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
84 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
85 "ExperimentName" => {
86 builder = builder.set_experiment_name(
87 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
88 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
89 .transpose()?,
90 );
91 }
92 "ExperimentArn" => {
93 builder = builder.set_experiment_arn(
94 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
95 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
96 .transpose()?,
97 );
98 }
99 "DisplayName" => {
100 builder = builder.set_display_name(
101 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
102 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
103 .transpose()?,
104 );
105 }
106 "Source" => {
107 builder = builder.set_source(crate::protocol_serde::shape_experiment_source::de_experiment_source(tokens)?);
108 }
109 "Description" => {
110 builder = builder.set_description(
111 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
112 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
113 .transpose()?,
114 );
115 }
116 "CreationTime" => {
117 builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
118 tokens.next(),
119 ::aws_smithy_types::date_time::Format::EpochSeconds,
120 )?);
121 }
122 "CreatedBy" => {
123 builder = builder.set_created_by(crate::protocol_serde::shape_user_context::de_user_context(tokens)?);
124 }
125 "LastModifiedTime" => {
126 builder = builder.set_last_modified_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
127 tokens.next(),
128 ::aws_smithy_types::date_time::Format::EpochSeconds,
129 )?);
130 }
131 "LastModifiedBy" => {
132 builder = builder.set_last_modified_by(crate::protocol_serde::shape_user_context::de_user_context(tokens)?);
133 }
134 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
135 },
136 other => {
137 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
138 "expected object key or end object, found: {:?}",
139 other
140 )))
141 }
142 }
143 }
144 if tokens.next().is_some() {
145 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
146 "found more JSON tokens after completing parsing",
147 ));
148 }
149 Ok(builder)
150}