Skip to main content

aws_sdk_sso/operation/
list_accounts.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `ListAccounts`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ListAccounts;
6impl ListAccounts {
7    /// Creates a new `ListAccounts`
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::list_accounts::ListAccountsInput,
14    ) -> ::std::result::Result<
15        crate::operation::list_accounts::ListAccountsOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::list_accounts::ListAccountsError,
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::list_accounts::ListAccountsError>()
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::list_accounts::ListAccountsOutput>()
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::list_accounts::ListAccountsInput,
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("SSO", "ListAccounts", 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                "SSO.ListAccounts",
59                "rpc.service" = "SSO",
60                "rpc.method" = "ListAccounts",
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 ListAccounts {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ListAccounts");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            ListAccountsRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            ListAccountsResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("ListAccounts")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("ListAccounts", "SSO"));
106
107        ::std::option::Option::Some(cfg.freeze())
108    }
109
110    fn runtime_components(
111        &self,
112        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
113    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
114        #[allow(unused_mut)]
115        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ListAccounts")
116            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
117                ListAccountsTelemetryInputCaptureInterceptor,
118            ))
119            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
120                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
121            ))
122            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
123                ListAccountsEndpointParamsInterceptor,
124            ))
125            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
126                crate::operation::list_accounts::ListAccountsError,
127            >::new())
128            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
129                crate::operation::list_accounts::ListAccountsError,
130            >::new())
131            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
132                crate::operation::list_accounts::ListAccountsError,
133            >::new())
134            .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
135                crate::operation::list_accounts::ListAccountsError,
136            >::new());
137
138        ::std::borrow::Cow::Owned(rcb)
139    }
140}
141
142#[derive(Debug)]
143struct ListAccountsTelemetryInputCaptureInterceptor;
144
145#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
146impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListAccountsTelemetryInputCaptureInterceptor {
147    fn name(&self) -> &'static str {
148        "ListAccountsTelemetryInputCaptureInterceptor"
149    }
150
151    fn read_before_execution(
152        &self,
153        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
154            '_,
155            ::aws_smithy_runtime_api::client::interceptors::context::Input,
156            ::aws_smithy_runtime_api::client::interceptors::context::Output,
157            ::aws_smithy_runtime_api::client::interceptors::context::Error,
158        >,
159        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
160    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
161        // Nothing to do unless the customer opted in by naming members to record.
162        let ::std::option::Option::Some(requested) = cfg
163            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
164            .filter(|r| !r.is_empty())
165        else {
166            return ::std::result::Result::Ok(());
167        };
168
169        let ::std::option::Option::Some(input) = context.input().downcast_ref::<ListAccountsInput>() else {
170            // A mismatched input is not this interceptor's concern; skip quietly.
171            return ::std::result::Result::Ok(());
172        };
173
174        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
175        if requested.should_capture("nextToken") {
176            if let ::std::option::Option::Some(value) = input.next_token.as_deref() {
177                captured.insert("nextToken", value);
178            }
179        }
180
181        cfg.interceptor_state().store_put(captured);
182        ::std::result::Result::Ok(())
183    }
184}
185#[derive(Debug)]
186struct ListAccountsResponseDeserializer;
187impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ListAccountsResponseDeserializer {
188    fn deserialize_nonstreaming_with_config(
189        &self,
190        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
191        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
192    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
193        let (success, status) = (response.status().is_success(), response.status().as_u16());
194        let headers = response.headers();
195        let body = response.body().bytes().expect("body loaded");
196        #[allow(unused_mut)]
197        let mut force_error = false;
198        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
199        let parse_result = if !success && status != 200 || force_error {
200            crate::protocol_serde::shape_list_accounts::de_list_accounts_http_error(status, headers, body, _cfg)
201        } else {
202            crate::protocol_serde::shape_list_accounts::de_list_accounts_http_response(status, headers, body, _cfg)
203        };
204        crate::protocol_serde::type_erase_result(parse_result)
205    }
206}
207#[derive(Debug)]
208struct ListAccountsRequestSerializer;
209impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ListAccountsRequestSerializer {
210    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
211    fn serialize_input(
212        &self,
213        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
214        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
215    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
216        let input = input
217            .downcast::<crate::operation::list_accounts::ListAccountsInput>()
218            .expect("correct type");
219        let _header_serialization_settings = _cfg
220            .load::<crate::serialization_settings::HeaderSerializationSettings>()
221            .cloned()
222            .unwrap_or_default();
223        let mut request_builder = {
224            #[allow(clippy::uninlined_format_args)]
225            fn uri_base(
226                _input: &crate::operation::list_accounts::ListAccountsInput,
227                output: &mut ::std::string::String,
228            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
229                use ::std::fmt::Write as _;
230                ::std::write!(output, "/assignment/accounts").expect("formatting should succeed");
231                ::std::result::Result::Ok(())
232            }
233            fn uri_query(
234                _input: &crate::operation::list_accounts::ListAccountsInput,
235                mut output: &mut ::std::string::String,
236            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
237                let mut query = ::aws_smithy_http::query::Writer::new(output);
238                if let ::std::option::Option::Some(inner_1) = &_input.next_token {
239                    {
240                        query.push_kv("next_token", &::aws_smithy_http::query::fmt_string(inner_1));
241                    }
242                }
243                if let ::std::option::Option::Some(inner_2) = &_input.max_results {
244                    {
245                        query.push_kv("max_result", ::aws_smithy_types::primitive::Encoder::from(*inner_2).encode());
246                    }
247                }
248                ::std::result::Result::Ok(())
249            }
250            #[allow(clippy::unnecessary_wraps)]
251            fn update_http_builder(
252                input: &crate::operation::list_accounts::ListAccountsInput,
253                builder: ::http_1x::request::Builder,
254            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
255                let mut uri = ::std::string::String::new();
256                uri_base(input, &mut uri)?;
257                uri_query(input, &mut uri)?;
258                let builder = crate::protocol_serde::shape_list_accounts::ser_list_accounts_headers(input, builder)?;
259                ::std::result::Result::Ok(builder.method("GET").uri(uri))
260            }
261            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
262            builder
263        };
264        let body = ::aws_smithy_types::body::SdkBody::from("");
265
266        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
267    }
268}
269#[derive(Debug)]
270struct ListAccountsEndpointParamsInterceptor;
271
272#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
273impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListAccountsEndpointParamsInterceptor {
274    fn name(&self) -> &'static str {
275        "ListAccountsEndpointParamsInterceptor"
276    }
277
278    fn read_before_execution(
279        &self,
280        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
281            '_,
282            ::aws_smithy_runtime_api::client::interceptors::context::Input,
283            ::aws_smithy_runtime_api::client::interceptors::context::Output,
284            ::aws_smithy_runtime_api::client::interceptors::context::Error,
285        >,
286        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
287    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
288        let _input = context
289            .input()
290            .downcast_ref::<ListAccountsInput>()
291            .ok_or("failed to downcast to ListAccountsInput")?;
292
293        let params = crate::config::endpoint::Params::builder()
294            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
295            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
296            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
297            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
298            .build()
299            .map_err(|err| {
300                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
301            })?;
302        cfg.interceptor_state()
303            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
304        ::std::result::Result::Ok(())
305    }
306}
307
308// The get_* functions below are generated from JMESPath expressions in the
309// operationContextParams trait. They target the operation's input shape.
310
311/// Error type for the `ListAccountsError` operation.
312#[non_exhaustive]
313#[derive(::std::fmt::Debug)]
314pub enum ListAccountsError {
315    /// <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>
316    InvalidRequestException(crate::types::error::InvalidRequestException),
317    /// <p>The specified resource doesn't exist.</p>
318    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
319    /// <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
320    TooManyRequestsException(crate::types::error::TooManyRequestsException),
321    /// <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
322    UnauthorizedException(crate::types::error::UnauthorizedException),
323    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
324    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
325    variable wildcard pattern and check `.code()`:
326     \
327    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
328     \
329    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ListAccountsError) for what information is available for the error.")]
330    Unhandled(crate::error::sealed_unhandled::Unhandled),
331}
332impl ListAccountsError {
333    /// Creates the `ListAccountsError::Unhandled` variant from any error type.
334    pub fn unhandled(
335        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
336    ) -> Self {
337        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
338            source: err.into(),
339            meta: ::std::default::Default::default(),
340        })
341    }
342
343    /// Creates the `ListAccountsError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
344    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
345        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
346            source: err.clone().into(),
347            meta: err,
348        })
349    }
350    ///
351    /// Returns error metadata, which includes the error code, message,
352    /// request ID, and potentially additional information.
353    ///
354    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
355        match self {
356            Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
357            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
358            Self::TooManyRequestsException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
359            Self::UnauthorizedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
360            Self::Unhandled(e) => &e.meta,
361        }
362    }
363    /// Returns `true` if the error kind is `ListAccountsError::InvalidRequestException`.
364    pub fn is_invalid_request_exception(&self) -> bool {
365        matches!(self, Self::InvalidRequestException(_))
366    }
367    /// Returns `true` if the error kind is `ListAccountsError::ResourceNotFoundException`.
368    pub fn is_resource_not_found_exception(&self) -> bool {
369        matches!(self, Self::ResourceNotFoundException(_))
370    }
371    /// Returns `true` if the error kind is `ListAccountsError::TooManyRequestsException`.
372    pub fn is_too_many_requests_exception(&self) -> bool {
373        matches!(self, Self::TooManyRequestsException(_))
374    }
375    /// Returns `true` if the error kind is `ListAccountsError::UnauthorizedException`.
376    pub fn is_unauthorized_exception(&self) -> bool {
377        matches!(self, Self::UnauthorizedException(_))
378    }
379}
380impl ::std::error::Error for ListAccountsError {
381    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
382        match self {
383            Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
384            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
385            Self::TooManyRequestsException(_inner) => ::std::option::Option::Some(_inner),
386            Self::UnauthorizedException(_inner) => ::std::option::Option::Some(_inner),
387            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
388        }
389    }
390}
391impl ::std::fmt::Display for ListAccountsError {
392    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
393        match self {
394            Self::InvalidRequestException(_inner) => _inner.fmt(f),
395            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
396            Self::TooManyRequestsException(_inner) => _inner.fmt(f),
397            Self::UnauthorizedException(_inner) => _inner.fmt(f),
398            Self::Unhandled(_inner) => {
399                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
400                    write!(f, "unhandled error ({code})")
401                } else {
402                    f.write_str("unhandled error")
403                }
404            }
405        }
406    }
407}
408impl ::aws_smithy_types::retry::ProvideErrorKind for ListAccountsError {
409    fn code(&self) -> ::std::option::Option<&str> {
410        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
411    }
412    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
413        ::std::option::Option::None
414    }
415}
416impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ListAccountsError {
417    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
418        match self {
419            Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
420            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
421            Self::TooManyRequestsException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
422            Self::UnauthorizedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
423            Self::Unhandled(_inner) => &_inner.meta,
424        }
425    }
426}
427impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ListAccountsError {
428    fn create_unhandled_error(
429        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
430        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
431    ) -> Self {
432        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
433            source,
434            meta: meta.unwrap_or_default(),
435        })
436    }
437}
438impl ::aws_types::request_id::RequestId for crate::operation::list_accounts::ListAccountsError {
439    fn request_id(&self) -> Option<&str> {
440        self.meta().request_id()
441    }
442}
443
444pub use crate::operation::list_accounts::_list_accounts_input::ListAccountsInput;
445
446pub use crate::operation::list_accounts::_list_accounts_output::ListAccountsOutput;
447
448mod _list_accounts_input;
449
450mod _list_accounts_output;
451
452/// Builders
453pub mod builders;
454
455/// Paginator for this operation
456pub mod paginator;