aws_sdk_mediapackagev2/protocol_serde/
shape_get_channel_group.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_channel_group_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_group::GetChannelGroupOutput, crate::operation::get_channel_group::GetChannelGroupError> {
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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::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_group::GetChannelGroupError::generic(generic),
96    })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_get_channel_group_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_group::GetChannelGroupOutput, crate::operation::get_channel_group::GetChannelGroupError> {
105    Ok({
106        #[allow(unused_mut)]
107        let mut output = crate::operation::get_channel_group::builders::GetChannelGroupOutputBuilder::default();
108        output = crate::protocol_serde::shape_get_channel_group::de_get_channel_group(_response_body, output)
109            .map_err(crate::operation::get_channel_group::GetChannelGroupError::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_group_output_output_correct_errors(output)
112            .build()
113            .map_err(crate::operation::get_channel_group::GetChannelGroupError::unhandled)?
114    })
115}
116
117pub(crate) fn de_get_channel_group(
118    value: &[u8],
119    mut builder: crate::operation::get_channel_group::builders::GetChannelGroupOutputBuilder,
120) -> ::std::result::Result<
121    crate::operation::get_channel_group::builders::GetChannelGroupOutputBuilder,
122    ::aws_smithy_json::deserialize::error::DeserializeError,
123> {
124    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
125    let tokens = &mut tokens_owned;
126    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
127    loop {
128        match tokens.next().transpose()? {
129            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
130            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
131                "Arn" => {
132                    builder = builder.set_arn(
133                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
134                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
135                            .transpose()?,
136                    );
137                }
138                "ChannelGroupName" => {
139                    builder = builder.set_channel_group_name(
140                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
141                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
142                            .transpose()?,
143                    );
144                }
145                "CreatedAt" => {
146                    builder = builder.set_created_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
147                        tokens.next(),
148                        ::aws_smithy_types::date_time::Format::EpochSeconds,
149                    )?);
150                }
151                "Description" => {
152                    builder = builder.set_description(
153                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
154                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
155                            .transpose()?,
156                    );
157                }
158                "ETag" => {
159                    builder = builder.set_e_tag(
160                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
161                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
162                            .transpose()?,
163                    );
164                }
165                "EgressDomain" => {
166                    builder = builder.set_egress_domain(
167                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
168                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
169                            .transpose()?,
170                    );
171                }
172                "ModifiedAt" => {
173                    builder = builder.set_modified_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
174                        tokens.next(),
175                        ::aws_smithy_types::date_time::Format::EpochSeconds,
176                    )?);
177                }
178                "tags" => {
179                    builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
180                }
181                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
182            },
183            other => {
184                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
185                    "expected object key or end object, found: {:?}",
186                    other
187                )))
188            }
189        }
190    }
191    if tokens.next().is_some() {
192        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
193            "found more JSON tokens after completing parsing",
194        ));
195    }
196    Ok(builder)
197}