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