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/// Error type for the `LogoutError` operation.
210#[non_exhaustive]
211#[derive(::std::fmt::Debug)]
212pub enum LogoutError {
213    /// <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>
214    InvalidRequestException(crate::types::error::InvalidRequestException),
215    /// <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
216    TooManyRequestsException(crate::types::error::TooManyRequestsException),
217    /// <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
218    UnauthorizedException(crate::types::error::UnauthorizedException),
219    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
220    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
221    variable wildcard pattern and check `.code()`:
222     \
223    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
224     \
225    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-LogoutError) for what information is available for the error.")]
226    Unhandled(crate::error::sealed_unhandled::Unhandled),
227}
228impl LogoutError {
229    /// Creates the `LogoutError::Unhandled` variant from any error type.
230    pub fn unhandled(
231        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
232    ) -> Self {
233        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
234            source: err.into(),
235            meta: ::std::default::Default::default(),
236        })
237    }
238
239    /// Creates the `LogoutError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
240    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
241        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
242            source: err.clone().into(),
243            meta: err,
244        })
245    }
246    ///
247    /// Returns error metadata, which includes the error code, message,
248    /// request ID, and potentially additional information.
249    ///
250    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
251        match self {
252            Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
253            Self::TooManyRequestsException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
254            Self::UnauthorizedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
255            Self::Unhandled(e) => &e.meta,
256        }
257    }
258    /// Returns `true` if the error kind is `LogoutError::InvalidRequestException`.
259    pub fn is_invalid_request_exception(&self) -> bool {
260        matches!(self, Self::InvalidRequestException(_))
261    }
262    /// Returns `true` if the error kind is `LogoutError::TooManyRequestsException`.
263    pub fn is_too_many_requests_exception(&self) -> bool {
264        matches!(self, Self::TooManyRequestsException(_))
265    }
266    /// Returns `true` if the error kind is `LogoutError::UnauthorizedException`.
267    pub fn is_unauthorized_exception(&self) -> bool {
268        matches!(self, Self::UnauthorizedException(_))
269    }
270}
271impl ::std::error::Error for LogoutError {
272    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
273        match self {
274            Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
275            Self::TooManyRequestsException(_inner) => ::std::option::Option::Some(_inner),
276            Self::UnauthorizedException(_inner) => ::std::option::Option::Some(_inner),
277            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
278        }
279    }
280}
281impl ::std::fmt::Display for LogoutError {
282    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
283        match self {
284            Self::InvalidRequestException(_inner) => _inner.fmt(f),
285            Self::TooManyRequestsException(_inner) => _inner.fmt(f),
286            Self::UnauthorizedException(_inner) => _inner.fmt(f),
287            Self::Unhandled(_inner) => {
288                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
289                    write!(f, "unhandled error ({code})")
290                } else {
291                    f.write_str("unhandled error")
292                }
293            }
294        }
295    }
296}
297impl ::aws_smithy_types::retry::ProvideErrorKind for LogoutError {
298    fn code(&self) -> ::std::option::Option<&str> {
299        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
300    }
301    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
302        ::std::option::Option::None
303    }
304}
305impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for LogoutError {
306    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
307        match self {
308            Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
309            Self::TooManyRequestsException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
310            Self::UnauthorizedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
311            Self::Unhandled(_inner) => &_inner.meta,
312        }
313    }
314}
315impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for LogoutError {
316    fn create_unhandled_error(
317        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
318        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
319    ) -> Self {
320        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
321            source,
322            meta: meta.unwrap_or_default(),
323        })
324    }
325}
326impl ::aws_types::request_id::RequestId for crate::operation::logout::LogoutError {
327    fn request_id(&self) -> Option<&str> {
328        self.meta().request_id()
329    }
330}
331
332pub use crate::operation::logout::_logout_output::LogoutOutput;
333
334pub use crate::operation::logout::_logout_input::LogoutInput;
335
336mod _logout_input;
337
338mod _logout_output;
339
340/// Builders
341pub mod builders;