aws_sdk_mediapackagev2/protocol_serde/
shape_update_channel.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_channel_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_channel::UpdateChannelOutput, crate::operation::update_channel::UpdateChannelError> {
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_channel::UpdateChannelError::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_channel::UpdateChannelError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::update_channel::UpdateChannelError::AccessDeniedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26 .map_err(crate::operation::update_channel::UpdateChannelError::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 "ConflictException" => crate::operation::update_channel::UpdateChannelError::ConflictException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
40 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
41 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "InternalServerException" => crate::operation::update_channel::UpdateChannelError::InternalServerException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
55 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
56 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 "ResourceNotFoundException" => crate::operation::update_channel::UpdateChannelError::ResourceNotFoundException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
70 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
71 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
72 let output = output.meta(generic);
73 output.build()
74 };
75 if tmp.message.is_none() {
76 tmp.message = _error_message;
77 }
78 tmp
79 }),
80 "ThrottlingException" => crate::operation::update_channel::UpdateChannelError::ThrottlingException({
81 #[allow(unused_mut)]
82 let mut tmp = {
83 #[allow(unused_mut)]
84 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
85 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
86 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
87 let output = output.meta(generic);
88 output.build()
89 };
90 if tmp.message.is_none() {
91 tmp.message = _error_message;
92 }
93 tmp
94 }),
95 "ValidationException" => crate::operation::update_channel::UpdateChannelError::ValidationException({
96 #[allow(unused_mut)]
97 let mut tmp = {
98 #[allow(unused_mut)]
99 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
100 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
101 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
102 let output = output.meta(generic);
103 output.build()
104 };
105 if tmp.message.is_none() {
106 tmp.message = _error_message;
107 }
108 tmp
109 }),
110 _ => crate::operation::update_channel::UpdateChannelError::generic(generic),
111 })
112}
113
114#[allow(clippy::unnecessary_wraps)]
115pub fn de_update_channel_http_response(
116 _response_status: u16,
117 _response_headers: &::aws_smithy_runtime_api::http::Headers,
118 _response_body: &[u8],
119) -> std::result::Result<crate::operation::update_channel::UpdateChannelOutput, crate::operation::update_channel::UpdateChannelError> {
120 Ok({
121 #[allow(unused_mut)]
122 let mut output = crate::operation::update_channel::builders::UpdateChannelOutputBuilder::default();
123 output = crate::protocol_serde::shape_update_channel::de_update_channel(_response_body, output)
124 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?;
125 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
126 crate::serde_util::update_channel_output_output_correct_errors(output)
127 .build()
128 .map_err(crate::operation::update_channel::UpdateChannelError::unhandled)?
129 })
130}
131
132pub fn ser_update_channel_headers(
133 input: &crate::operation::update_channel::UpdateChannelInput,
134 mut builder: ::http::request::Builder,
135) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
136 if let ::std::option::Option::Some(inner_1) = &input.e_tag {
137 let formatted_2 = inner_1.as_str();
138 let header_value = formatted_2;
139 let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
140 ::aws_smithy_types::error::operation::BuildError::invalid_field(
141 "e_tag",
142 format!("`{}` cannot be used as a header value: {}", &header_value, err),
143 )
144 })?;
145 builder = builder.header("x-amzn-update-if-match", header_value);
146 }
147 Ok(builder)
148}
149
150pub fn ser_update_channel_input(
151 input: &crate::operation::update_channel::UpdateChannelInput,
152) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
153 let mut out = String::new();
154 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
155 crate::protocol_serde::shape_update_channel_input::ser_update_channel_input_input(&mut object, input)?;
156 object.finish();
157 Ok(::aws_smithy_types::body::SdkBody::from(out))
158}
159
160pub(crate) fn de_update_channel(
161 value: &[u8],
162 mut builder: crate::operation::update_channel::builders::UpdateChannelOutputBuilder,
163) -> ::std::result::Result<
164 crate::operation::update_channel::builders::UpdateChannelOutputBuilder,
165 ::aws_smithy_json::deserialize::error::DeserializeError,
166> {
167 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
168 let tokens = &mut tokens_owned;
169 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
170 loop {
171 match tokens.next().transpose()? {
172 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
173 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
174 "Arn" => {
175 builder = builder.set_arn(
176 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
177 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
178 .transpose()?,
179 );
180 }
181 "ChannelGroupName" => {
182 builder = builder.set_channel_group_name(
183 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
184 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
185 .transpose()?,
186 );
187 }
188 "ChannelName" => {
189 builder = builder.set_channel_name(
190 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
191 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
192 .transpose()?,
193 );
194 }
195 "CreatedAt" => {
196 builder = builder.set_created_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
197 tokens.next(),
198 ::aws_smithy_types::date_time::Format::EpochSeconds,
199 )?);
200 }
201 "Description" => {
202 builder = builder.set_description(
203 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
204 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
205 .transpose()?,
206 );
207 }
208 "ETag" => {
209 builder = builder.set_e_tag(
210 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
211 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
212 .transpose()?,
213 );
214 }
215 "IngestEndpoints" => {
216 builder = builder.set_ingest_endpoints(crate::protocol_serde::shape_ingest_endpoint_list::de_ingest_endpoint_list(tokens)?);
217 }
218 "InputSwitchConfiguration" => {
219 builder = builder.set_input_switch_configuration(
220 crate::protocol_serde::shape_input_switch_configuration::de_input_switch_configuration(tokens)?,
221 );
222 }
223 "InputType" => {
224 builder = builder.set_input_type(
225 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
226 .map(|s| s.to_unescaped().map(|u| crate::types::InputType::from(u.as_ref())))
227 .transpose()?,
228 );
229 }
230 "ModifiedAt" => {
231 builder = builder.set_modified_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
232 tokens.next(),
233 ::aws_smithy_types::date_time::Format::EpochSeconds,
234 )?);
235 }
236 "OutputHeaderConfiguration" => {
237 builder = builder.set_output_header_configuration(
238 crate::protocol_serde::shape_output_header_configuration::de_output_header_configuration(tokens)?,
239 );
240 }
241 "tags" => {
242 builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
243 }
244 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
245 },
246 other => {
247 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
248 "expected object key or end object, found: {:?}",
249 other
250 )))
251 }
252 }
253 }
254 if tokens.next().is_some() {
255 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
256 "found more JSON tokens after completing parsing",
257 ));
258 }
259 Ok(builder)
260}