aws_sdk_wickr/operation/
get_bot.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetBot`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetBot;
6impl GetBot {
7    /// Creates a new `GetBot`
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_bot::GetBotInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_bot::GetBotOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_bot::GetBotError,
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_bot::GetBotError>().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::get_bot::GetBotOutput>().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::get_bot::GetBotInput,
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        use ::tracing::Instrument;
46        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Wickr", "GetBot", input, runtime_plugins, stop_point)
47            // Create a parent span for the entire operation. Includes a random, internal-only,
48            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
49            .instrument(::tracing::debug_span!(
50                "Wickr.GetBot",
51                "rpc.service" = "Wickr",
52                "rpc.method" = "GetBot",
53                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
54                "rpc.system" = "aws-api",
55            ))
56            .await
57    }
58
59    pub(crate) fn operation_runtime_plugins(
60        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
61        client_config: &crate::config::Config,
62        config_override: ::std::option::Option<crate::config::Builder>,
63    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
64        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
65
66        if let ::std::option::Option::Some(config_override) = config_override {
67            for plugin in config_override.runtime_plugins.iter().cloned() {
68                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
69            }
70            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
71                config_override,
72                client_config.config.clone(),
73                &client_config.runtime_components,
74            ));
75        }
76        runtime_plugins
77    }
78}
79impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetBot {
80    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
81        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetBot");
82
83        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
84            GetBotRequestSerializer,
85        ));
86        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
87            GetBotResponseDeserializer,
88        ));
89
90        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
91            crate::config::auth::Params::builder()
92                .operation_name("GetBot")
93                .build()
94                .expect("required fields set"),
95        ));
96
97        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetBot", "Wickr"));
98        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
99        signing_options.double_uri_encode = true;
100        signing_options.content_sha256_header = false;
101        signing_options.normalize_uri_path = true;
102        signing_options.payload_override = None;
103
104        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
105            signing_options,
106            ..::std::default::Default::default()
107        });
108
109        ::std::option::Option::Some(cfg.freeze())
110    }
111
112    fn runtime_components(
113        &self,
114        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
115    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
116        #[allow(unused_mut)]
117        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetBot")
118            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
119            .with_interceptor(GetBotEndpointParamsInterceptor)
120            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
121                crate::operation::get_bot::GetBotError,
122            >::new())
123            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
124                crate::operation::get_bot::GetBotError,
125            >::new())
126            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
127                crate::operation::get_bot::GetBotError,
128            >::new());
129
130        ::std::borrow::Cow::Owned(rcb)
131    }
132}
133
134#[derive(Debug)]
135struct GetBotResponseDeserializer;
136impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetBotResponseDeserializer {
137    fn deserialize_nonstreaming(
138        &self,
139        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
140    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
141        let (success, status) = (response.status().is_success(), response.status().as_u16());
142        let headers = response.headers();
143        let body = response.body().bytes().expect("body loaded");
144        #[allow(unused_mut)]
145        let mut force_error = false;
146        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
147        let parse_result = if !success && status != 200 || force_error {
148            crate::protocol_serde::shape_get_bot::de_get_bot_http_error(status, headers, body)
149        } else {
150            crate::protocol_serde::shape_get_bot::de_get_bot_http_response(status, headers, body)
151        };
152        crate::protocol_serde::type_erase_result(parse_result)
153    }
154}
155#[derive(Debug)]
156struct GetBotRequestSerializer;
157impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetBotRequestSerializer {
158    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
159    fn serialize_input(
160        &self,
161        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
162        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
163    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
164        let input = input.downcast::<crate::operation::get_bot::GetBotInput>().expect("correct type");
165        let _header_serialization_settings = _cfg
166            .load::<crate::serialization_settings::HeaderSerializationSettings>()
167            .cloned()
168            .unwrap_or_default();
169        let mut request_builder = {
170            #[allow(clippy::uninlined_format_args)]
171            fn uri_base(
172                _input: &crate::operation::get_bot::GetBotInput,
173                output: &mut ::std::string::String,
174            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
175                use ::std::fmt::Write as _;
176                let input_1 = &_input.network_id;
177                let input_1 = input_1
178                    .as_ref()
179                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("network_id", "cannot be empty or unset"))?;
180                let network_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
181                if network_id.is_empty() {
182                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
183                        "network_id",
184                        "cannot be empty or unset",
185                    ));
186                }
187                let input_2 = &_input.bot_id;
188                let input_2 = input_2
189                    .as_ref()
190                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bot_id", "cannot be empty or unset"))?;
191                let bot_id = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
192                if bot_id.is_empty() {
193                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
194                        "bot_id",
195                        "cannot be empty or unset",
196                    ));
197                }
198                ::std::write!(output, "/networks/{networkId}/bots/{botId}", networkId = network_id, botId = bot_id)
199                    .expect("formatting should succeed");
200                ::std::result::Result::Ok(())
201            }
202            #[allow(clippy::unnecessary_wraps)]
203            fn update_http_builder(
204                input: &crate::operation::get_bot::GetBotInput,
205                builder: ::http::request::Builder,
206            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
207                let mut uri = ::std::string::String::new();
208                uri_base(input, &mut uri)?;
209                ::std::result::Result::Ok(builder.method("GET").uri(uri))
210            }
211            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
212            builder
213        };
214        let body = ::aws_smithy_types::body::SdkBody::from("");
215
216        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
217    }
218}
219#[derive(Debug)]
220struct GetBotEndpointParamsInterceptor;
221
222impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetBotEndpointParamsInterceptor {
223    fn name(&self) -> &'static str {
224        "GetBotEndpointParamsInterceptor"
225    }
226
227    fn read_before_execution(
228        &self,
229        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
230            '_,
231            ::aws_smithy_runtime_api::client::interceptors::context::Input,
232            ::aws_smithy_runtime_api::client::interceptors::context::Output,
233            ::aws_smithy_runtime_api::client::interceptors::context::Error,
234        >,
235        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
236    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
237        let _input = context.input().downcast_ref::<GetBotInput>().ok_or("failed to downcast to GetBotInput")?;
238
239        let params = crate::config::endpoint::Params::builder()
240            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
241            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
242            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
243            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
244            .build()
245            .map_err(|err| {
246                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
247            })?;
248        cfg.interceptor_state()
249            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
250        ::std::result::Result::Ok(())
251    }
252}
253
254// The get_* functions below are generated from JMESPath expressions in the
255// operationContextParams trait. They target the operation's input shape.
256
257/// Error type for the `GetBotError` operation.
258#[non_exhaustive]
259#[derive(::std::fmt::Debug)]
260pub enum GetBotError {
261    /// <p>The request was invalid or malformed. This error occurs when the request parameters do not meet the API requirements, such as invalid field values, missing required parameters, or improperly formatted data.</p>
262    BadRequestError(crate::types::error::BadRequestError),
263    /// <p>Access to the requested resource is forbidden. This error occurs when the authenticated user does not have the necessary permissions to perform the requested operation, even though they are authenticated.</p>
264    ForbiddenError(crate::types::error::ForbiddenError),
265    /// <p>An unexpected error occurred on the server while processing the request. This indicates a problem with the Wickr service itself rather than with the request. If this error persists, contact Amazon Web Services Support.</p>
266    InternalServerError(crate::types::error::InternalServerError),
267    /// <p>The request was throttled because too many requests were sent in a short period of time. Wait a moment and retry the request. Consider implementing exponential backoff in your application.</p>
268    RateLimitError(crate::types::error::RateLimitError),
269    /// <p>The requested resource could not be found. This error occurs when you try to access or modify a network, user, bot, security group, or other resource that doesn't exist or has been deleted.</p>
270    ResourceNotFoundError(crate::types::error::ResourceNotFoundError),
271    /// <p>The request was not authenticated or the authentication credentials were invalid. This error occurs when the request lacks valid authentication credentials or the credentials have expired.</p>
272    UnauthorizedError(crate::types::error::UnauthorizedError),
273    /// <p>One or more fields in the request failed validation. This error provides detailed information about which fields were invalid and why, allowing you to correct the request and retry.</p>
274    ValidationError(crate::types::error::ValidationError),
275    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
276    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
277    variable wildcard pattern and check `.code()`:
278     \
279    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
280     \
281    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetBotError) for what information is available for the error.")]
282    Unhandled(crate::error::sealed_unhandled::Unhandled),
283}
284impl GetBotError {
285    /// Creates the `GetBotError::Unhandled` variant from any error type.
286    pub fn unhandled(
287        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
288    ) -> Self {
289        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
290            source: err.into(),
291            meta: ::std::default::Default::default(),
292        })
293    }
294
295    /// Creates the `GetBotError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
296    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
297        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
298            source: err.clone().into(),
299            meta: err,
300        })
301    }
302    ///
303    /// Returns error metadata, which includes the error code, message,
304    /// request ID, and potentially additional information.
305    ///
306    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
307        match self {
308            Self::BadRequestError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
309            Self::ForbiddenError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
310            Self::InternalServerError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
311            Self::RateLimitError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
312            Self::ResourceNotFoundError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
313            Self::UnauthorizedError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
314            Self::ValidationError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
315            Self::Unhandled(e) => &e.meta,
316        }
317    }
318    /// Returns `true` if the error kind is `GetBotError::BadRequestError`.
319    pub fn is_bad_request_error(&self) -> bool {
320        matches!(self, Self::BadRequestError(_))
321    }
322    /// Returns `true` if the error kind is `GetBotError::ForbiddenError`.
323    pub fn is_forbidden_error(&self) -> bool {
324        matches!(self, Self::ForbiddenError(_))
325    }
326    /// Returns `true` if the error kind is `GetBotError::InternalServerError`.
327    pub fn is_internal_server_error(&self) -> bool {
328        matches!(self, Self::InternalServerError(_))
329    }
330    /// Returns `true` if the error kind is `GetBotError::RateLimitError`.
331    pub fn is_rate_limit_error(&self) -> bool {
332        matches!(self, Self::RateLimitError(_))
333    }
334    /// Returns `true` if the error kind is `GetBotError::ResourceNotFoundError`.
335    pub fn is_resource_not_found_error(&self) -> bool {
336        matches!(self, Self::ResourceNotFoundError(_))
337    }
338    /// Returns `true` if the error kind is `GetBotError::UnauthorizedError`.
339    pub fn is_unauthorized_error(&self) -> bool {
340        matches!(self, Self::UnauthorizedError(_))
341    }
342    /// Returns `true` if the error kind is `GetBotError::ValidationError`.
343    pub fn is_validation_error(&self) -> bool {
344        matches!(self, Self::ValidationError(_))
345    }
346}
347impl ::std::error::Error for GetBotError {
348    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
349        match self {
350            Self::BadRequestError(_inner) => ::std::option::Option::Some(_inner),
351            Self::ForbiddenError(_inner) => ::std::option::Option::Some(_inner),
352            Self::InternalServerError(_inner) => ::std::option::Option::Some(_inner),
353            Self::RateLimitError(_inner) => ::std::option::Option::Some(_inner),
354            Self::ResourceNotFoundError(_inner) => ::std::option::Option::Some(_inner),
355            Self::UnauthorizedError(_inner) => ::std::option::Option::Some(_inner),
356            Self::ValidationError(_inner) => ::std::option::Option::Some(_inner),
357            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
358        }
359    }
360}
361impl ::std::fmt::Display for GetBotError {
362    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
363        match self {
364            Self::BadRequestError(_inner) => _inner.fmt(f),
365            Self::ForbiddenError(_inner) => _inner.fmt(f),
366            Self::InternalServerError(_inner) => _inner.fmt(f),
367            Self::RateLimitError(_inner) => _inner.fmt(f),
368            Self::ResourceNotFoundError(_inner) => _inner.fmt(f),
369            Self::UnauthorizedError(_inner) => _inner.fmt(f),
370            Self::ValidationError(_inner) => _inner.fmt(f),
371            Self::Unhandled(_inner) => {
372                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
373                    write!(f, "unhandled error ({code})")
374                } else {
375                    f.write_str("unhandled error")
376                }
377            }
378        }
379    }
380}
381impl ::aws_smithy_types::retry::ProvideErrorKind for GetBotError {
382    fn code(&self) -> ::std::option::Option<&str> {
383        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
384    }
385    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
386        ::std::option::Option::None
387    }
388}
389impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetBotError {
390    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
391        match self {
392            Self::BadRequestError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
393            Self::ForbiddenError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
394            Self::InternalServerError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
395            Self::RateLimitError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
396            Self::ResourceNotFoundError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
397            Self::UnauthorizedError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
398            Self::ValidationError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
399            Self::Unhandled(_inner) => &_inner.meta,
400        }
401    }
402}
403impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetBotError {
404    fn create_unhandled_error(
405        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
406        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
407    ) -> Self {
408        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
409            source,
410            meta: meta.unwrap_or_default(),
411        })
412    }
413}
414impl ::aws_types::request_id::RequestId for crate::operation::get_bot::GetBotError {
415    fn request_id(&self) -> Option<&str> {
416        self.meta().request_id()
417    }
418}
419
420pub use crate::operation::get_bot::_get_bot_output::GetBotOutput;
421
422pub use crate::operation::get_bot::_get_bot_input::GetBotInput;
423
424mod _get_bot_input;
425
426mod _get_bot_output;
427
428/// Builders
429pub mod builders;