aws_sdk_s3/operation/
put_object.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `PutObject`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct PutObject;
6impl PutObject {
7    /// Creates a new `PutObject`
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::put_object::PutObjectInput,
14    ) -> ::std::result::Result<
15        crate::operation::put_object::PutObjectOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::put_object::PutObjectError,
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::put_object::PutObjectError>()
27                    .expect("correct error type")
28            })
29        };
30        use ::tracing::Instrument;
31        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
32            // Create a parent span for the entire operation. Includes a random, internal-only,
33            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
34            .instrument(::tracing::debug_span!(
35                "s3.PutObject",
36                "rpc.service" = "s3",
37                "rpc.method" = "PutObject",
38                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
39                "rpc.system" = "aws-api",
40            ))
41            .await
42            .map_err(map_err)?;
43        let output = context.finalize().map_err(map_err)?;
44        ::std::result::Result::Ok(
45            output
46                .downcast::<crate::operation::put_object::PutObjectOutput>()
47                .expect("correct output type"),
48        )
49    }
50
51    pub(crate) async fn orchestrate_with_stop_point(
52        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
53        input: crate::operation::put_object::PutObjectInput,
54        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
55    ) -> ::std::result::Result<
56        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
57        ::aws_smithy_runtime_api::client::result::SdkError<
58            ::aws_smithy_runtime_api::client::interceptors::context::Error,
59            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
60        >,
61    > {
62        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
63        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("s3", "PutObject", input, runtime_plugins, stop_point).await
64    }
65
66    pub(crate) fn operation_runtime_plugins(
67        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
68        client_config: &crate::config::Config,
69        config_override: ::std::option::Option<crate::config::Builder>,
70    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
71        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
72        runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
73            ::aws_runtime::auth::sigv4::SCHEME_ID,
74            #[cfg(feature = "sigv4a")]
75            {
76                ::aws_runtime::auth::sigv4a::SCHEME_ID
77            },
78            crate::s3_express::auth::SCHEME_ID,
79            ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
80        ]));
81        if let ::std::option::Option::Some(config_override) = config_override {
82            for plugin in config_override.runtime_plugins.iter().cloned() {
83                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
84            }
85            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
86                config_override,
87                client_config.config.clone(),
88                &client_config.runtime_components,
89            ));
90        }
91        runtime_plugins
92    }
93}
94impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for PutObject {
95    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
96        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("PutObject");
97
98        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
99            PutObjectRequestSerializer,
100        ));
101        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
102            PutObjectResponseDeserializer,
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
106            ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
107        ));
108
109        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
110        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("PutObject", "s3"));
111        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
112        signing_options.double_uri_encode = false;
113        signing_options.content_sha256_header = true;
114        signing_options.normalize_uri_path = false;
115        signing_options.payload_override = None;
116
117        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
118            signing_options,
119            ..::std::default::Default::default()
120        });
121
122        ::std::option::Option::Some(cfg.freeze())
123    }
124
125    fn runtime_components(
126        &self,
127        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
128    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
129        #[allow(unused_mut)]
130        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("PutObject")
131            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
132            .with_interceptor(PutObjectEndpointParamsInterceptor)
133            .with_interceptor(crate::http_request_checksum::RequestChecksumInterceptor::new(
134                |input: &::aws_smithy_runtime_api::client::interceptors::context::Input| {
135                    let input: &crate::operation::put_object::PutObjectInput = input.downcast_ref().expect("correct type");
136                    let checksum_algorithm = input.checksum_algorithm();
137                    let checksum_algorithm = checksum_algorithm.map(|algorithm| algorithm.as_str());
138                    (checksum_algorithm.map(|s| s.to_string()), false)
139                },
140                |request: &mut ::aws_smithy_runtime_api::http::Request, cfg: &::aws_smithy_types::config_bag::ConfigBag| {
141                    // We check if the user has set any of the checksum values manually
142                    let mut user_set_checksum_value = false;
143                    let headers_to_check =
144                        request
145                            .headers()
146                            .iter()
147                            .filter_map(|(name, _val)| if name.starts_with("x-amz-checksum-") { Some(name) } else { None });
148                    for algo_header in headers_to_check {
149                        if request.headers().get(algo_header).is_some() {
150                            user_set_checksum_value = true;
151                        }
152                    }
153
154                    // We check if the user set the checksum algo manually
155                    let user_set_checksum_algo = request.headers().get("x-amz-sdk-checksum-algorithm").is_some();
156
157                    // This value is set by the user on the SdkConfig to indicate their preference
158                    let request_checksum_calculation = cfg
159                        .load::<::aws_smithy_types::checksum_config::RequestChecksumCalculation>()
160                        .unwrap_or(&::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported);
161
162                    // From the httpChecksum trait
163                    let http_checksum_required = false;
164
165                    let is_presigned_req = cfg.load::<crate::presigning::PresigningMarker>().is_some();
166
167                    // If the request is presigned we do not set a default.
168                    // If the RequestChecksumCalculation is WhenSupported and the user has not set a checksum value or algo
169                    // we default to Crc32. If it is WhenRequired and a checksum is required by the trait and the user has not
170                    // set a checksum value or algo we also set the default. In all other cases we do nothing.
171                    match (
172                        request_checksum_calculation,
173                        http_checksum_required,
174                        user_set_checksum_value,
175                        user_set_checksum_algo,
176                        is_presigned_req,
177                    ) {
178                        (_, _, _, _, true) => {}
179                        (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported, _, false, false, _)
180                        | (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenRequired, true, false, false, _) => {
181                            request.headers_mut().insert("x-amz-sdk-checksum-algorithm", "CRC32");
182                        }
183                        _ => {}
184                    }
185
186                    // We return a bool indicating if the user did set the checksum value, if they did
187                    // we can short circuit and exit the interceptor early.
188                    Ok(user_set_checksum_value)
189                },
190            ))
191            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
192                crate::operation::put_object::PutObjectError,
193            >::new())
194            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
195                crate::operation::put_object::PutObjectError,
196            >::new())
197            .with_retry_classifier(
198                ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::put_object::PutObjectError>::builder()
199                    .transient_errors({
200                        let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
201                        transient_errors.push("InternalError");
202                        ::std::borrow::Cow::Owned(transient_errors)
203                    })
204                    .build(),
205            );
206
207        ::std::borrow::Cow::Owned(rcb)
208    }
209}
210
211#[derive(Debug)]
212struct PutObjectResponseDeserializer;
213impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for PutObjectResponseDeserializer {
214    fn deserialize_nonstreaming(
215        &self,
216        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
217    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
218        let (success, status) = (response.status().is_success(), response.status().as_u16());
219        let headers = response.headers();
220        let body = response.body().bytes().expect("body loaded");
221        #[allow(unused_mut)]
222        let mut force_error = false;
223        ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
224        if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
225            force_error = true;
226        }
227        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
228        let parse_result = if !success && status != 200 || force_error {
229            crate::protocol_serde::shape_put_object::de_put_object_http_error(status, headers, body)
230        } else {
231            crate::protocol_serde::shape_put_object::de_put_object_http_response(status, headers, body)
232        };
233        crate::protocol_serde::type_erase_result(parse_result)
234    }
235}
236#[derive(Debug)]
237struct PutObjectRequestSerializer;
238impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for PutObjectRequestSerializer {
239    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
240    fn serialize_input(
241        &self,
242        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
243        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
244    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
245        let input = input.downcast::<crate::operation::put_object::PutObjectInput>().expect("correct type");
246        let _header_serialization_settings = _cfg
247            .load::<crate::serialization_settings::HeaderSerializationSettings>()
248            .cloned()
249            .unwrap_or_default();
250        let mut request_builder = {
251            fn uri_base(
252                _input: &crate::operation::put_object::PutObjectInput,
253                output: &mut ::std::string::String,
254            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
255                use ::std::fmt::Write as _;
256                let input_1 = &_input.key;
257                let input_1 = input_1
258                    .as_ref()
259                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
260                let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
261                if key.is_empty() {
262                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
263                        "key",
264                        "cannot be empty or unset",
265                    ));
266                }
267                ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
268                ::std::result::Result::Ok(())
269            }
270            fn uri_query(
271                _input: &crate::operation::put_object::PutObjectInput,
272                mut output: &mut ::std::string::String,
273            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
274                let mut query = ::aws_smithy_http::query::Writer::new(output);
275                query.push_kv("x-id", "PutObject");
276                ::std::result::Result::Ok(())
277            }
278            #[allow(clippy::unnecessary_wraps)]
279            fn update_http_builder(
280                input: &crate::operation::put_object::PutObjectInput,
281                builder: ::http::request::Builder,
282            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
283                let mut uri = ::std::string::String::new();
284                uri_base(input, &mut uri)?;
285                uri_query(input, &mut uri)?;
286                let builder = crate::protocol_serde::shape_put_object::ser_put_object_headers(input, builder)?;
287                ::std::result::Result::Ok(builder.method("PUT").uri(uri))
288            }
289            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
290            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/octet-stream");
291            builder
292        };
293        let body = crate::protocol_serde::shape_put_object_input::ser_body_http_payload(input.body)?.into_inner();
294        if let Some(content_length) = body.content_length() {
295            let content_length = content_length.to_string();
296            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
297        }
298        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
299    }
300}
301#[derive(Debug)]
302struct PutObjectEndpointParamsInterceptor;
303
304impl ::aws_smithy_runtime_api::client::interceptors::Intercept for PutObjectEndpointParamsInterceptor {
305    fn name(&self) -> &'static str {
306        "PutObjectEndpointParamsInterceptor"
307    }
308
309    fn read_before_execution(
310        &self,
311        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
312            '_,
313            ::aws_smithy_runtime_api::client::interceptors::context::Input,
314            ::aws_smithy_runtime_api::client::interceptors::context::Output,
315            ::aws_smithy_runtime_api::client::interceptors::context::Error,
316        >,
317        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
318    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
319        let _input = context
320            .input()
321            .downcast_ref::<PutObjectInput>()
322            .ok_or("failed to downcast to PutObjectInput")?;
323
324        let params = crate::config::endpoint::Params::builder()
325            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
326            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
327            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
328            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
329            .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
330            .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
331            .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
332            .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
333            .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
334            .set_bucket(Some(
335                _input
336                    .bucket
337                    .clone()
338                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
339                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
340            ))
341            .set_key(Some(
342                _input
343                    .key
344                    .clone()
345                    .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
346                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
347            ))
348            .build()
349            .map_err(|err| {
350                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
351            })?;
352        cfg.interceptor_state()
353            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
354        ::std::result::Result::Ok(())
355    }
356}
357
358// The get_* functions below are generated from JMESPath expressions in the
359// operationContextParams trait. They target the operation's input shape.
360
361#[allow(unreachable_code, unused_variables)]
362#[cfg(test)]
363mod put_object_test {
364
365    /// This test validates that if a content-type is specified, that only one content-type header is sent
366    /// Test ID: DontSendDuplicateContentType
367    #[::tokio::test]
368    #[::tracing_test::traced_test]
369    async fn dont_send_duplicate_content_type_request() {
370        let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
371        let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
372        let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
373        let mut config_builder = config_builder;
374        config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
375
376        let config = config_builder.http_client(http_client).build();
377        let client = crate::Client::from_conf(config);
378        let result = client
379            .put_object()
380            .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
381            .set_key(::std::option::Option::Some("test-key".to_owned()))
382            .set_content_type(::std::option::Option::Some("text/html".to_owned()))
383            .send()
384            .await;
385        let _ = dbg!(result);
386        let http_request = request_receiver.expect_request();
387        let expected_headers = [("content-type", "text/html")];
388        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
389        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
390        ::pretty_assertions::assert_eq!(http_request.method(), "PUT", "method was incorrect");
391        ::pretty_assertions::assert_eq!(uri.path(), "/test-key", "path was incorrect");
392    }
393
394    /// This test validates that if a content-length is specified, that only one content-length header is sent
395    /// Test ID: DontSendDuplicateContentLength
396    #[::tokio::test]
397    #[::tracing_test::traced_test]
398    async fn dont_send_duplicate_content_length_request() {
399        let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
400        let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
401        let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
402        let mut config_builder = config_builder;
403        config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
404
405        let config = config_builder.http_client(http_client).build();
406        let client = crate::Client::from_conf(config);
407        let result = client
408            .put_object()
409            .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
410            .set_key(::std::option::Option::Some("test-key".to_owned()))
411            .set_content_length(::std::option::Option::Some(2))
412            .set_body(::std::option::Option::Some(::aws_smithy_types::byte_stream::ByteStream::from_static(
413                b"ab",
414            )))
415            .send()
416            .await;
417        let _ = dbg!(result);
418        let http_request = request_receiver.expect_request();
419        let expected_headers = [("content-length", "2")];
420        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
421        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
422        ::pretty_assertions::assert_eq!(http_request.method(), "PUT", "method was incorrect");
423        ::pretty_assertions::assert_eq!(uri.path(), "/test-key", "path was incorrect");
424    }
425}
426
427/// Error type for the `PutObjectError` operation.
428#[non_exhaustive]
429#[derive(::std::fmt::Debug)]
430pub enum PutObjectError {
431    /// <p>The existing object was created with a different encryption type. Subsequent write requests must include the appropriate encryption parameters in the request or while creating the session.</p>
432    EncryptionTypeMismatch(crate::types::error::EncryptionTypeMismatch),
433    /// <p>You may receive this error in multiple cases. Depending on the reason for the error, you may receive one of the messages below:</p>
434    /// <ul>
435    /// <li>
436    /// <p>Cannot specify both a write offset value and user-defined object metadata for existing objects.</p></li>
437    /// <li>
438    /// <p>Checksum Type mismatch occurred, expected checksum Type: sha1, actual checksum Type: crc32c.</p></li>
439    /// <li>
440    /// <p>Request body cannot be empty when 'write offset' is specified.</p></li>
441    /// </ul>
442    InvalidRequest(crate::types::error::InvalidRequest),
443    /// <p>The write offset value that you specified does not match the current object size.</p>
444    InvalidWriteOffset(crate::types::error::InvalidWriteOffset),
445    /// <p>You have attempted to add more parts than the maximum of 10000 that are allowed for this object. You can use the CopyObject operation to copy this object to another and then add more data to the newly copied object.</p>
446    TooManyParts(crate::types::error::TooManyParts),
447    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
448    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
449    variable wildcard pattern and check `.code()`:
450     \
451    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
452     \
453    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-PutObjectError) for what information is available for the error.")]
454    Unhandled(crate::error::sealed_unhandled::Unhandled),
455}
456impl PutObjectError {
457    /// Creates the `PutObjectError::Unhandled` variant from any error type.
458    pub fn unhandled(
459        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
460    ) -> Self {
461        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
462            source: err.into(),
463            meta: ::std::default::Default::default(),
464        })
465    }
466
467    /// Creates the `PutObjectError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
468    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
469        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
470            source: err.clone().into(),
471            meta: err,
472        })
473    }
474    ///
475    /// Returns error metadata, which includes the error code, message,
476    /// request ID, and potentially additional information.
477    ///
478    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
479        match self {
480            Self::EncryptionTypeMismatch(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
481            Self::InvalidRequest(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
482            Self::InvalidWriteOffset(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
483            Self::TooManyParts(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
484            Self::Unhandled(e) => &e.meta,
485        }
486    }
487    /// Returns `true` if the error kind is `PutObjectError::EncryptionTypeMismatch`.
488    pub fn is_encryption_type_mismatch(&self) -> bool {
489        matches!(self, Self::EncryptionTypeMismatch(_))
490    }
491    /// Returns `true` if the error kind is `PutObjectError::InvalidRequest`.
492    pub fn is_invalid_request(&self) -> bool {
493        matches!(self, Self::InvalidRequest(_))
494    }
495    /// Returns `true` if the error kind is `PutObjectError::InvalidWriteOffset`.
496    pub fn is_invalid_write_offset(&self) -> bool {
497        matches!(self, Self::InvalidWriteOffset(_))
498    }
499    /// Returns `true` if the error kind is `PutObjectError::TooManyParts`.
500    pub fn is_too_many_parts(&self) -> bool {
501        matches!(self, Self::TooManyParts(_))
502    }
503}
504impl ::std::error::Error for PutObjectError {
505    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
506        match self {
507            Self::EncryptionTypeMismatch(_inner) => ::std::option::Option::Some(_inner),
508            Self::InvalidRequest(_inner) => ::std::option::Option::Some(_inner),
509            Self::InvalidWriteOffset(_inner) => ::std::option::Option::Some(_inner),
510            Self::TooManyParts(_inner) => ::std::option::Option::Some(_inner),
511            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
512        }
513    }
514}
515impl ::std::fmt::Display for PutObjectError {
516    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
517        match self {
518            Self::EncryptionTypeMismatch(_inner) => _inner.fmt(f),
519            Self::InvalidRequest(_inner) => _inner.fmt(f),
520            Self::InvalidWriteOffset(_inner) => _inner.fmt(f),
521            Self::TooManyParts(_inner) => _inner.fmt(f),
522            Self::Unhandled(_inner) => {
523                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
524                    write!(f, "unhandled error ({code})")
525                } else {
526                    f.write_str("unhandled error")
527                }
528            }
529        }
530    }
531}
532impl ::aws_smithy_types::retry::ProvideErrorKind for PutObjectError {
533    fn code(&self) -> ::std::option::Option<&str> {
534        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
535    }
536    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
537        ::std::option::Option::None
538    }
539}
540impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for PutObjectError {
541    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
542        match self {
543            Self::EncryptionTypeMismatch(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
544            Self::InvalidRequest(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
545            Self::InvalidWriteOffset(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
546            Self::TooManyParts(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
547            Self::Unhandled(_inner) => &_inner.meta,
548        }
549    }
550}
551impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for PutObjectError {
552    fn create_unhandled_error(
553        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
554        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
555    ) -> Self {
556        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
557            source,
558            meta: meta.unwrap_or_default(),
559        })
560    }
561}
562impl crate::s3_request_id::RequestIdExt for crate::operation::put_object::PutObjectError {
563    fn extended_request_id(&self) -> Option<&str> {
564        self.meta().extended_request_id()
565    }
566}
567impl ::aws_types::request_id::RequestId for crate::operation::put_object::PutObjectError {
568    fn request_id(&self) -> Option<&str> {
569        self.meta().request_id()
570    }
571}
572
573pub use crate::operation::put_object::_put_object_output::PutObjectOutput;
574
575pub use crate::operation::put_object::_put_object_input::PutObjectInput;
576
577mod _put_object_input;
578
579mod _put_object_output;
580
581/// Builders
582pub mod builders;