Skip to main content

aws_sdk_workspaces/protocol_serde/
shape_describe_client_branding.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_client_branding_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_client_branding::DescribeClientBrandingOutput,
9    crate::operation::describe_client_branding::DescribeClientBrandingError,
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_client_branding::DescribeClientBrandingError::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_client_branding::DescribeClientBrandingError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "AccessDeniedException" => crate::operation::describe_client_branding::DescribeClientBrandingError::AccessDeniedException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
32                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::describe_client_branding::DescribeClientBrandingError::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        "InvalidParameterValuesException" => {
43            crate::operation::describe_client_branding::DescribeClientBrandingError::InvalidParameterValuesException({
44                #[allow(unused_mut)]
45                let mut tmp = {
46                    #[allow(unused_mut)]
47                    let mut output = crate::types::error::builders::InvalidParameterValuesExceptionBuilder::default();
48                    output = crate::protocol_serde::shape_invalid_parameter_values_exception::de_invalid_parameter_values_exception_json_err(
49                        _response_body,
50                        output,
51                    )
52                    .map_err(crate::operation::describe_client_branding::DescribeClientBrandingError::unhandled)?;
53                    let output = output.meta(generic);
54                    output.build()
55                };
56                if tmp.message.is_none() {
57                    tmp.message = _error_message;
58                }
59                tmp
60            })
61        }
62        "ResourceNotFoundException" => crate::operation::describe_client_branding::DescribeClientBrandingError::ResourceNotFoundException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
67                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
68                    .map_err(crate::operation::describe_client_branding::DescribeClientBrandingError::unhandled)?;
69                let output = output.meta(generic);
70                output.build()
71            };
72            if tmp.message.is_none() {
73                tmp.message = _error_message;
74            }
75            tmp
76        }),
77        _ => crate::operation::describe_client_branding::DescribeClientBrandingError::generic(generic),
78    })
79}
80
81#[allow(clippy::unnecessary_wraps)]
82pub fn de_describe_client_branding_http_response(
83    _response_status: u16,
84    _response_headers: &::aws_smithy_runtime_api::http::Headers,
85    _response_body: &[u8],
86) -> std::result::Result<
87    crate::operation::describe_client_branding::DescribeClientBrandingOutput,
88    crate::operation::describe_client_branding::DescribeClientBrandingError,
89> {
90    Ok({
91        #[allow(unused_mut)]
92        let mut output = crate::operation::describe_client_branding::builders::DescribeClientBrandingOutputBuilder::default();
93        output = crate::protocol_serde::shape_describe_client_branding::de_describe_client_branding(_response_body, output)
94            .map_err(crate::operation::describe_client_branding::DescribeClientBrandingError::unhandled)?;
95        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
96        output.build()
97    })
98}
99
100pub fn ser_describe_client_branding_input(
101    input: &crate::operation::describe_client_branding::DescribeClientBrandingInput,
102) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
103    let mut out = String::new();
104    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
105    crate::protocol_serde::shape_describe_client_branding_input::ser_describe_client_branding_input_input(&mut object, input)?;
106    object.finish();
107    Ok(::aws_smithy_types::body::SdkBody::from(out))
108}
109
110pub(crate) fn de_describe_client_branding(
111    _value: &[u8],
112    mut builder: crate::operation::describe_client_branding::builders::DescribeClientBrandingOutputBuilder,
113) -> ::std::result::Result<
114    crate::operation::describe_client_branding::builders::DescribeClientBrandingOutputBuilder,
115    ::aws_smithy_json::deserialize::error::DeserializeError,
116> {
117    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
118    let tokens = &mut tokens_owned;
119    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
120    loop {
121        match tokens.next().transpose()? {
122            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
123            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
124                "DeviceTypeWindows" => {
125                    builder = builder.set_device_type_windows(
126                        crate::protocol_serde::shape_default_client_branding_attributes::de_default_client_branding_attributes(tokens, _value)?,
127                    );
128                }
129                "DeviceTypeOsx" => {
130                    builder = builder.set_device_type_osx(
131                        crate::protocol_serde::shape_default_client_branding_attributes::de_default_client_branding_attributes(tokens, _value)?,
132                    );
133                }
134                "DeviceTypeAndroid" => {
135                    builder = builder.set_device_type_android(
136                        crate::protocol_serde::shape_default_client_branding_attributes::de_default_client_branding_attributes(tokens, _value)?,
137                    );
138                }
139                "DeviceTypeIos" => {
140                    builder = builder.set_device_type_ios(
141                        crate::protocol_serde::shape_ios_client_branding_attributes::de_ios_client_branding_attributes(tokens, _value)?,
142                    );
143                }
144                "DeviceTypeLinux" => {
145                    builder = builder.set_device_type_linux(
146                        crate::protocol_serde::shape_default_client_branding_attributes::de_default_client_branding_attributes(tokens, _value)?,
147                    );
148                }
149                "DeviceTypeWeb" => {
150                    builder = builder.set_device_type_web(
151                        crate::protocol_serde::shape_default_client_branding_attributes::de_default_client_branding_attributes(tokens, _value)?,
152                    );
153                }
154                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
155            },
156            other => {
157                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
158                    "expected object key or end object, found: {other:?}"
159                )))
160            }
161        }
162    }
163    if tokens.next().is_some() {
164        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
165            "found more JSON tokens after completing parsing",
166        ));
167    }
168    Ok(builder)
169}