Skip to main content

aws_sdk_s3/operation/
select_object_content.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `SelectObjectContent`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct SelectObjectContent;
6impl SelectObjectContent {
7    /// Creates a new `SelectObjectContent`
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::select_object_content::SelectObjectContentInput,
14    ) -> ::std::result::Result<
15        crate::operation::select_object_content::SelectObjectContentOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::select_object_content::SelectObjectContentError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::select_object_content::SelectObjectContentError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::select_object_content::SelectObjectContentOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::select_object_content::SelectObjectContentInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        use ::tracing::Instrument;
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("S3", "SelectObjectContent", input, runtime_plugins, stop_point)
55            // Create a parent span for the entire operation. Includes a random, internal-only,
56            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
57            .instrument(::tracing::debug_span!(
58                "S3.SelectObjectContent",
59                "rpc.service" = "S3",
60                "rpc.method" = "SelectObjectContent",
61                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62                "rpc.system" = "aws-api",
63            ))
64            .await
65    }
66
67    pub(crate) fn operation_runtime_plugins(
68        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69        client_config: &crate::config::Config,
70        config_override: ::std::option::Option<crate::config::Builder>,
71    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74        if let ::std::option::Option::Some(config_override) = config_override {
75            for plugin in config_override.runtime_plugins.iter().cloned() {
76                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77            }
78            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79                config_override,
80                client_config.config.clone(),
81                &client_config.runtime_components,
82            ));
83        }
84        runtime_plugins
85    }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for SelectObjectContent {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("SelectObjectContent");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            SelectObjectContentRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            SelectObjectContentResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("SelectObjectContent")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("SelectObjectContent", "S3"));
106        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
107        signing_options.double_uri_encode = false;
108        signing_options.content_sha256_header = true;
109        signing_options.normalize_uri_path = false;
110        signing_options.payload_override = None;
111
112        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
113            signing_options,
114            ..::std::default::Default::default()
115        });
116
117        ::std::option::Option::Some(cfg.freeze())
118    }
119
120    fn runtime_components(
121        &self,
122        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
123    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
124        #[allow(unused_mut)]
125                    let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("SelectObjectContent")
126                            .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(SelectObjectContentTelemetryInputCaptureInterceptor))
127.with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(SelectObjectContentEndpointParamsInterceptor))
128                            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<crate::operation::select_object_content::SelectObjectContentError>::new())
129.with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<crate::operation::select_object_content::SelectObjectContentError>::new())
130.with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::select_object_content::SelectObjectContentError>::builder().transient_errors({
131                                            let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
132                                            transient_errors.push("InternalError");
133                                            ::std::borrow::Cow::Owned(transient_errors)
134                                            }).build())
135.with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<crate::operation::select_object_content::SelectObjectContentError>::new());
136
137        ::std::borrow::Cow::Owned(rcb)
138    }
139}
140
141#[derive(Debug)]
142struct SelectObjectContentTelemetryInputCaptureInterceptor;
143
144#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
145impl ::aws_smithy_runtime_api::client::interceptors::Intercept for SelectObjectContentTelemetryInputCaptureInterceptor {
146    fn name(&self) -> &'static str {
147        "SelectObjectContentTelemetryInputCaptureInterceptor"
148    }
149
150    fn read_before_execution(
151        &self,
152        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
153            '_,
154            ::aws_smithy_runtime_api::client::interceptors::context::Input,
155            ::aws_smithy_runtime_api::client::interceptors::context::Output,
156            ::aws_smithy_runtime_api::client::interceptors::context::Error,
157        >,
158        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
159    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
160        // Nothing to do unless the customer opted in by naming members to record.
161        let ::std::option::Option::Some(requested) = cfg
162            .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
163            .filter(|r| !r.is_empty())
164        else {
165            return ::std::result::Result::Ok(());
166        };
167
168        let ::std::option::Option::Some(input) = context.input().downcast_ref::<SelectObjectContentInput>() else {
169            // A mismatched input is not this interceptor's concern; skip quietly.
170            return ::std::result::Result::Ok(());
171        };
172
173        let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
174        if requested.should_capture("Bucket") {
175            if let ::std::option::Option::Some(value) = input.bucket.as_deref() {
176                captured.insert("Bucket", value);
177            }
178        }
179        if requested.should_capture("Key") {
180            if let ::std::option::Option::Some(value) = input.key.as_deref() {
181                captured.insert("Key", value);
182            }
183        }
184        if requested.should_capture("SSECustomerAlgorithm") {
185            if let ::std::option::Option::Some(value) = input.sse_customer_algorithm.as_deref() {
186                captured.insert("SSECustomerAlgorithm", value);
187            }
188        }
189        if requested.should_capture("SSECustomerKeyMD5") {
190            if let ::std::option::Option::Some(value) = input.sse_customer_key_md5.as_deref() {
191                captured.insert("SSECustomerKeyMD5", value);
192            }
193        }
194        if requested.should_capture("Expression") {
195            if let ::std::option::Option::Some(value) = input.expression.as_deref() {
196                captured.insert("Expression", value);
197            }
198        }
199        if requested.should_capture("ExpectedBucketOwner") {
200            if let ::std::option::Option::Some(value) = input.expected_bucket_owner.as_deref() {
201                captured.insert("ExpectedBucketOwner", value);
202            }
203        }
204
205        cfg.interceptor_state().store_put(captured);
206        ::std::result::Result::Ok(())
207    }
208}
209#[derive(Debug)]
210struct SelectObjectContentResponseDeserializer;
211impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for SelectObjectContentResponseDeserializer {
212    fn deserialize_streaming_with_config(
213        &self,
214        response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
215        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
216    ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
217        #[allow(unused_mut)]
218        let mut force_error = false;
219        ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
220        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
221
222        // If this is an error, defer to the non-streaming parser
223        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
224            return ::std::option::Option::None;
225        }
226        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
227            crate::protocol_serde::shape_select_object_content::de_select_object_content_http_response(response, _cfg),
228        ))
229    }
230
231    fn deserialize_nonstreaming_with_config(
232        &self,
233        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
234        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
235    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
236        // For streaming operations, we only hit this case if its an error
237        let body = response.body().bytes().expect("body loaded");
238        crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_select_object_content::de_select_object_content_http_error(
239            response.status().as_u16(),
240            response.headers(),
241            body,
242            _cfg,
243        ))
244    }
245}
246#[derive(Debug)]
247struct SelectObjectContentRequestSerializer;
248impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for SelectObjectContentRequestSerializer {
249    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
250    fn serialize_input(
251        &self,
252        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
253        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
254    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
255        let input = input
256            .downcast::<crate::operation::select_object_content::SelectObjectContentInput>()
257            .expect("correct type");
258        let _header_serialization_settings = _cfg
259            .load::<crate::serialization_settings::HeaderSerializationSettings>()
260            .cloned()
261            .unwrap_or_default();
262        let mut request_builder = {
263            #[allow(clippy::uninlined_format_args)]
264            fn uri_base(
265                _input: &crate::operation::select_object_content::SelectObjectContentInput,
266                output: &mut ::std::string::String,
267            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
268                use ::std::fmt::Write as _;
269                let input_1 = &_input.key;
270                let input_1 = input_1
271                    .as_ref()
272                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
273                let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
274                if key.is_empty() {
275                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
276                        "key",
277                        "cannot be empty or unset",
278                    ));
279                }
280                ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
281                ::std::result::Result::Ok(())
282            }
283            fn uri_query(
284                _input: &crate::operation::select_object_content::SelectObjectContentInput,
285                mut output: &mut ::std::string::String,
286            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
287                let mut query = ::aws_smithy_http::query::Writer::new(output);
288                query.push_v("select");
289                query.push_kv("select-type", "2");
290                ::std::result::Result::Ok(())
291            }
292            #[allow(clippy::unnecessary_wraps)]
293            fn update_http_builder(
294                input: &crate::operation::select_object_content::SelectObjectContentInput,
295                builder: ::http_1x::request::Builder,
296            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
297                let mut uri = ::std::string::String::new();
298                uri_base(input, &mut uri)?;
299                uri_query(input, &mut uri)?;
300                let builder = crate::protocol_serde::shape_select_object_content::ser_select_object_content_headers(input, builder)?;
301                ::std::result::Result::Ok(builder.method("POST").uri(uri))
302            }
303            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
304            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/xml");
305            builder
306        };
307        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_select_object_content::ser_select_object_content_op_input(
308            &input,
309        )?);
310        if let Some(content_length) = body.content_length() {
311            let content_length = content_length.to_string();
312            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
313        }
314        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
315    }
316}
317#[derive(Debug)]
318struct SelectObjectContentEndpointParamsInterceptor;
319
320#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
321impl ::aws_smithy_runtime_api::client::interceptors::Intercept for SelectObjectContentEndpointParamsInterceptor {
322    fn name(&self) -> &'static str {
323        "SelectObjectContentEndpointParamsInterceptor"
324    }
325
326    fn read_before_execution(
327        &self,
328        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
329            '_,
330            ::aws_smithy_runtime_api::client::interceptors::context::Input,
331            ::aws_smithy_runtime_api::client::interceptors::context::Output,
332            ::aws_smithy_runtime_api::client::interceptors::context::Error,
333        >,
334        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
335    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
336        let _input = context
337            .input()
338            .downcast_ref::<SelectObjectContentInput>()
339            .ok_or("failed to downcast to SelectObjectContentInput")?;
340
341        let params = crate::config::endpoint::Params::builder()
342            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
343            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
344            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
345            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
346            .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
347            .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
348            .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
349            .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
350            .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
351            .set_bucket(Some(
352                _input
353                    .bucket
354                    .clone()
355                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
356                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
357            ))
358            .build()
359            .map_err(|err| {
360                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
361            })?;
362        cfg.interceptor_state()
363            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
364        ::std::result::Result::Ok(())
365    }
366}
367
368// The get_* functions below are generated from JMESPath expressions in the
369// operationContextParams trait. They target the operation's input shape.
370
371/// Error type for the `SelectObjectContentError` operation.
372#[non_exhaustive]
373#[derive(::std::fmt::Debug)]
374pub enum SelectObjectContentError {
375    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
376    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
377    variable wildcard pattern and check `.code()`:
378     \
379    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
380     \
381    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-SelectObjectContentError) for what information is available for the error.")]
382    Unhandled(crate::error::sealed_unhandled::Unhandled),
383}
384impl SelectObjectContentError {
385    /// Creates the `SelectObjectContentError::Unhandled` variant from any error type.
386    pub fn unhandled(
387        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
388    ) -> Self {
389        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
390            source: err.into(),
391            meta: ::std::default::Default::default(),
392        })
393    }
394
395    /// Creates the `SelectObjectContentError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
396    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
397        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
398            source: err.clone().into(),
399            meta: err,
400        })
401    }
402    ///
403    /// Returns error metadata, which includes the error code, message,
404    /// request ID, and potentially additional information.
405    ///
406    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
407        match self {
408            Self::Unhandled(e) => &e.meta,
409        }
410    }
411}
412impl ::std::error::Error for SelectObjectContentError {
413    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
414        match self {
415            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
416        }
417    }
418}
419impl ::std::fmt::Display for SelectObjectContentError {
420    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
421        match self {
422            Self::Unhandled(_inner) => {
423                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
424                    write!(f, "unhandled error ({code})")
425                } else {
426                    f.write_str("unhandled error")
427                }
428            }
429        }
430    }
431}
432impl ::aws_smithy_types::retry::ProvideErrorKind for SelectObjectContentError {
433    fn code(&self) -> ::std::option::Option<&str> {
434        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
435    }
436    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
437        ::std::option::Option::None
438    }
439}
440impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for SelectObjectContentError {
441    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
442        match self {
443            Self::Unhandled(_inner) => &_inner.meta,
444        }
445    }
446}
447impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for SelectObjectContentError {
448    fn create_unhandled_error(
449        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
450        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
451    ) -> Self {
452        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
453            source,
454            meta: meta.unwrap_or_default(),
455        })
456    }
457}
458impl crate::s3_request_id::RequestIdExt for crate::operation::select_object_content::SelectObjectContentError {
459    fn extended_request_id(&self) -> Option<&str> {
460        self.meta().extended_request_id()
461    }
462}
463impl ::aws_types::request_id::RequestId for crate::operation::select_object_content::SelectObjectContentError {
464    fn request_id(&self) -> Option<&str> {
465        self.meta().request_id()
466    }
467}
468
469pub use crate::operation::select_object_content::_select_object_content_input::SelectObjectContentInput;
470
471pub use crate::operation::select_object_content::_select_object_content_output::SelectObjectContentOutput;
472
473mod _select_object_content_input;
474
475mod _select_object_content_output;
476
477/// Builders
478pub mod builders;