129 133 | ::std::borrow::Cow::Owned(rcb)
|
130 134 | }
|
131 135 | }
|
132 136 |
|
133 137 | #[derive(Debug)]
|
134 138 | struct GetRoleCredentialsResponseDeserializer;
|
135 139 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetRoleCredentialsResponseDeserializer {
|
136 140 | fn deserialize_nonstreaming(
|
137 141 | &self,
|
138 142 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
143 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
139 144 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
140 145 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
141 - | let headers = response.headers();
|
142 - | let body = response.body().bytes().expect("body loaded");
|
143 146 | #[allow(unused_mut)]
|
144 147 | let mut force_error = false;
|
145 148 | ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
|
146 - | let parse_result = if !success && status != 200 || force_error {
|
147 - | crate::protocol_serde::shape_get_role_credentials::de_get_role_credentials_http_error(status, headers, body)
|
148 - | } else {
|
149 - | crate::protocol_serde::shape_get_role_credentials::de_get_role_credentials_http_response(status, headers, body)
|
149 + | if !success && status != 200 || force_error {
|
150 + | let headers = response.headers();
|
151 + | let body = response.body().bytes().expect("body loaded");
|
152 + | #[allow(unused_mut)]
|
153 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
154 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
155 + | })?;
|
156 + | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
|
157 + | let generic = generic_builder.build();
|
158 + | let error_code = match generic.code() {
|
159 + | ::std::option::Option::Some(code) => code,
|
160 + | ::std::option::Option::None => {
|
161 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
162 + | ::aws_smithy_runtime_api::box_error::BoxError::from(
|
163 + | crate::operation::get_role_credentials::GetRoleCredentialsError::unhandled(generic),
|
164 + | ),
|
165 + | ))
|
166 + | }
|
167 + | };
|
168 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
169 + | let protocol = _cfg
|
170 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
171 + | .expect("a SharedClientProtocol is required");
|
172 + | let err = match error_code {
|
173 + | "InvalidRequestException" => crate::operation::get_role_credentials::GetRoleCredentialsError::InvalidRequestException({
|
174 + | let mut tmp = match protocol
|
175 + | .deserialize_response(response, crate::types::error::InvalidRequestException::SCHEMA, _cfg)
|
176 + | .and_then(|mut deser| {
|
177 + | crate::types::error::InvalidRequestException::deserialize_with_response(
|
178 + | &mut *deser,
|
179 + | response.headers(),
|
180 + | response.status().into(),
|
181 + | body,
|
182 + | )
|
183 + | }) {
|
184 + | ::std::result::Result::Ok(val) => val,
|
185 + | ::std::result::Result::Err(e) => {
|
186 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
187 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
188 + | ))
|
189 + | }
|
190 + | };
|
191 + | tmp.meta = generic;
|
192 + | if tmp.message.is_none() {
|
193 + | tmp.message = _error_message;
|
194 + | }
|
195 + | tmp
|
196 + | }),
|
197 + | "ResourceNotFoundException" => crate::operation::get_role_credentials::GetRoleCredentialsError::ResourceNotFoundException({
|
198 + | let mut tmp = match protocol
|
199 + | .deserialize_response(response, crate::types::error::ResourceNotFoundException::SCHEMA, _cfg)
|
200 + | .and_then(|mut deser| {
|
201 + | crate::types::error::ResourceNotFoundException::deserialize_with_response(
|
202 + | &mut *deser,
|
203 + | response.headers(),
|
204 + | response.status().into(),
|
205 + | body,
|
206 + | )
|
207 + | }) {
|
208 + | ::std::result::Result::Ok(val) => val,
|
209 + | ::std::result::Result::Err(e) => {
|
210 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
211 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
212 + | ))
|
213 + | }
|
214 + | };
|
215 + | tmp.meta = generic;
|
216 + | if tmp.message.is_none() {
|
217 + | tmp.message = _error_message;
|
218 + | }
|
219 + | tmp
|
220 + | }),
|
221 + | "TooManyRequestsException" => crate::operation::get_role_credentials::GetRoleCredentialsError::TooManyRequestsException({
|
222 + | let mut tmp = match protocol
|
223 + | .deserialize_response(response, crate::types::error::TooManyRequestsException::SCHEMA, _cfg)
|
224 + | .and_then(|mut deser| {
|
225 + | crate::types::error::TooManyRequestsException::deserialize_with_response(
|
226 + | &mut *deser,
|
227 + | response.headers(),
|
228 + | response.status().into(),
|
229 + | body,
|
230 + | )
|
231 + | }) {
|
232 + | ::std::result::Result::Ok(val) => val,
|
233 + | ::std::result::Result::Err(e) => {
|
234 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
235 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
236 + | ))
|
237 + | }
|
238 + | };
|
239 + | tmp.meta = generic;
|
240 + | if tmp.message.is_none() {
|
241 + | tmp.message = _error_message;
|
242 + | }
|
243 + | tmp
|
244 + | }),
|
245 + | "UnauthorizedException" => crate::operation::get_role_credentials::GetRoleCredentialsError::UnauthorizedException({
|
246 + | let mut tmp = match protocol
|
247 + | .deserialize_response(response, crate::types::error::UnauthorizedException::SCHEMA, _cfg)
|
248 + | .and_then(|mut deser| {
|
249 + | crate::types::error::UnauthorizedException::deserialize_with_response(
|
250 + | &mut *deser,
|
251 + | response.headers(),
|
252 + | response.status().into(),
|
253 + | body,
|
254 + | )
|
255 + | }) {
|
256 + | ::std::result::Result::Ok(val) => val,
|
257 + | ::std::result::Result::Err(e) => {
|
258 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
259 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
260 + | ))
|
261 + | }
|
262 + | };
|
263 + | tmp.meta = generic;
|
264 + | if tmp.message.is_none() {
|
265 + | tmp.message = _error_message;
|
266 + | }
|
267 + | tmp
|
268 + | }),
|
269 + | _ => crate::operation::get_role_credentials::GetRoleCredentialsError::generic(generic),
|
150 270 | };
|
151 - | crate::protocol_serde::type_erase_result(parse_result)
|
271 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
272 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
273 + | ))
|
274 + | } else {
|
275 + | let protocol = _cfg
|
276 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
277 + | .expect("a SharedClientProtocol is required");
|
278 + | let mut deser = protocol
|
279 + | .deserialize_response(response, GetRoleCredentials::OUTPUT_SCHEMA, _cfg)
|
280 + | .map_err(|e| {
|
281 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
282 + | })?;
|
283 + | let body = response.body().bytes().expect("body loaded");
|
284 + | let output = crate::operation::get_role_credentials::GetRoleCredentialsOutput::deserialize_with_response(
|
285 + | &mut *deser,
|
286 + | response.headers(),
|
287 + | response.status().into(),
|
288 + | body,
|
289 + | )
|
290 + | .map_err(|e| {
|
291 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
292 + | })?;
|
293 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
294 + | }
|
152 295 | }
|
153 296 | }
|
154 297 | #[derive(Debug)]
|
155 298 | struct GetRoleCredentialsRequestSerializer;
|
156 299 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetRoleCredentialsRequestSerializer {
|
157 300 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
158 301 | fn serialize_input(
|
159 302 | &self,
|
160 303 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
161 304 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
162 305 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
163 306 | let input = input
|
164 307 | .downcast::<crate::operation::get_role_credentials::GetRoleCredentialsInput>()
|
165 308 | .expect("correct type");
|
166 - | let _header_serialization_settings = _cfg
|
167 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
168 - | .cloned()
|
169 - | .unwrap_or_default();
|
170 - | let mut request_builder = {
|
171 - | #[allow(clippy::uninlined_format_args)]
|
172 - | fn uri_base(
|
173 - | _input: &crate::operation::get_role_credentials::GetRoleCredentialsInput,
|
174 - | output: &mut ::std::string::String,
|
175 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
176 - | use ::std::fmt::Write as _;
|
177 - | ::std::write!(output, "/federation/credentials").expect("formatting should succeed");
|
178 - | ::std::result::Result::Ok(())
|
179 - | }
|
180 - | fn uri_query(
|
181 - | _input: &crate::operation::get_role_credentials::GetRoleCredentialsInput,
|
182 - | mut output: &mut ::std::string::String,
|
183 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
184 - | let mut query = ::aws_smithy_http::query::Writer::new(output);
|
185 - | let inner_1 = &_input.role_name;
|
186 - | let inner_1 = inner_1
|
187 - | .as_ref()
|
188 - | .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("role_name", "cannot be empty or unset"))?;
|
189 - | if inner_1.is_empty() {
|
190 - | return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
|
191 - | "role_name",
|
192 - | "cannot be empty or unset",
|
193 - | ));
|
309 + | let protocol = _cfg
|
310 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
311 + | .expect("a SharedClientProtocol is required");
|
312 + | if protocol.supports_http_bindings() {
|
313 + | let mut request = protocol
|
314 + | .serialize_body(&input, GetRoleCredentials::INPUT_SCHEMA, "", _cfg)
|
315 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
316 + | {
|
317 + | let mut uri = "/federation/credentials".to_string();
|
318 + | let mut query_params: Vec<(String, String)> = Vec::new();
|
319 + | if let Some(ref val) = input.role_name {
|
320 + | query_params.push(("role_name".to_string(), val.to_string()));
|
321 + | }
|
322 + | if let Some(ref val) = input.account_id {
|
323 + | query_params.push(("account_id".to_string(), val.to_string()));
|
324 + | }
|
325 + | if let Some(ref val) = input.access_token {
|
326 + | request.headers_mut().insert("x-amz-sso_bearer_token", val.to_string());
|
327 + | }
|
328 + | if !query_params.is_empty() {
|
329 + | uri.push(if uri.contains('?') { '&' } else { '?' });
|
330 + | let pairs: Vec<String> = query_params
|
331 + | .iter()
|
332 + | .map(|(k, v)| {
|
333 + | format!(
|
334 + | "{}={}",
|
335 + | ::aws_smithy_schema::http_protocol::percent_encode(k),
|
336 + | ::aws_smithy_schema::http_protocol::percent_encode(v)
|
337 + | )
|
338 + | })
|
339 + | .collect();
|
340 + | uri.push_str(&pairs.join("&"));
|
194 341 | }
|
195 - | query.push_kv("role_name", &::aws_smithy_http::query::fmt_string(inner_1));
|
196 - | let inner_2 = &_input.account_id;
|
197 - | let inner_2 = inner_2
|
198 - | .as_ref()
|
199 - | .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("account_id", "cannot be empty or unset"))?;
|
200 - | if inner_2.is_empty() {
|
201 - | return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
|
202 - | "account_id",
|
203 - | "cannot be empty or unset",
|
204 - | ));
|
342 + | request.set_uri(uri.as_str()).expect("valid URI");
|
205 343 | }
|
206 - | query.push_kv("account_id", &::aws_smithy_http::query::fmt_string(inner_2));
|
207 - | ::std::result::Result::Ok(())
|
208 - | }
|
209 - | #[allow(clippy::unnecessary_wraps)]
|
210 - | fn update_http_builder(
|
211 - | input: &crate::operation::get_role_credentials::GetRoleCredentialsInput,
|
212 - | builder: ::http_1x::request::Builder,
|
213 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
214 - | let mut uri = ::std::string::String::new();
|
215 - | uri_base(input, &mut uri)?;
|
216 - | uri_query(input, &mut uri)?;
|
217 - | let builder = crate::protocol_serde::shape_get_role_credentials::ser_get_role_credentials_headers(input, builder)?;
|
218 - | ::std::result::Result::Ok(builder.method("GET").uri(uri))
|
219 - | }
|
220 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
221 - | builder
|
222 - | };
|
223 - | let body = ::aws_smithy_types::body::SdkBody::from("");
|
224 344 |
|
225 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
345 + | return ::std::result::Result::Ok(request);
|
346 + | } else {
|
347 + | let mut request = protocol
|
348 + | .serialize_request(&input, GetRoleCredentials::INPUT_SCHEMA, "", _cfg)
|
349 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
350 + |
|
351 + | return ::std::result::Result::Ok(request);
|
352 + | }
|
226 353 | }
|
227 354 | }
|
228 355 | #[derive(Debug)]
|
229 356 | struct GetRoleCredentialsEndpointParamsInterceptor;
|
230 357 |
|
231 358 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetRoleCredentialsEndpointParamsInterceptor {
|
232 359 | fn name(&self) -> &'static str {
|
233 360 | "GetRoleCredentialsEndpointParamsInterceptor"
|
234 361 | }
|
235 362 |
|