Skip to main content

aws_sdk_sts/operation/
get_federation_token.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetFederationToken`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetFederationToken;
6impl GetFederationToken {
7    /// Creates a new `GetFederationToken`
8    pub fn new() -> Self {
9        Self
10    }
11    pub(crate) async fn orchestrate(
12        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13        input: crate::operation::get_federation_token::GetFederationTokenInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_federation_token::GetFederationTokenOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_federation_token::GetFederationTokenError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::get_federation_token::GetFederationTokenError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::get_federation_token::GetFederationTokenOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::get_federation_token::GetFederationTokenInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        use ::tracing::Instrument;
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("STS", "GetFederationToken", input, runtime_plugins, stop_point)
55            // Create a parent span for the entire operation. Includes a random, internal-only,
56            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
57            .instrument(::tracing::debug_span!(
58                "STS.GetFederationToken",
59                "rpc.service" = "STS",
60                "rpc.method" = "GetFederationToken",
61                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62                "rpc.system" = "aws-api",
63            ))
64            .await
65    }
66
67    pub(crate) fn operation_runtime_plugins(
68        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69        client_config: &crate::config::Config,
70        config_override: ::std::option::Option<crate::config::Builder>,
71    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74        if let ::std::option::Option::Some(config_override) = config_override {
75            for plugin in config_override.runtime_plugins.iter().cloned() {
76                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77            }
78            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79                config_override,
80                client_config.config.clone(),
81                &client_config.runtime_components,
82            ));
83        }
84        runtime_plugins
85    }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetFederationToken {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetFederationToken");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            GetFederationTokenRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            GetFederationTokenResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("GetFederationToken")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
106        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetFederationToken", "STS"));
107        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
108        signing_options.double_uri_encode = true;
109        signing_options.content_sha256_header = false;
110        signing_options.normalize_uri_path = true;
111        signing_options.payload_override = None;
112
113        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
114            signing_options,
115            ..::std::default::Default::default()
116        });
117
118        ::std::option::Option::Some(cfg.freeze())
119    }
120
121    fn runtime_components(
122        &self,
123        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
124    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
125        #[allow(unused_mut)]
126                    let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetFederationToken")
127                            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(GetFederationTokenTelemetryInputCaptureInterceptor))
128.with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default()))
129.with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(GetFederationTokenEndpointParamsInterceptor))
130                            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<crate::operation::get_federation_token::GetFederationTokenError>::new())
131.with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<crate::operation::get_federation_token::GetFederationTokenError>::new())
132.with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::get_federation_token::GetFederationTokenError>::builder().transient_errors({
133                                            let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
134                                            transient_errors.push("IDPCommunicationError");
135                                            ::std::borrow::Cow::Owned(transient_errors)
136                                            }).build())
137.with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<crate::operation::get_federation_token::GetFederationTokenError>::new());
138
139        ::std::borrow::Cow::Owned(rcb)
140    }
141}
142
143#[derive(Debug)]
144struct GetFederationTokenTelemetryInputCaptureInterceptor;
145
146#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
147impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetFederationTokenTelemetryInputCaptureInterceptor {
148    fn name(&self) -> &'static str {
149        "GetFederationTokenTelemetryInputCaptureInterceptor"
150    }
151
152    fn read_before_execution(
153        &self,
154        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
155            '_,
156            ::aws_smithy_runtime_api::client::interceptors::context::Input,
157            ::aws_smithy_runtime_api::client::interceptors::context::Output,
158            ::aws_smithy_runtime_api::client::interceptors::context::Error,
159        >,
160        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
161    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
162        // Nothing to do unless the customer opted in by naming members to record.
163        let ::std::option::Option::Some(requested) = cfg
164            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
165            .filter(|r| !r.is_empty())
166        else {
167            return ::std::result::Result::Ok(());
168        };
169
170        let ::std::option::Option::Some(input) = context.input().downcast_ref::<GetFederationTokenInput>() else {
171            // A mismatched input is not this interceptor's concern; skip quietly.
172            return ::std::result::Result::Ok(());
173        };
174
175        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
176        if requested.should_capture("Name") {
177            if let ::std::option::Option::Some(value) = input.name.as_deref() {
178                captured.insert("Name", value);
179            }
180        }
181        if requested.should_capture("Policy") {
182            if let ::std::option::Option::Some(value) = input.policy.as_deref() {
183                captured.insert("Policy", value);
184            }
185        }
186
187        cfg.interceptor_state().store_put(captured);
188        ::std::result::Result::Ok(())
189    }
190}
191#[derive(Debug)]
192struct GetFederationTokenResponseDeserializer;
193impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetFederationTokenResponseDeserializer {
194    fn deserialize_nonstreaming_with_config(
195        &self,
196        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
197        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
198    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
199        let (success, status) = (response.status().is_success(), response.status().as_u16());
200        let headers = response.headers();
201        let body = response.body().bytes().expect("body loaded");
202        #[allow(unused_mut)]
203        let mut force_error = false;
204        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
205        let parse_result = if !success && status != 200 || force_error {
206            crate::protocol_serde::shape_get_federation_token::de_get_federation_token_http_error(status, headers, body, _cfg)
207        } else {
208            crate::protocol_serde::shape_get_federation_token::de_get_federation_token_http_response(status, headers, body, _cfg)
209        };
210        crate::protocol_serde::type_erase_result(parse_result)
211    }
212}
213#[derive(Debug)]
214struct GetFederationTokenRequestSerializer;
215impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetFederationTokenRequestSerializer {
216    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
217    fn serialize_input(
218        &self,
219        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
220        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
221    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
222        let input = input
223            .downcast::<crate::operation::get_federation_token::GetFederationTokenInput>()
224            .expect("correct type");
225        let _header_serialization_settings = _cfg
226            .load::<crate::serialization_settings::HeaderSerializationSettings>()
227            .cloned()
228            .unwrap_or_default();
229        let mut request_builder = {
230            #[allow(clippy::uninlined_format_args)]
231            fn uri_base(
232                _input: &crate::operation::get_federation_token::GetFederationTokenInput,
233                output: &mut ::std::string::String,
234            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
235                use ::std::fmt::Write as _;
236                ::std::write!(output, "/").expect("formatting should succeed");
237                ::std::result::Result::Ok(())
238            }
239            #[allow(clippy::unnecessary_wraps)]
240            fn update_http_builder(
241                input: &crate::operation::get_federation_token::GetFederationTokenInput,
242                builder: ::http_1x::request::Builder,
243            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
244                let mut uri = ::std::string::String::new();
245                uri_base(input, &mut uri)?;
246                ::std::result::Result::Ok(builder.method("POST").uri(uri))
247            }
248            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
249            builder =
250                _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-www-form-urlencoded");
251            builder
252        };
253        let body = ::aws_smithy_types::body::SdkBody::from(
254            crate::protocol_serde::shape_get_federation_token_input::ser_get_federation_token_input_input_input(&input)?,
255        );
256        if let Some(content_length) = body.content_length() {
257            let content_length = content_length.to_string();
258            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
259        }
260        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
261    }
262}
263#[derive(Debug)]
264struct GetFederationTokenEndpointParamsInterceptor;
265
266#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
267impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetFederationTokenEndpointParamsInterceptor {
268    fn name(&self) -> &'static str {
269        "GetFederationTokenEndpointParamsInterceptor"
270    }
271
272    fn read_before_execution(
273        &self,
274        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
275            '_,
276            ::aws_smithy_runtime_api::client::interceptors::context::Input,
277            ::aws_smithy_runtime_api::client::interceptors::context::Output,
278            ::aws_smithy_runtime_api::client::interceptors::context::Error,
279        >,
280        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
281    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
282        let _input = context
283            .input()
284            .downcast_ref::<GetFederationTokenInput>()
285            .ok_or("failed to downcast to GetFederationTokenInput")?;
286
287        let params = crate::config::endpoint::Params::builder()
288            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
289            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
290            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
291            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
292            .build()
293            .map_err(|err| {
294                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
295            })?;
296        cfg.interceptor_state()
297            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
298        ::std::result::Result::Ok(())
299    }
300}
301
302// The get_* functions below are generated from JMESPath expressions in the
303// operationContextParams trait. They target the operation's input shape.
304
305/// Error type for the `GetFederationTokenError` operation.
306#[non_exhaustive]
307#[derive(::std::fmt::Debug)]
308pub enum GetFederationTokenError {
309    /// <p>The request was rejected because the policy document was malformed. The error message describes the specific error.</p>
310    MalformedPolicyDocumentException(crate::types::error::MalformedPolicyDocumentException),
311    /// <p>The request was rejected because the total packed size of the session policies and session tags combined was too large. An Amazon Web Services conversion compresses the session policy document, session policy ARNs, and session tags into a packed binary format that has a separate limit. The error message indicates by percentage how close the policies and tags are to the upper size limit. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html">Passing Session Tags in STS</a> in the <i>IAM User Guide</i>.</p>
312    /// <p>You could receive this error even though you meet other defined session policy and session tag limits. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-limits-entity-length">IAM and STS Entity Character Limits</a> in the <i>IAM User Guide</i>.</p>
313    PackedPolicyTooLargeException(crate::types::error::PackedPolicyTooLargeException),
314    /// <p>STS is not activated in the requested region for the account that is being asked to generate credentials. The account administrator must use the IAM console to activate STS in that region. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html#sts-regions-activate-deactivate">Activating and Deactivating STS in an Amazon Web Services Region</a> in the <i>IAM User Guide</i>.</p>
315    RegionDisabledException(crate::types::error::RegionDisabledException),
316    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
317    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
318    variable wildcard pattern and check `.code()`:
319     \
320    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
321     \
322    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetFederationTokenError) for what information is available for the error.")]
323    Unhandled(crate::error::sealed_unhandled::Unhandled),
324}
325impl GetFederationTokenError {
326    /// Creates the `GetFederationTokenError::Unhandled` variant from any error type.
327    pub fn unhandled(
328        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
329    ) -> Self {
330        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
331            source: err.into(),
332            meta: ::std::default::Default::default(),
333        })
334    }
335
336    /// Creates the `GetFederationTokenError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
337    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
338        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
339            source: err.clone().into(),
340            meta: err,
341        })
342    }
343    ///
344    /// Returns error metadata, which includes the error code, message,
345    /// request ID, and potentially additional information.
346    ///
347    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
348        match self {
349            Self::MalformedPolicyDocumentException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
350            Self::PackedPolicyTooLargeException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
351            Self::RegionDisabledException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
352            Self::Unhandled(e) => &e.meta,
353        }
354    }
355    /// Returns `true` if the error kind is `GetFederationTokenError::MalformedPolicyDocumentException`.
356    pub fn is_malformed_policy_document_exception(&self) -> bool {
357        matches!(self, Self::MalformedPolicyDocumentException(_))
358    }
359    /// Returns `true` if the error kind is `GetFederationTokenError::PackedPolicyTooLargeException`.
360    pub fn is_packed_policy_too_large_exception(&self) -> bool {
361        matches!(self, Self::PackedPolicyTooLargeException(_))
362    }
363    /// Returns `true` if the error kind is `GetFederationTokenError::RegionDisabledException`.
364    pub fn is_region_disabled_exception(&self) -> bool {
365        matches!(self, Self::RegionDisabledException(_))
366    }
367}
368impl ::std::error::Error for GetFederationTokenError {
369    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
370        match self {
371            Self::MalformedPolicyDocumentException(_inner) => ::std::option::Option::Some(_inner),
372            Self::PackedPolicyTooLargeException(_inner) => ::std::option::Option::Some(_inner),
373            Self::RegionDisabledException(_inner) => ::std::option::Option::Some(_inner),
374            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
375        }
376    }
377}
378impl ::std::fmt::Display for GetFederationTokenError {
379    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
380        match self {
381            Self::MalformedPolicyDocumentException(_inner) => _inner.fmt(f),
382            Self::PackedPolicyTooLargeException(_inner) => _inner.fmt(f),
383            Self::RegionDisabledException(_inner) => _inner.fmt(f),
384            Self::Unhandled(_inner) => {
385                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
386                    write!(f, "unhandled error ({code})")
387                } else {
388                    f.write_str("unhandled error")
389                }
390            }
391        }
392    }
393}
394impl ::aws_smithy_types::retry::ProvideErrorKind for GetFederationTokenError {
395    fn code(&self) -> ::std::option::Option<&str> {
396        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
397    }
398    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
399        ::std::option::Option::None
400    }
401}
402impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetFederationTokenError {
403    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
404        match self {
405            Self::MalformedPolicyDocumentException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
406            Self::PackedPolicyTooLargeException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
407            Self::RegionDisabledException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
408            Self::Unhandled(_inner) => &_inner.meta,
409        }
410    }
411}
412impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetFederationTokenError {
413    fn create_unhandled_error(
414        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
415        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
416    ) -> Self {
417        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
418            source,
419            meta: meta.unwrap_or_default(),
420        })
421    }
422}
423impl ::aws_types::request_id::RequestId for crate::operation::get_federation_token::GetFederationTokenError {
424    fn request_id(&self) -> Option<&str> {
425        self.meta().request_id()
426    }
427}
428
429pub use crate::operation::get_federation_token::_get_federation_token_input::GetFederationTokenInput;
430
431pub use crate::operation::get_federation_token::_get_federation_token_output::GetFederationTokenOutput;
432
433mod _get_federation_token_input;
434
435mod _get_federation_token_output;
436
437/// Builders
438pub mod builders;