aws_sdk_grafana/protocol_serde/
shape_update_workspace_authentication.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_workspace_authentication_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::update_workspace_authentication::UpdateWorkspaceAuthenticationOutput,
9    crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError,
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::update_workspace_authentication::UpdateWorkspaceAuthenticationError::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 => return Err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::AccessDeniedException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
28                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
30                let output = output.meta(generic);
31                crate::serde_util::access_denied_exception_correct_errors(output)
32                    .build()
33                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
34            };
35            tmp
36        }),
37        "ConflictException" => crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::ConflictException({
38            #[allow(unused_mut)]
39            let mut tmp = {
40                #[allow(unused_mut)]
41                let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
42                output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
43                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
44                let output = output.meta(generic);
45                crate::serde_util::conflict_exception_correct_errors(output)
46                    .build()
47                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
48            };
49            tmp
50        }),
51        "InternalServerException" => {
52            crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::InternalServerException({
53                #[allow(unused_mut)]
54                let mut tmp = {
55                    #[allow(unused_mut)]
56                    let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
57                    output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
58                        .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
59                    output = output.set_retry_after_seconds(
60                        crate::protocol_serde::shape_internal_server_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
61                            crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled(
62                                "Failed to parse retryAfterSeconds from header `Retry-After",
63                            )
64                        })?,
65                    );
66                    let output = output.meta(generic);
67                    crate::serde_util::internal_server_exception_correct_errors(output)
68                        .build()
69                        .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
70                };
71                tmp
72            })
73        }
74        "ResourceNotFoundException" => {
75            crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::ResourceNotFoundException({
76                #[allow(unused_mut)]
77                let mut tmp = {
78                    #[allow(unused_mut)]
79                    let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
80                    output =
81                        crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
82                            .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
83                    let output = output.meta(generic);
84                    crate::serde_util::resource_not_found_exception_correct_errors(output)
85                        .build()
86                        .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
87                };
88                tmp
89            })
90        }
91        "ThrottlingException" => crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::ThrottlingException({
92            #[allow(unused_mut)]
93            let mut tmp = {
94                #[allow(unused_mut)]
95                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
96                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
97                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
98                output = output.set_retry_after_seconds(
99                    crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
100                        crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled(
101                            "Failed to parse retryAfterSeconds from header `Retry-After",
102                        )
103                    })?,
104                );
105                let output = output.meta(generic);
106                crate::serde_util::throttling_exception_correct_errors(output)
107                    .build()
108                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
109            };
110            tmp
111        }),
112        "ValidationException" => crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::ValidationException({
113            #[allow(unused_mut)]
114            let mut tmp = {
115                #[allow(unused_mut)]
116                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
117                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
118                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
119                let output = output.meta(generic);
120                crate::serde_util::validation_exception_correct_errors(output)
121                    .build()
122                    .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?
123            };
124            tmp
125        }),
126        _ => crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::generic(generic),
127    })
128}
129
130#[allow(clippy::unnecessary_wraps)]
131pub fn de_update_workspace_authentication_http_response(
132    _response_status: u16,
133    _response_headers: &::aws_smithy_runtime_api::http::Headers,
134    _response_body: &[u8],
135) -> std::result::Result<
136    crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationOutput,
137    crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError,
138> {
139    Ok({
140        #[allow(unused_mut)]
141        let mut output = crate::operation::update_workspace_authentication::builders::UpdateWorkspaceAuthenticationOutputBuilder::default();
142        output = crate::protocol_serde::shape_update_workspace_authentication::de_update_workspace_authentication(_response_body, output)
143            .map_err(crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationError::unhandled)?;
144        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
145        crate::serde_util::update_workspace_authentication_output_output_correct_errors(output).build()
146    })
147}
148
149pub fn ser_update_workspace_authentication_input(
150    input: &crate::operation::update_workspace_authentication::UpdateWorkspaceAuthenticationInput,
151) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
152    let mut out = String::new();
153    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
154    crate::protocol_serde::shape_update_workspace_authentication_input::ser_update_workspace_authentication_input_input(&mut object, input)?;
155    object.finish();
156    Ok(::aws_smithy_types::body::SdkBody::from(out))
157}
158
159pub(crate) fn de_update_workspace_authentication(
160    value: &[u8],
161    mut builder: crate::operation::update_workspace_authentication::builders::UpdateWorkspaceAuthenticationOutputBuilder,
162) -> ::std::result::Result<
163    crate::operation::update_workspace_authentication::builders::UpdateWorkspaceAuthenticationOutputBuilder,
164    ::aws_smithy_json::deserialize::error::DeserializeError,
165> {
166    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
167    let tokens = &mut tokens_owned;
168    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
169    loop {
170        match tokens.next().transpose()? {
171            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
172            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
173                "authentication" => {
174                    builder = builder.set_authentication(crate::protocol_serde::shape_authentication_description::de_authentication_description(
175                        tokens,
176                    )?);
177                }
178                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
179            },
180            other => {
181                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
182                    "expected object key or end object, found: {:?}",
183                    other
184                )))
185            }
186        }
187    }
188    if tokens.next().is_some() {
189        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
190            "found more JSON tokens after completing parsing",
191        ));
192    }
193    Ok(builder)
194}