aws_sdk_dynamodb/operation/
scan.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `Scan`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct Scan;
6impl Scan {
7    /// Creates a new `Scan`
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::scan::ScanInput,
14    ) -> ::std::result::Result<
15        crate::operation::scan::ScanOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::scan::ScanError,
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        >| { err.map_service_error(|err| err.downcast::<crate::operation::scan::ScanError>().expect("correct error type")) };
25        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
26            .await
27            .map_err(map_err)?;
28        let output = context.finalize().map_err(map_err)?;
29        ::std::result::Result::Ok(output.downcast::<crate::operation::scan::ScanOutput>().expect("correct output type"))
30    }
31
32    pub(crate) async fn orchestrate_with_stop_point(
33        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
34        input: crate::operation::scan::ScanInput,
35        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
36    ) -> ::std::result::Result<
37        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
38        ::aws_smithy_runtime_api::client::result::SdkError<
39            ::aws_smithy_runtime_api::client::interceptors::context::Error,
40            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
41        >,
42    > {
43        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
44        use ::tracing::Instrument;
45        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("DynamoDB", "Scan", input, runtime_plugins, stop_point)
46            // Create a parent span for the entire operation. Includes a random, internal-only,
47            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
48            .instrument(::tracing::debug_span!(
49                "DynamoDB.Scan",
50                "rpc.service" = "DynamoDB",
51                "rpc.method" = "Scan",
52                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
53                "rpc.system" = "aws-api",
54            ))
55            .await
56    }
57
58    pub(crate) fn operation_runtime_plugins(
59        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
60        client_config: &crate::config::Config,
61        config_override: ::std::option::Option<crate::config::Builder>,
62    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
63        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
64        runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
65            ::aws_runtime::auth::sigv4::SCHEME_ID,
66        ]));
67        if let ::std::option::Option::Some(config_override) = config_override {
68            for plugin in config_override.runtime_plugins.iter().cloned() {
69                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
70            }
71            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
72                config_override,
73                client_config.config.clone(),
74                &client_config.runtime_components,
75            ));
76        }
77        runtime_plugins
78    }
79}
80impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for Scan {
81    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
82        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("Scan");
83
84        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
85            ScanRequestSerializer,
86        ));
87        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
88            ScanResponseDeserializer,
89        ));
90
91        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
92            ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
93        ));
94
95        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("Scan", "DynamoDB"));
96        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
97        signing_options.double_uri_encode = true;
98        signing_options.content_sha256_header = false;
99        signing_options.normalize_uri_path = true;
100        signing_options.payload_override = None;
101
102        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
103            signing_options,
104            ..::std::default::Default::default()
105        });
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("Scan")
116            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
117            .with_interceptor(ScanEndpointParamsInterceptor)
118            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
119                crate::operation::scan::ScanError,
120            >::new())
121            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
122                crate::operation::scan::ScanError,
123            >::new())
124            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
125                crate::operation::scan::ScanError,
126            >::new());
127
128        ::std::borrow::Cow::Owned(rcb)
129    }
130}
131
132#[derive(Debug)]
133struct ScanResponseDeserializer;
134impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ScanResponseDeserializer {
135    fn deserialize_nonstreaming(
136        &self,
137        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
138    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
139        let (success, status) = (response.status().is_success(), response.status().as_u16());
140        let headers = response.headers();
141        let body = response.body().bytes().expect("body loaded");
142        #[allow(unused_mut)]
143        let mut force_error = false;
144        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
145        let parse_result = if !success && status != 200 || force_error {
146            crate::protocol_serde::shape_scan::de_scan_http_error(status, headers, body)
147        } else {
148            crate::protocol_serde::shape_scan::de_scan_http_response(status, headers, body)
149        };
150        crate::protocol_serde::type_erase_result(parse_result)
151    }
152}
153#[derive(Debug)]
154struct ScanRequestSerializer;
155impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ScanRequestSerializer {
156    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
157    fn serialize_input(
158        &self,
159        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
160        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
161    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
162        let input = input.downcast::<crate::operation::scan::ScanInput>().expect("correct type");
163        let _header_serialization_settings = _cfg
164            .load::<crate::serialization_settings::HeaderSerializationSettings>()
165            .cloned()
166            .unwrap_or_default();
167        let mut request_builder = {
168            fn uri_base(
169                _input: &crate::operation::scan::ScanInput,
170                output: &mut ::std::string::String,
171            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
172                use ::std::fmt::Write as _;
173                ::std::write!(output, "/").expect("formatting should succeed");
174                ::std::result::Result::Ok(())
175            }
176            #[allow(clippy::unnecessary_wraps)]
177            fn update_http_builder(
178                input: &crate::operation::scan::ScanInput,
179                builder: ::http::request::Builder,
180            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
181                let mut uri = ::std::string::String::new();
182                uri_base(input, &mut uri)?;
183                ::std::result::Result::Ok(builder.method("POST").uri(uri))
184            }
185            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
186            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/x-amz-json-1.0");
187            builder = _header_serialization_settings.set_default_header(
188                builder,
189                ::http::header::HeaderName::from_static("x-amz-target"),
190                "DynamoDB_20120810.Scan",
191            );
192            builder
193        };
194        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_scan::ser_scan_input(&input)?);
195        if let Some(content_length) = body.content_length() {
196            let content_length = content_length.to_string();
197            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
198        }
199        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
200    }
201}
202#[derive(Debug)]
203struct ScanEndpointParamsInterceptor;
204
205impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ScanEndpointParamsInterceptor {
206    fn name(&self) -> &'static str {
207        "ScanEndpointParamsInterceptor"
208    }
209
210    fn read_before_execution(
211        &self,
212        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
213            '_,
214            ::aws_smithy_runtime_api::client::interceptors::context::Input,
215            ::aws_smithy_runtime_api::client::interceptors::context::Output,
216            ::aws_smithy_runtime_api::client::interceptors::context::Error,
217        >,
218        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
219    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
220        let _input = context.input().downcast_ref::<ScanInput>().ok_or("failed to downcast to ScanInput")?;
221
222        let params = crate::config::endpoint::Params::builder()
223            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
224            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
225            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
226            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
227            .set_account_id_endpoint_mode(::std::option::Option::Some(
228                cfg.load::<::aws_types::endpoint_config::AccountIdEndpointMode>()
229                    .cloned()
230                    .unwrap_or_default()
231                    .to_string(),
232            ))
233            .set_resource_arn(Some(
234                _input
235                    .table_name
236                    .clone()
237                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
238                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("table_name", "A required field was not set"))?,
239            ))
240            .build()
241            .map_err(|err| {
242                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
243            })?;
244        cfg.interceptor_state()
245            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
246        ::std::result::Result::Ok(())
247    }
248}
249
250// The get_* functions below are generated from JMESPath expressions in the
251// operationContextParams trait. They target the operation's input shape.
252
253/// Error type for the `ScanError` operation.
254#[non_exhaustive]
255#[derive(::std::fmt::Debug)]
256pub enum ScanError {
257    /// <p>An error occurred on the server side.</p>
258    InternalServerError(crate::types::error::InternalServerError),
259    #[allow(missing_docs)] // documentation missing in model
260    InvalidEndpointException(crate::types::error::InvalidEndpointException),
261    /// <p>Your request rate is too high. The Amazon Web Services SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
262    ProvisionedThroughputExceededException(crate::types::error::ProvisionedThroughputExceededException),
263    /// <p>Throughput exceeds the current throughput quota for your account. Please contact <a href="https://aws.amazon.com/support">Amazon Web ServicesSupport</a> to request a quota increase.</p>
264    RequestLimitExceeded(crate::types::error::RequestLimitExceeded),
265    /// <p>The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
266    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
267    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
268    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
269    variable wildcard pattern and check `.code()`:
270     \
271    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
272     \
273    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ScanError) for what information is available for the error.")]
274    Unhandled(crate::error::sealed_unhandled::Unhandled),
275}
276impl ScanError {
277    /// Creates the `ScanError::Unhandled` variant from any error type.
278    pub fn unhandled(
279        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
280    ) -> Self {
281        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
282            source: err.into(),
283            meta: ::std::default::Default::default(),
284        })
285    }
286
287    /// Creates the `ScanError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
288    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
289        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
290            source: err.clone().into(),
291            meta: err,
292        })
293    }
294    ///
295    /// Returns error metadata, which includes the error code, message,
296    /// request ID, and potentially additional information.
297    ///
298    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
299        match self {
300            Self::InternalServerError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
301            Self::InvalidEndpointException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
302            Self::ProvisionedThroughputExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
303            Self::RequestLimitExceeded(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
304            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
305            Self::Unhandled(e) => &e.meta,
306        }
307    }
308    /// Returns `true` if the error kind is `ScanError::InternalServerError`.
309    pub fn is_internal_server_error(&self) -> bool {
310        matches!(self, Self::InternalServerError(_))
311    }
312    /// Returns `true` if the error kind is `ScanError::InvalidEndpointException`.
313    pub fn is_invalid_endpoint_exception(&self) -> bool {
314        matches!(self, Self::InvalidEndpointException(_))
315    }
316    /// Returns `true` if the error kind is `ScanError::ProvisionedThroughputExceededException`.
317    pub fn is_provisioned_throughput_exceeded_exception(&self) -> bool {
318        matches!(self, Self::ProvisionedThroughputExceededException(_))
319    }
320    /// Returns `true` if the error kind is `ScanError::RequestLimitExceeded`.
321    pub fn is_request_limit_exceeded(&self) -> bool {
322        matches!(self, Self::RequestLimitExceeded(_))
323    }
324    /// Returns `true` if the error kind is `ScanError::ResourceNotFoundException`.
325    pub fn is_resource_not_found_exception(&self) -> bool {
326        matches!(self, Self::ResourceNotFoundException(_))
327    }
328}
329impl ::std::error::Error for ScanError {
330    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
331        match self {
332            Self::InternalServerError(_inner) => ::std::option::Option::Some(_inner),
333            Self::InvalidEndpointException(_inner) => ::std::option::Option::Some(_inner),
334            Self::ProvisionedThroughputExceededException(_inner) => ::std::option::Option::Some(_inner),
335            Self::RequestLimitExceeded(_inner) => ::std::option::Option::Some(_inner),
336            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
337            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
338        }
339    }
340}
341impl ::std::fmt::Display for ScanError {
342    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
343        match self {
344            Self::InternalServerError(_inner) => _inner.fmt(f),
345            Self::InvalidEndpointException(_inner) => _inner.fmt(f),
346            Self::ProvisionedThroughputExceededException(_inner) => _inner.fmt(f),
347            Self::RequestLimitExceeded(_inner) => _inner.fmt(f),
348            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
349            Self::Unhandled(_inner) => {
350                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
351                    write!(f, "unhandled error ({code})")
352                } else {
353                    f.write_str("unhandled error")
354                }
355            }
356        }
357    }
358}
359impl ::aws_smithy_types::retry::ProvideErrorKind for ScanError {
360    fn code(&self) -> ::std::option::Option<&str> {
361        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
362    }
363    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
364        ::std::option::Option::None
365    }
366}
367impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ScanError {
368    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
369        match self {
370            Self::InternalServerError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
371            Self::InvalidEndpointException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
372            Self::ProvisionedThroughputExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
373            Self::RequestLimitExceeded(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
374            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
375            Self::Unhandled(_inner) => &_inner.meta,
376        }
377    }
378}
379impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ScanError {
380    fn create_unhandled_error(
381        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
382        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
383    ) -> Self {
384        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
385            source,
386            meta: meta.unwrap_or_default(),
387        })
388    }
389}
390impl ::aws_types::request_id::RequestId for crate::operation::scan::ScanError {
391    fn request_id(&self) -> Option<&str> {
392        self.meta().request_id()
393    }
394}
395
396pub use crate::operation::scan::_scan_output::ScanOutput;
397
398pub use crate::operation::scan::_scan_input::ScanInput;
399
400mod _scan_input;
401
402mod _scan_output;
403
404/// Builders
405pub mod builders;
406
407/// Paginator for this operation
408pub mod paginator;