Skip to main content

aws_sdk_chime/operation/
get_user.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetUser`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetUser;
6impl GetUser {
7    /// Creates a new `GetUser`
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::get_user::GetUserInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_user::GetUserOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_user::GetUserError,
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::get_user::GetUserError>().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(
31            output
32                .downcast::<crate::operation::get_user::GetUserOutput>()
33                .expect("correct output type"),
34        )
35    }
36
37    pub(crate) async fn orchestrate_with_stop_point(
38        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
39        input: crate::operation::get_user::GetUserInput,
40        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
41    ) -> ::std::result::Result<
42        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
43        ::aws_smithy_runtime_api::client::result::SdkError<
44            ::aws_smithy_runtime_api::client::interceptors::context::Error,
45            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
46        >,
47    > {
48        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
49        use ::tracing::Instrument;
50        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Chime", "GetUser", input, runtime_plugins, stop_point)
51            // Create a parent span for the entire operation. Includes a random, internal-only,
52            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
53            .instrument(::tracing::debug_span!(
54                "Chime.GetUser",
55                "rpc.service" = "Chime",
56                "rpc.method" = "GetUser",
57                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
58                "rpc.system" = "aws-api",
59            ))
60            .await
61    }
62
63    pub(crate) fn operation_runtime_plugins(
64        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
65        client_config: &crate::config::Config,
66        config_override: ::std::option::Option<crate::config::Builder>,
67    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
68        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
69
70        if let ::std::option::Option::Some(config_override) = config_override {
71            for plugin in config_override.runtime_plugins.iter().cloned() {
72                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
73            }
74            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
75                config_override,
76                client_config.config.clone(),
77                &client_config.runtime_components,
78            ));
79        }
80        runtime_plugins
81    }
82}
83impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetUser {
84    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
85        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetUser");
86
87        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
88            GetUserRequestSerializer,
89        ));
90        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
91            GetUserResponseDeserializer,
92        ));
93
94        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
95            crate::config::auth::Params::builder()
96                .operation_name("GetUser")
97                .build()
98                .expect("required fields set"),
99        ));
100
101        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
102        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetUser", "Chime"));
103        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
104        signing_options.double_uri_encode = true;
105        signing_options.content_sha256_header = false;
106        signing_options.normalize_uri_path = true;
107        signing_options.payload_override = None;
108
109        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
110            signing_options,
111            ..::std::default::Default::default()
112        });
113
114        ::std::option::Option::Some(cfg.freeze())
115    }
116
117    fn runtime_components(
118        &self,
119        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
120    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
121        #[allow(unused_mut)]
122        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetUser")
123            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
124                ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
125            ))
126            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
127                GetUserEndpointParamsInterceptor,
128            ))
129            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
130                crate::operation::get_user::GetUserError,
131            >::new())
132            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
133                crate::operation::get_user::GetUserError,
134            >::new())
135            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
136                crate::operation::get_user::GetUserError,
137            >::new());
138
139        ::std::borrow::Cow::Owned(rcb)
140    }
141}
142
143#[derive(Debug)]
144struct GetUserResponseDeserializer;
145impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetUserResponseDeserializer {
146    fn deserialize_nonstreaming_with_config(
147        &self,
148        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
149        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
150    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
151        let (success, status) = (response.status().is_success(), response.status().as_u16());
152        let headers = response.headers();
153        let body = response.body().bytes().expect("body loaded");
154        #[allow(unused_mut)]
155        let mut force_error = false;
156        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
157        let parse_result = if !success && status != 200 || force_error {
158            crate::protocol_serde::shape_get_user::de_get_user_http_error(status, headers, body)
159        } else {
160            crate::protocol_serde::shape_get_user::de_get_user_http_response(status, headers, body)
161        };
162        crate::protocol_serde::type_erase_result(parse_result)
163    }
164}
165#[derive(Debug)]
166struct GetUserRequestSerializer;
167impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetUserRequestSerializer {
168    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
169    fn serialize_input(
170        &self,
171        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
172        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
173    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
174        let input = input.downcast::<crate::operation::get_user::GetUserInput>().expect("correct type");
175        let _header_serialization_settings = _cfg
176            .load::<crate::serialization_settings::HeaderSerializationSettings>()
177            .cloned()
178            .unwrap_or_default();
179        let mut request_builder = {
180            #[allow(clippy::uninlined_format_args)]
181            fn uri_base(
182                _input: &crate::operation::get_user::GetUserInput,
183                output: &mut ::std::string::String,
184            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
185                use ::std::fmt::Write as _;
186                let input_1 = &_input.account_id;
187                let input_1 = input_1
188                    .as_ref()
189                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("account_id", "cannot be empty or unset"))?;
190                let account_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
191                if account_id.is_empty() {
192                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
193                        "account_id",
194                        "cannot be empty or unset",
195                    ));
196                }
197                let input_2 = &_input.user_id;
198                let input_2 = input_2
199                    .as_ref()
200                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("user_id", "cannot be empty or unset"))?;
201                let user_id = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
202                if user_id.is_empty() {
203                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
204                        "user_id",
205                        "cannot be empty or unset",
206                    ));
207                }
208                ::std::write!(output, "/accounts/{AccountId}/users/{UserId}", AccountId = account_id, UserId = user_id)
209                    .expect("formatting should succeed");
210                ::std::result::Result::Ok(())
211            }
212            #[allow(clippy::unnecessary_wraps)]
213            fn update_http_builder(
214                input: &crate::operation::get_user::GetUserInput,
215                builder: ::http_1x::request::Builder,
216            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
217                let mut uri = ::std::string::String::new();
218                uri_base(input, &mut uri)?;
219                ::std::result::Result::Ok(builder.method("GET").uri(uri))
220            }
221            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
222            builder
223        };
224        let body = ::aws_smithy_types::body::SdkBody::from("");
225
226        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
227    }
228}
229#[derive(Debug)]
230struct GetUserEndpointParamsInterceptor;
231
232#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
233impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetUserEndpointParamsInterceptor {
234    fn name(&self) -> &'static str {
235        "GetUserEndpointParamsInterceptor"
236    }
237
238    fn read_before_execution(
239        &self,
240        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
241            '_,
242            ::aws_smithy_runtime_api::client::interceptors::context::Input,
243            ::aws_smithy_runtime_api::client::interceptors::context::Output,
244            ::aws_smithy_runtime_api::client::interceptors::context::Error,
245        >,
246        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
247    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
248        let _input = context
249            .input()
250            .downcast_ref::<GetUserInput>()
251            .ok_or("failed to downcast to GetUserInput")?;
252
253        let params = crate::config::endpoint::Params::builder()
254            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
255            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
256            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
257            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
258            .build()
259            .map_err(|err| {
260                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
261            })?;
262        cfg.interceptor_state()
263            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
264        ::std::result::Result::Ok(())
265    }
266}
267
268// The get_* functions below are generated from JMESPath expressions in the
269// operationContextParams trait. They target the operation's input shape.
270
271/// Error type for the `GetUserError` operation.
272#[non_exhaustive]
273#[derive(::std::fmt::Debug)]
274pub enum GetUserError {
275    /// <p>The input parameters don't match the service's restrictions.</p>
276    BadRequestException(crate::types::error::BadRequestException),
277    /// <p>The client is permanently forbidden from making the request.</p>
278    ForbiddenException(crate::types::error::ForbiddenException),
279    /// <p>One or more of the resources in the request does not exist in the system.</p>
280    NotFoundException(crate::types::error::NotFoundException),
281    /// <p>The service encountered an unexpected error.</p>
282    ServiceFailureException(crate::types::error::ServiceFailureException),
283    /// <p>The service is currently unavailable.</p>
284    ServiceUnavailableException(crate::types::error::ServiceUnavailableException),
285    /// <p>The client exceeded its request rate limit.</p>
286    ThrottledClientException(crate::types::error::ThrottledClientException),
287    /// <p>The client is not currently authorized to make the request.</p>
288    UnauthorizedClientException(crate::types::error::UnauthorizedClientException),
289    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
290    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
291    variable wildcard pattern and check `.code()`:
292     \
293    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
294     \
295    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetUserError) for what information is available for the error.")]
296    Unhandled(crate::error::sealed_unhandled::Unhandled),
297}
298impl GetUserError {
299    /// Creates the `GetUserError::Unhandled` variant from any error type.
300    pub fn unhandled(
301        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
302    ) -> Self {
303        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
304            source: err.into(),
305            meta: ::std::default::Default::default(),
306        })
307    }
308
309    /// Creates the `GetUserError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
310    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
311        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
312            source: err.clone().into(),
313            meta: err,
314        })
315    }
316    ///
317    /// Returns error metadata, which includes the error code, message,
318    /// request ID, and potentially additional information.
319    ///
320    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
321        match self {
322            Self::BadRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
323            Self::ForbiddenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
324            Self::NotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
325            Self::ServiceFailureException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
326            Self::ServiceUnavailableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
327            Self::ThrottledClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
328            Self::UnauthorizedClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
329            Self::Unhandled(e) => &e.meta,
330        }
331    }
332    /// Returns `true` if the error kind is `GetUserError::BadRequestException`.
333    pub fn is_bad_request_exception(&self) -> bool {
334        matches!(self, Self::BadRequestException(_))
335    }
336    /// Returns `true` if the error kind is `GetUserError::ForbiddenException`.
337    pub fn is_forbidden_exception(&self) -> bool {
338        matches!(self, Self::ForbiddenException(_))
339    }
340    /// Returns `true` if the error kind is `GetUserError::NotFoundException`.
341    pub fn is_not_found_exception(&self) -> bool {
342        matches!(self, Self::NotFoundException(_))
343    }
344    /// Returns `true` if the error kind is `GetUserError::ServiceFailureException`.
345    pub fn is_service_failure_exception(&self) -> bool {
346        matches!(self, Self::ServiceFailureException(_))
347    }
348    /// Returns `true` if the error kind is `GetUserError::ServiceUnavailableException`.
349    pub fn is_service_unavailable_exception(&self) -> bool {
350        matches!(self, Self::ServiceUnavailableException(_))
351    }
352    /// Returns `true` if the error kind is `GetUserError::ThrottledClientException`.
353    pub fn is_throttled_client_exception(&self) -> bool {
354        matches!(self, Self::ThrottledClientException(_))
355    }
356    /// Returns `true` if the error kind is `GetUserError::UnauthorizedClientException`.
357    pub fn is_unauthorized_client_exception(&self) -> bool {
358        matches!(self, Self::UnauthorizedClientException(_))
359    }
360}
361impl ::std::error::Error for GetUserError {
362    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
363        match self {
364            Self::BadRequestException(_inner) => ::std::option::Option::Some(_inner),
365            Self::ForbiddenException(_inner) => ::std::option::Option::Some(_inner),
366            Self::NotFoundException(_inner) => ::std::option::Option::Some(_inner),
367            Self::ServiceFailureException(_inner) => ::std::option::Option::Some(_inner),
368            Self::ServiceUnavailableException(_inner) => ::std::option::Option::Some(_inner),
369            Self::ThrottledClientException(_inner) => ::std::option::Option::Some(_inner),
370            Self::UnauthorizedClientException(_inner) => ::std::option::Option::Some(_inner),
371            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
372        }
373    }
374}
375impl ::std::fmt::Display for GetUserError {
376    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
377        match self {
378            Self::BadRequestException(_inner) => _inner.fmt(f),
379            Self::ForbiddenException(_inner) => _inner.fmt(f),
380            Self::NotFoundException(_inner) => _inner.fmt(f),
381            Self::ServiceFailureException(_inner) => _inner.fmt(f),
382            Self::ServiceUnavailableException(_inner) => _inner.fmt(f),
383            Self::ThrottledClientException(_inner) => _inner.fmt(f),
384            Self::UnauthorizedClientException(_inner) => _inner.fmt(f),
385            Self::Unhandled(_inner) => {
386                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
387                    write!(f, "unhandled error ({code})")
388                } else {
389                    f.write_str("unhandled error")
390                }
391            }
392        }
393    }
394}
395impl ::aws_smithy_types::retry::ProvideErrorKind for GetUserError {
396    fn code(&self) -> ::std::option::Option<&str> {
397        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
398    }
399    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
400        ::std::option::Option::None
401    }
402}
403impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetUserError {
404    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
405        match self {
406            Self::BadRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
407            Self::ForbiddenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
408            Self::NotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
409            Self::ServiceFailureException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
410            Self::ServiceUnavailableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
411            Self::ThrottledClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
412            Self::UnauthorizedClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
413            Self::Unhandled(_inner) => &_inner.meta,
414        }
415    }
416}
417impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetUserError {
418    fn create_unhandled_error(
419        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
420        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
421    ) -> Self {
422        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
423            source,
424            meta: meta.unwrap_or_default(),
425        })
426    }
427}
428impl ::aws_types::request_id::RequestId for crate::operation::get_user::GetUserError {
429    fn request_id(&self) -> Option<&str> {
430        self.meta().request_id()
431    }
432}
433
434pub use crate::operation::get_user::_get_user_input::GetUserInput;
435
436pub use crate::operation::get_user::_get_user_output::GetUserOutput;
437
438mod _get_user_input;
439
440mod _get_user_output;
441
442/// Builders
443pub mod builders;