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