aws_sdk_mediapackagev2/protocol_serde/
shape_get_channel.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_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::get_channel::GetChannelOutput, crate::operation::get_channel::GetChannelError> {
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::get_channel::GetChannelError::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::get_channel::GetChannelError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::get_channel::GetChannelError::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::get_channel::GetChannelError::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 "InternalServerException" => crate::operation::get_channel::GetChannelError::InternalServerException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
40 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
41 .map_err(crate::operation::get_channel::GetChannelError::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 "ResourceNotFoundException" => crate::operation::get_channel::GetChannelError::ResourceNotFoundException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
55 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
56 .map_err(crate::operation::get_channel::GetChannelError::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 "ThrottlingException" => crate::operation::get_channel::GetChannelError::ThrottlingException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
70 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
71 .map_err(crate::operation::get_channel::GetChannelError::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 "ValidationException" => crate::operation::get_channel::GetChannelError::ValidationException({
81 #[allow(unused_mut)]
82 let mut tmp = {
83 #[allow(unused_mut)]
84 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
85 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
86 .map_err(crate::operation::get_channel::GetChannelError::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 _ => crate::operation::get_channel::GetChannelError::generic(generic),
96 })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_get_channel_http_response(
101 _response_status: u16,
102 _response_headers: &::aws_smithy_runtime_api::http::Headers,
103 _response_body: &[u8],
104) -> std::result::Result<crate::operation::get_channel::GetChannelOutput, crate::operation::get_channel::GetChannelError> {
105 Ok({
106 #[allow(unused_mut)]
107 let mut output = crate::operation::get_channel::builders::GetChannelOutputBuilder::default();
108 output = crate::protocol_serde::shape_get_channel::de_get_channel(_response_body, output)
109 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?;
110 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
111 crate::serde_util::get_channel_output_output_correct_errors(output)
112 .build()
113 .map_err(crate::operation::get_channel::GetChannelError::unhandled)?
114 })
115}
116
117pub(crate) fn de_get_channel(
118 value: &[u8],
119 mut builder: crate::operation::get_channel::builders::GetChannelOutputBuilder,
120) -> ::std::result::Result<crate::operation::get_channel::builders::GetChannelOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
121{
122 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
123 let tokens = &mut tokens_owned;
124 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
125 loop {
126 match tokens.next().transpose()? {
127 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
128 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
129 "Arn" => {
130 builder = builder.set_arn(
131 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
132 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
133 .transpose()?,
134 );
135 }
136 "ChannelGroupName" => {
137 builder = builder.set_channel_group_name(
138 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
139 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
140 .transpose()?,
141 );
142 }
143 "ChannelName" => {
144 builder = builder.set_channel_name(
145 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
146 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
147 .transpose()?,
148 );
149 }
150 "CreatedAt" => {
151 builder = builder.set_created_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
152 tokens.next(),
153 ::aws_smithy_types::date_time::Format::EpochSeconds,
154 )?);
155 }
156 "Description" => {
157 builder = builder.set_description(
158 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
159 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
160 .transpose()?,
161 );
162 }
163 "ETag" => {
164 builder = builder.set_e_tag(
165 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
166 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
167 .transpose()?,
168 );
169 }
170 "IngestEndpoints" => {
171 builder = builder.set_ingest_endpoints(crate::protocol_serde::shape_ingest_endpoint_list::de_ingest_endpoint_list(tokens)?);
172 }
173 "InputSwitchConfiguration" => {
174 builder = builder.set_input_switch_configuration(
175 crate::protocol_serde::shape_input_switch_configuration::de_input_switch_configuration(tokens)?,
176 );
177 }
178 "InputType" => {
179 builder = builder.set_input_type(
180 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
181 .map(|s| s.to_unescaped().map(|u| crate::types::InputType::from(u.as_ref())))
182 .transpose()?,
183 );
184 }
185 "ModifiedAt" => {
186 builder = builder.set_modified_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
187 tokens.next(),
188 ::aws_smithy_types::date_time::Format::EpochSeconds,
189 )?);
190 }
191 "OutputHeaderConfiguration" => {
192 builder = builder.set_output_header_configuration(
193 crate::protocol_serde::shape_output_header_configuration::de_output_header_configuration(tokens)?,
194 );
195 }
196 "ResetAt" => {
197 builder = builder.set_reset_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
198 tokens.next(),
199 ::aws_smithy_types::date_time::Format::EpochSeconds,
200 )?);
201 }
202 "Tags" => {
203 builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
204 }
205 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
206 },
207 other => {
208 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
209 "expected object key or end object, found: {:?}",
210 other
211 )))
212 }
213 }
214 }
215 if tokens.next().is_some() {
216 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
217 "found more JSON tokens after completing parsing",
218 ));
219 }
220 Ok(builder)
221}