Skip to main content

aws_sdk_sso/operation/
logout.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `Logout`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct Logout;
6impl Logout {
7    /// Creates a new `Logout`
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::logout::LogoutInput,
14    ) -> ::std::result::Result<
15        crate::operation::logout::LogoutOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::logout::LogoutError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err =
22            |err: ::aws_smithy_runtime_api::client::result::SdkError<
23                ::aws_smithy_runtime_api::client::interceptors::context::Error,
24                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
25            >| { err.map_service_error(|err| err.downcast::<crate::operation::logout::LogoutError>().expect("correct error type")) };
26        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
27            .await
28            .map_err(map_err)?;
29        let output = context.finalize().map_err(map_err)?;
30        ::std::result::Result::Ok(output.downcast::<crate::operation::logout::LogoutOutput>().expect("correct output type"))
31    }
32
33    pub(crate) async fn orchestrate_with_stop_point(
34        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
35        input: crate::operation::logout::LogoutInput,
36        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
37    ) -> ::std::result::Result<
38        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
39        ::aws_smithy_runtime_api::client::result::SdkError<
40            ::aws_smithy_runtime_api::client::interceptors::context::Error,
41            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
42        >,
43    > {
44        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
45        use ::tracing::Instrument;
46        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("SSO", "Logout", input, runtime_plugins, stop_point)
47            // Create a parent span for the entire operation. Includes a random, internal-only,
48            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
49            .instrument(::tracing::debug_span!(
50                "SSO.Logout",
51                "rpc.service" = "SSO",
52                "rpc.method" = "Logout",
53                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
54                "rpc.system" = "aws-api",
55            ))
56            .await
57    }
58
59    pub(crate) fn operation_runtime_plugins(
60        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
61        client_config: &crate::config::Config,
62        config_override: ::std::option::Option<crate::config::Builder>,
63    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
64        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
65
66        if let ::std::option::Option::Some(config_override) = config_override {
67            for plugin in config_override.runtime_plugins.iter().cloned() {
68                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
69            }
70            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
71                config_override,
72                client_config.config.clone(),
73                &client_config.runtime_components,
74            ));
75        }
76        runtime_plugins
77    }
78}
79impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for Logout {
80    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
81        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("Logout");
82
83        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
84            LogoutRequestSerializer,
85        ));
86        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
87            LogoutResponseDeserializer,
88        ));
89
90        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
91            crate::config::auth::Params::builder()
92                .operation_name("Logout")
93                .build()
94                .expect("required fields set"),
95        ));
96
97        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("Logout", "SSO"));
98
99        ::std::option::Option::Some(cfg.freeze())
100    }
101
102    fn runtime_components(
103        &self,
104        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
105    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
106        #[allow(unused_mut)]
107        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("Logout")
108            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
109                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
110            ))
111            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
112                LogoutEndpointParamsInterceptor,
113            ))
114            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
115                crate::operation::logout::LogoutError,
116            >::new())
117            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
118                crate::operation::logout::LogoutError,
119            >::new())
120            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
121                crate::operation::logout::LogoutError,
122            >::new())
123            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
124                crate::operation::logout::LogoutError,
125            >::new());
126
127        ::std::borrow::Cow::Owned(rcb)
128    }
129}
130
131#[derive(Debug)]
132struct LogoutResponseDeserializer;
133impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for LogoutResponseDeserializer {
134    fn deserialize_nonstreaming_with_config(
135        &self,
136        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
137        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
138    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
139        let (success, status) = (response.status().is_success(), response.status().as_u16());
140        let headers = response.headers();
141        let body = response.body().bytes().expect("body loaded");
142        #[allow(unused_mut)]
143        let mut force_error = false;
144        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
145        let parse_result = if !success && status != 200 || force_error {
146            crate::protocol_serde::shape_logout::de_logout_http_error(status, headers, body, _cfg)
147        } else {
148            crate::protocol_serde::shape_logout::de_logout_http_response(status, headers, body, _cfg)
149        };
150        crate::protocol_serde::type_erase_result(parse_result)
151    }
152}
153#[derive(Debug)]
154struct LogoutRequestSerializer;
155impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for LogoutRequestSerializer {
156    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
157    fn serialize_input(
158        &self,
159        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
160        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
161    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
162        let input = input.downcast::<crate::operation::logout::LogoutInput>().expect("correct type");
163        let _header_serialization_settings = _cfg
164            .load::<crate::serialization_settings::HeaderSerializationSettings>()
165            .cloned()
166            .unwrap_or_default();
167        let mut request_builder = {
168            #[allow(clippy::uninlined_format_args)]
169            fn uri_base(
170                _input: &crate::operation::logout::LogoutInput,
171                output: &mut ::std::string::String,
172            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
173                use ::std::fmt::Write as _;
174                ::std::write!(output, "/logout").expect("formatting should succeed");
175                ::std::result::Result::Ok(())
176            }
177            #[allow(clippy::unnecessary_wraps)]
178            fn update_http_builder(
179                input: &crate::operation::logout::LogoutInput,
180                builder: ::http_1x::request::Builder,
181            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
182                let mut uri = ::std::string::String::new();
183                uri_base(input, &mut uri)?;
184                let builder = crate::protocol_serde::shape_logout::ser_logout_headers(input, builder)?;
185                ::std::result::Result::Ok(builder.method("POST").uri(uri))
186            }
187            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
188            builder
189        };
190        let body = ::aws_smithy_types::body::SdkBody::from("");
191
192        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
193    }
194}
195#[derive(Debug)]
196struct LogoutEndpointParamsInterceptor;
197
198#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
199impl ::aws_smithy_runtime_api::client::interceptors::Intercept for LogoutEndpointParamsInterceptor {
200    fn name(&self) -> &'static str {
201        "LogoutEndpointParamsInterceptor"
202    }
203
204    fn read_before_execution(
205        &self,
206        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
207            '_,
208            ::aws_smithy_runtime_api::client::interceptors::context::Input,
209            ::aws_smithy_runtime_api::client::interceptors::context::Output,
210            ::aws_smithy_runtime_api::client::interceptors::context::Error,
211        >,
212        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
213    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
214        let _input = context.input().downcast_ref::<LogoutInput>().ok_or("failed to downcast to LogoutInput")?;
215
216        let params = crate::config::endpoint::Params::builder()
217            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
218            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
219            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
220            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
221            .build()
222            .map_err(|err| {
223                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
224            })?;
225        cfg.interceptor_state()
226            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
227        ::std::result::Result::Ok(())
228    }
229}
230
231// The get_* functions below are generated from JMESPath expressions in the
232// operationContextParams trait. They target the operation's input shape.
233
234/// Error type for the `LogoutError` operation.
235#[non_exhaustive]
236#[derive(::std::fmt::Debug)]
237pub enum LogoutError {
238    /// <p>Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.</p>
239    InvalidRequestException(crate::types::error::InvalidRequestException),
240    /// <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
241    TooManyRequestsException(crate::types::error::TooManyRequestsException),
242    /// <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
243    UnauthorizedException(crate::types::error::UnauthorizedException),
244    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
245    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
246    variable wildcard pattern and check `.code()`:
247     \
248    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
249     \
250    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-LogoutError) for what information is available for the error.")]
251    Unhandled(crate::error::sealed_unhandled::Unhandled),
252}
253impl LogoutError {
254    /// Creates the `LogoutError::Unhandled` variant from any error type.
255    pub fn unhandled(
256        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
257    ) -> Self {
258        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
259            source: err.into(),
260            meta: ::std::default::Default::default(),
261        })
262    }
263
264    /// Creates the `LogoutError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
265    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
266        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
267            source: err.clone().into(),
268            meta: err,
269        })
270    }
271    ///
272    /// Returns error metadata, which includes the error code, message,
273    /// request ID, and potentially additional information.
274    ///
275    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
276        match self {
277            Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
278            Self::TooManyRequestsException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
279            Self::UnauthorizedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
280            Self::Unhandled(e) => &e.meta,
281        }
282    }
283    /// Returns `true` if the error kind is `LogoutError::InvalidRequestException`.
284    pub fn is_invalid_request_exception(&self) -> bool {
285        matches!(self, Self::InvalidRequestException(_))
286    }
287    /// Returns `true` if the error kind is `LogoutError::TooManyRequestsException`.
288    pub fn is_too_many_requests_exception(&self) -> bool {
289        matches!(self, Self::TooManyRequestsException(_))
290    }
291    /// Returns `true` if the error kind is `LogoutError::UnauthorizedException`.
292    pub fn is_unauthorized_exception(&self) -> bool {
293        matches!(self, Self::UnauthorizedException(_))
294    }
295}
296impl ::std::error::Error for LogoutError {
297    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
298        match self {
299            Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
300            Self::TooManyRequestsException(_inner) => ::std::option::Option::Some(_inner),
301            Self::UnauthorizedException(_inner) => ::std::option::Option::Some(_inner),
302            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
303        }
304    }
305}
306impl ::std::fmt::Display for LogoutError {
307    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
308        match self {
309            Self::InvalidRequestException(_inner) => _inner.fmt(f),
310            Self::TooManyRequestsException(_inner) => _inner.fmt(f),
311            Self::UnauthorizedException(_inner) => _inner.fmt(f),
312            Self::Unhandled(_inner) => {
313                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
314                    write!(f, "unhandled error ({code})")
315                } else {
316                    f.write_str("unhandled error")
317                }
318            }
319        }
320    }
321}
322impl ::aws_smithy_types::retry::ProvideErrorKind for LogoutError {
323    fn code(&self) -> ::std::option::Option<&str> {
324        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
325    }
326    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
327        ::std::option::Option::None
328    }
329}
330impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for LogoutError {
331    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
332        match self {
333            Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
334            Self::TooManyRequestsException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
335            Self::UnauthorizedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
336            Self::Unhandled(_inner) => &_inner.meta,
337        }
338    }
339}
340impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for LogoutError {
341    fn create_unhandled_error(
342        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
343        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
344    ) -> Self {
345        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
346            source,
347            meta: meta.unwrap_or_default(),
348        })
349    }
350}
351impl ::aws_types::request_id::RequestId for crate::operation::logout::LogoutError {
352    fn request_id(&self) -> Option<&str> {
353        self.meta().request_id()
354    }
355}
356
357pub use crate::operation::logout::_logout_input::LogoutInput;
358
359pub use crate::operation::logout::_logout_output::LogoutOutput;
360
361mod _logout_input;
362
363mod _logout_output;
364
365/// Builders
366pub mod builders;