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(
213        &self,
214        response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
215    ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
216        #[allow(unused_mut)]
217        let mut force_error = false;
218        ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
219        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
220
221        // If this is an error, defer to the non-streaming parser
222        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
223            return ::std::option::Option::None;
224        }
225        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
226            crate::protocol_serde::shape_select_object_content::de_select_object_content_http_response(response),
227        ))
228    }
229
230    fn deserialize_nonstreaming_with_config(
231        &self,
232        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
233        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
234    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
235        // For streaming operations, we only hit this case if its an error
236        let body = response.body().bytes().expect("body loaded");
237        crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_select_object_content::de_select_object_content_http_error(
238            response.status().as_u16(),
239            response.headers(),
240            body,
241        ))
242    }
243}
244#[derive(Debug)]
245struct SelectObjectContentRequestSerializer;
246impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for SelectObjectContentRequestSerializer {
247    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
248    fn serialize_input(
249        &self,
250        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
251        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
252    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
253        let input = input
254            .downcast::<crate::operation::select_object_content::SelectObjectContentInput>()
255            .expect("correct type");
256        let _header_serialization_settings = _cfg
257            .load::<crate::serialization_settings::HeaderSerializationSettings>()
258            .cloned()
259            .unwrap_or_default();
260        let mut request_builder = {
261            #[allow(clippy::uninlined_format_args)]
262            fn uri_base(
263                _input: &crate::operation::select_object_content::SelectObjectContentInput,
264                output: &mut ::std::string::String,
265            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
266                use ::std::fmt::Write as _;
267                let input_1 = &_input.key;
268                let input_1 = input_1
269                    .as_ref()
270                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
271                let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
272                if key.is_empty() {
273                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
274                        "key",
275                        "cannot be empty or unset",
276                    ));
277                }
278                ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
279                ::std::result::Result::Ok(())
280            }
281            fn uri_query(
282                _input: &crate::operation::select_object_content::SelectObjectContentInput,
283                mut output: &mut ::std::string::String,
284            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
285                let mut query = ::aws_smithy_http::query::Writer::new(output);
286                query.push_v("select");
287                query.push_kv("select-type", "2");
288                ::std::result::Result::Ok(())
289            }
290            #[allow(clippy::unnecessary_wraps)]
291            fn update_http_builder(
292                input: &crate::operation::select_object_content::SelectObjectContentInput,
293                builder: ::http_1x::request::Builder,
294            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
295                let mut uri = ::std::string::String::new();
296                uri_base(input, &mut uri)?;
297                uri_query(input, &mut uri)?;
298                let builder = crate::protocol_serde::shape_select_object_content::ser_select_object_content_headers(input, builder)?;
299                ::std::result::Result::Ok(builder.method("POST").uri(uri))
300            }
301            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
302            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/xml");
303            builder
304        };
305        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_select_object_content::ser_select_object_content_op_input(
306            &input,
307        )?);
308        if let Some(content_length) = body.content_length() {
309            let content_length = content_length.to_string();
310            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
311        }
312        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
313    }
314}
315#[derive(Debug)]
316struct SelectObjectContentEndpointParamsInterceptor;
317
318#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
319impl ::aws_smithy_runtime_api::client::interceptors::Intercept for SelectObjectContentEndpointParamsInterceptor {
320    fn name(&self) -> &'static str {
321        "SelectObjectContentEndpointParamsInterceptor"
322    }
323
324    fn read_before_execution(
325        &self,
326        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
327            '_,
328            ::aws_smithy_runtime_api::client::interceptors::context::Input,
329            ::aws_smithy_runtime_api::client::interceptors::context::Output,
330            ::aws_smithy_runtime_api::client::interceptors::context::Error,
331        >,
332        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
333    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
334        let _input = context
335            .input()
336            .downcast_ref::<SelectObjectContentInput>()
337            .ok_or("failed to downcast to SelectObjectContentInput")?;
338
339        let params = crate::config::endpoint::Params::builder()
340            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
341            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
342            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
343            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
344            .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
345            .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
346            .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
347            .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
348            .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
349            .set_bucket(Some(
350                _input
351                    .bucket
352                    .clone()
353                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
354                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
355            ))
356            .build()
357            .map_err(|err| {
358                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
359            })?;
360        cfg.interceptor_state()
361            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
362        ::std::result::Result::Ok(())
363    }
364}
365
366// The get_* functions below are generated from JMESPath expressions in the
367// operationContextParams trait. They target the operation's input shape.
368
369/// Error type for the `SelectObjectContentError` operation.
370#[non_exhaustive]
371#[derive(::std::fmt::Debug)]
372pub enum SelectObjectContentError {
373    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
374    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
375    variable wildcard pattern and check `.code()`:
376     \
377    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
378     \
379    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-SelectObjectContentError) for what information is available for the error.")]
380    Unhandled(crate::error::sealed_unhandled::Unhandled),
381}
382impl SelectObjectContentError {
383    /// Creates the `SelectObjectContentError::Unhandled` variant from any error type.
384    pub fn unhandled(
385        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
386    ) -> Self {
387        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
388            source: err.into(),
389            meta: ::std::default::Default::default(),
390        })
391    }
392
393    /// Creates the `SelectObjectContentError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
394    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
395        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
396            source: err.clone().into(),
397            meta: err,
398        })
399    }
400    ///
401    /// Returns error metadata, which includes the error code, message,
402    /// request ID, and potentially additional information.
403    ///
404    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
405        match self {
406            Self::Unhandled(e) => &e.meta,
407        }
408    }
409}
410impl ::std::error::Error for SelectObjectContentError {
411    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
412        match self {
413            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
414        }
415    }
416}
417impl ::std::fmt::Display for SelectObjectContentError {
418    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
419        match self {
420            Self::Unhandled(_inner) => {
421                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
422                    write!(f, "unhandled error ({code})")
423                } else {
424                    f.write_str("unhandled error")
425                }
426            }
427        }
428    }
429}
430impl ::aws_smithy_types::retry::ProvideErrorKind for SelectObjectContentError {
431    fn code(&self) -> ::std::option::Option<&str> {
432        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
433    }
434    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
435        ::std::option::Option::None
436    }
437}
438impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for SelectObjectContentError {
439    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
440        match self {
441            Self::Unhandled(_inner) => &_inner.meta,
442        }
443    }
444}
445impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for SelectObjectContentError {
446    fn create_unhandled_error(
447        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
448        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
449    ) -> Self {
450        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
451            source,
452            meta: meta.unwrap_or_default(),
453        })
454    }
455}
456impl crate::s3_request_id::RequestIdExt for crate::operation::select_object_content::SelectObjectContentError {
457    fn extended_request_id(&self) -> Option<&str> {
458        self.meta().extended_request_id()
459    }
460}
461impl ::aws_types::request_id::RequestId for crate::operation::select_object_content::SelectObjectContentError {
462    fn request_id(&self) -> Option<&str> {
463        self.meta().request_id()
464    }
465}
466
467pub use crate::operation::select_object_content::_select_object_content_input::SelectObjectContentInput;
468
469pub use crate::operation::select_object_content::_select_object_content_output::SelectObjectContentOutput;
470
471mod _select_object_content_input;
472
473mod _select_object_content_output;
474
475/// Builders
476pub mod builders;