aws_sdk_mediapackagev2/protocol_serde/
shape_reset_channel_state.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_reset_channel_state_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::reset_channel_state::ResetChannelStateOutput, crate::operation::reset_channel_state::ResetChannelStateError>
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::reset_channel_state::ResetChannelStateError::unhandled)?;
12 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13 let generic = generic_builder.build();
14 let error_code = match generic.code() {
15 Some(code) => code,
16 None => return Err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "AccessDeniedException" => crate::operation::reset_channel_state::ResetChannelStateError::AccessDeniedException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
26 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
27 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
28 let output = output.meta(generic);
29 output.build()
30 };
31 if tmp.message.is_none() {
32 tmp.message = _error_message;
33 }
34 tmp
35 }),
36 "ConflictException" => crate::operation::reset_channel_state::ResetChannelStateError::ConflictException({
37 #[allow(unused_mut)]
38 let mut tmp = {
39 #[allow(unused_mut)]
40 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
41 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
42 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
43 let output = output.meta(generic);
44 output.build()
45 };
46 if tmp.message.is_none() {
47 tmp.message = _error_message;
48 }
49 tmp
50 }),
51 "InternalServerException" => crate::operation::reset_channel_state::ResetChannelStateError::InternalServerException({
52 #[allow(unused_mut)]
53 let mut tmp = {
54 #[allow(unused_mut)]
55 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
56 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
57 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
58 let output = output.meta(generic);
59 output.build()
60 };
61 if tmp.message.is_none() {
62 tmp.message = _error_message;
63 }
64 tmp
65 }),
66 "ResourceNotFoundException" => crate::operation::reset_channel_state::ResetChannelStateError::ResourceNotFoundException({
67 #[allow(unused_mut)]
68 let mut tmp = {
69 #[allow(unused_mut)]
70 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
71 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
72 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
73 let output = output.meta(generic);
74 output.build()
75 };
76 if tmp.message.is_none() {
77 tmp.message = _error_message;
78 }
79 tmp
80 }),
81 "ThrottlingException" => crate::operation::reset_channel_state::ResetChannelStateError::ThrottlingException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
86 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
87 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
88 let output = output.meta(generic);
89 output.build()
90 };
91 if tmp.message.is_none() {
92 tmp.message = _error_message;
93 }
94 tmp
95 }),
96 "ValidationException" => crate::operation::reset_channel_state::ResetChannelStateError::ValidationException({
97 #[allow(unused_mut)]
98 let mut tmp = {
99 #[allow(unused_mut)]
100 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
101 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
102 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
103 let output = output.meta(generic);
104 output.build()
105 };
106 if tmp.message.is_none() {
107 tmp.message = _error_message;
108 }
109 tmp
110 }),
111 _ => crate::operation::reset_channel_state::ResetChannelStateError::generic(generic),
112 })
113}
114
115#[allow(clippy::unnecessary_wraps)]
116pub fn de_reset_channel_state_http_response(
117 _response_status: u16,
118 _response_headers: &::aws_smithy_runtime_api::http::Headers,
119 _response_body: &[u8],
120) -> std::result::Result<crate::operation::reset_channel_state::ResetChannelStateOutput, crate::operation::reset_channel_state::ResetChannelStateError>
121{
122 Ok({
123 #[allow(unused_mut)]
124 let mut output = crate::operation::reset_channel_state::builders::ResetChannelStateOutputBuilder::default();
125 output = crate::protocol_serde::shape_reset_channel_state::de_reset_channel_state(_response_body, output)
126 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?;
127 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
128 crate::serde_util::reset_channel_state_output_output_correct_errors(output)
129 .build()
130 .map_err(crate::operation::reset_channel_state::ResetChannelStateError::unhandled)?
131 })
132}
133
134pub(crate) fn de_reset_channel_state(
135 value: &[u8],
136 mut builder: crate::operation::reset_channel_state::builders::ResetChannelStateOutputBuilder,
137) -> ::std::result::Result<
138 crate::operation::reset_channel_state::builders::ResetChannelStateOutputBuilder,
139 ::aws_smithy_json::deserialize::error::DeserializeError,
140> {
141 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
142 let tokens = &mut tokens_owned;
143 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
144 loop {
145 match tokens.next().transpose()? {
146 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
147 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
148 "Arn" => {
149 builder = builder.set_arn(
150 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
151 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
152 .transpose()?,
153 );
154 }
155 "ChannelGroupName" => {
156 builder = builder.set_channel_group_name(
157 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
158 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
159 .transpose()?,
160 );
161 }
162 "ChannelName" => {
163 builder = builder.set_channel_name(
164 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
165 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
166 .transpose()?,
167 );
168 }
169 "ResetAt" => {
170 builder = builder.set_reset_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
171 tokens.next(),
172 ::aws_smithy_types::date_time::Format::EpochSeconds,
173 )?);
174 }
175 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
176 },
177 other => {
178 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
179 "expected object key or end object, found: {:?}",
180 other
181 )))
182 }
183 }
184 }
185 if tokens.next().is_some() {
186 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
187 "found more JSON tokens after completing parsing",
188 ));
189 }
190 Ok(builder)
191}