aws_sdk_dynamodb/operation/
query.rs

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