aws_sdk_sso/protocol_serde/
shape_get_role_credentials.rs
1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_role_credentials_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::get_role_credentials::GetRoleCredentialsOutput,
9 crate::operation::get_role_credentials::GetRoleCredentialsError,
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::get_role_credentials::GetRoleCredentialsError::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::get_role_credentials::GetRoleCredentialsError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "InvalidRequestException" => crate::operation::get_role_credentials::GetRoleCredentialsError::InvalidRequestException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
28 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
29 .map_err(crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled)?;
30 let output = output.meta(generic);
31 output.build()
32 };
33 if tmp.message.is_none() {
34 tmp.message = _error_message;
35 }
36 tmp
37 }),
38 "ResourceNotFoundException" => crate::operation::get_role_credentials::GetRoleCredentialsError::ResourceNotFoundException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
43 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
44 .map_err(crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled)?;
45 let output = output.meta(generic);
46 output.build()
47 };
48 if tmp.message.is_none() {
49 tmp.message = _error_message;
50 }
51 tmp
52 }),
53 "TooManyRequestsException" => crate::operation::get_role_credentials::GetRoleCredentialsError::TooManyRequestsException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::TooManyRequestsExceptionBuilder::default();
58 output = crate::protocol_serde::shape_too_many_requests_exception::de_too_many_requests_exception_json_err(_response_body, output)
59 .map_err(crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled)?;
60 let output = output.meta(generic);
61 output.build()
62 };
63 if tmp.message.is_none() {
64 tmp.message = _error_message;
65 }
66 tmp
67 }),
68 "UnauthorizedException" => crate::operation::get_role_credentials::GetRoleCredentialsError::UnauthorizedException({
69 #[allow(unused_mut)]
70 let mut tmp = {
71 #[allow(unused_mut)]
72 let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
73 output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
74 .map_err(crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled)?;
75 let output = output.meta(generic);
76 output.build()
77 };
78 if tmp.message.is_none() {
79 tmp.message = _error_message;
80 }
81 tmp
82 }),
83 _ => crate::operation::get_role_credentials::GetRoleCredentialsError::generic(generic),
84 })
85}
86
87#[allow(clippy::unnecessary_wraps)]
88pub fn de_get_role_credentials_http_response(
89 _response_status: u16,
90 _response_headers: &::aws_smithy_runtime_api::http::Headers,
91 _response_body: &[u8],
92) -> std::result::Result<
93 crate::operation::get_role_credentials::GetRoleCredentialsOutput,
94 crate::operation::get_role_credentials::GetRoleCredentialsError,
95> {
96 Ok({
97 #[allow(unused_mut)]
98 let mut output = crate::operation::get_role_credentials::builders::GetRoleCredentialsOutputBuilder::default();
99 output = crate::protocol_serde::shape_get_role_credentials::de_get_role_credentials(_response_body, output)
100 .map_err(crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled)?;
101 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
102 output.build()
103 })
104}
105
106pub fn ser_get_role_credentials_headers(
107 input: &crate::operation::get_role_credentials::GetRoleCredentialsInput,
108 mut builder: ::http::request::Builder,
109) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
110 if let ::std::option::Option::Some(inner_1) = &input.access_token {
111 let formatted_2 = inner_1.as_str();
112 let header_value = formatted_2;
113 let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
114 ::aws_smithy_types::error::operation::BuildError::invalid_field(
115 "access_token",
116 format!("`{}` cannot be used as a header value: {}", &"*** Sensitive Data Redacted ***", err),
117 )
118 })?;
119 builder = builder.header("x-amz-sso_bearer_token", header_value);
120 }
121 Ok(builder)
122}
123
124pub(crate) fn de_get_role_credentials(
125 value: &[u8],
126 mut builder: crate::operation::get_role_credentials::builders::GetRoleCredentialsOutputBuilder,
127) -> ::std::result::Result<
128 crate::operation::get_role_credentials::builders::GetRoleCredentialsOutputBuilder,
129 ::aws_smithy_json::deserialize::error::DeserializeError,
130> {
131 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
132 let tokens = &mut tokens_owned;
133 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
134 loop {
135 match tokens.next().transpose()? {
136 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
137 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
138 "roleCredentials" => {
139 builder = builder.set_role_credentials(crate::protocol_serde::shape_role_credentials::de_role_credentials(tokens)?);
140 }
141 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
142 },
143 other => {
144 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
145 "expected object key or end object, found: {:?}",
146 other
147 )))
148 }
149 }
150 }
151 if tokens.next().is_some() {
152 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
153 "found more JSON tokens after completing parsing",
154 ));
155 }
156 Ok(builder)
157}