aws_sdk_sagemaker/protocol_serde/
shape_describe_trial_component.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_trial_component_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_trial_component::DescribeTrialComponentOutput,
9 crate::operation::describe_trial_component::DescribeTrialComponentError,
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_trial_component::DescribeTrialComponentError::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 => {
19 return Err(crate::operation::describe_trial_component::DescribeTrialComponentError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "ResourceNotFound" => crate::operation::describe_trial_component::DescribeTrialComponentError::ResourceNotFound({
28 #[allow(unused_mut)]
29 let mut tmp = {
30 #[allow(unused_mut)]
31 let mut output = crate::types::error::builders::ResourceNotFoundBuilder::default();
32 output = crate::protocol_serde::shape_resource_not_found::de_resource_not_found_json_err(_response_body, output)
33 .map_err(crate::operation::describe_trial_component::DescribeTrialComponentError::unhandled)?;
34 let output = output.meta(generic);
35 output.build()
36 };
37 if tmp.message.is_none() {
38 tmp.message = _error_message;
39 }
40 tmp
41 }),
42 _ => crate::operation::describe_trial_component::DescribeTrialComponentError::generic(generic),
43 })
44}
45
46#[allow(clippy::unnecessary_wraps)]
47pub fn de_describe_trial_component_http_response(
48 _response_status: u16,
49 _response_headers: &::aws_smithy_runtime_api::http::Headers,
50 _response_body: &[u8],
51) -> std::result::Result<
52 crate::operation::describe_trial_component::DescribeTrialComponentOutput,
53 crate::operation::describe_trial_component::DescribeTrialComponentError,
54> {
55 Ok({
56 #[allow(unused_mut)]
57 let mut output = crate::operation::describe_trial_component::builders::DescribeTrialComponentOutputBuilder::default();
58 output = crate::protocol_serde::shape_describe_trial_component::de_describe_trial_component(_response_body, output)
59 .map_err(crate::operation::describe_trial_component::DescribeTrialComponentError::unhandled)?;
60 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
61 output.build()
62 })
63}
64
65pub fn ser_describe_trial_component_input(
66 input: &crate::operation::describe_trial_component::DescribeTrialComponentInput,
67) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
68 let mut out = String::new();
69 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
70 crate::protocol_serde::shape_describe_trial_component_input::ser_describe_trial_component_input_input(&mut object, input)?;
71 object.finish();
72 Ok(::aws_smithy_types::body::SdkBody::from(out))
73}
74
75pub(crate) fn de_describe_trial_component(
76 value: &[u8],
77 mut builder: crate::operation::describe_trial_component::builders::DescribeTrialComponentOutputBuilder,
78) -> ::std::result::Result<
79 crate::operation::describe_trial_component::builders::DescribeTrialComponentOutputBuilder,
80 ::aws_smithy_json::deserialize::error::DeserializeError,
81> {
82 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
83 let tokens = &mut tokens_owned;
84 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
85 loop {
86 match tokens.next().transpose()? {
87 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
88 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
89 "TrialComponentName" => {
90 builder = builder.set_trial_component_name(
91 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
92 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
93 .transpose()?,
94 );
95 }
96 "TrialComponentArn" => {
97 builder = builder.set_trial_component_arn(
98 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
99 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
100 .transpose()?,
101 );
102 }
103 "DisplayName" => {
104 builder = builder.set_display_name(
105 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
106 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
107 .transpose()?,
108 );
109 }
110 "Source" => {
111 builder = builder.set_source(crate::protocol_serde::shape_trial_component_source::de_trial_component_source(tokens)?);
112 }
113 "Status" => {
114 builder = builder.set_status(crate::protocol_serde::shape_trial_component_status::de_trial_component_status(tokens)?);
115 }
116 "StartTime" => {
117 builder = builder.set_start_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
118 tokens.next(),
119 ::aws_smithy_types::date_time::Format::EpochSeconds,
120 )?);
121 }
122 "EndTime" => {
123 builder = builder.set_end_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
124 tokens.next(),
125 ::aws_smithy_types::date_time::Format::EpochSeconds,
126 )?);
127 }
128 "CreationTime" => {
129 builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
130 tokens.next(),
131 ::aws_smithy_types::date_time::Format::EpochSeconds,
132 )?);
133 }
134 "CreatedBy" => {
135 builder = builder.set_created_by(crate::protocol_serde::shape_user_context::de_user_context(tokens)?);
136 }
137 "LastModifiedTime" => {
138 builder = builder.set_last_modified_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
139 tokens.next(),
140 ::aws_smithy_types::date_time::Format::EpochSeconds,
141 )?);
142 }
143 "LastModifiedBy" => {
144 builder = builder.set_last_modified_by(crate::protocol_serde::shape_user_context::de_user_context(tokens)?);
145 }
146 "Parameters" => {
147 builder = builder.set_parameters(crate::protocol_serde::shape_trial_component_parameters::de_trial_component_parameters(
148 tokens,
149 )?);
150 }
151 "InputArtifacts" => {
152 builder = builder.set_input_artifacts(crate::protocol_serde::shape_trial_component_artifacts::de_trial_component_artifacts(
153 tokens,
154 )?);
155 }
156 "OutputArtifacts" => {
157 builder = builder.set_output_artifacts(crate::protocol_serde::shape_trial_component_artifacts::de_trial_component_artifacts(
158 tokens,
159 )?);
160 }
161 "MetadataProperties" => {
162 builder = builder.set_metadata_properties(crate::protocol_serde::shape_metadata_properties::de_metadata_properties(tokens)?);
163 }
164 "Metrics" => {
165 builder = builder
166 .set_metrics(crate::protocol_serde::shape_trial_component_metric_summaries::de_trial_component_metric_summaries(tokens)?);
167 }
168 "LineageGroupArn" => {
169 builder = builder.set_lineage_group_arn(
170 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
171 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
172 .transpose()?,
173 );
174 }
175 "Sources" => {
176 builder = builder.set_sources(crate::protocol_serde::shape_trial_component_sources::de_trial_component_sources(tokens)?);
177 }
178 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
179 },
180 other => {
181 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
182 "expected object key or end object, found: {:?}",
183 other
184 )))
185 }
186 }
187 }
188 if tokens.next().is_some() {
189 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
190 "found more JSON tokens after completing parsing",
191 ));
192 }
193 Ok(builder)
194}