1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct UpdateObjectEncryption;
6impl UpdateObjectEncryption {
7 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::update_object_encryption::UpdateObjectEncryptionInput,
14 ) -> ::std::result::Result<
15 crate::operation::update_object_encryption::UpdateObjectEncryptionOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::update_object_encryption::UpdateObjectEncryptionError,
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::update_object_encryption::UpdateObjectEncryptionError>()
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::update_object_encryption::UpdateObjectEncryptionOutput>()
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::update_object_encryption::UpdateObjectEncryptionInput,
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", "UpdateObjectEncryption", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "S3.UpdateObjectEncryption",
59 "rpc.service" = "S3",
60 "rpc.method" = "UpdateObjectEncryption",
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 UpdateObjectEncryption {
88 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("UpdateObjectEncryption");
90
91 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92 UpdateObjectEncryptionRequestSerializer,
93 ));
94 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95 UpdateObjectEncryptionResponseDeserializer,
96 ));
97
98 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99 crate::config::auth::Params::builder()
100 .operation_name("UpdateObjectEncryption")
101 .build()
102 .expect("required fields set"),
103 ));
104
105 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
106 "UpdateObjectEncryption",
107 "S3",
108 ));
109 cfg.store_put(crate::s3_express::checksum::provide_default_checksum_algorithm());
110 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
111 signing_options.double_uri_encode = false;
112 signing_options.content_sha256_header = true;
113 signing_options.normalize_uri_path = false;
114 signing_options.payload_override = None;
115
116 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
117 signing_options,
118 ..::std::default::Default::default()
119 });
120
121 ::std::option::Option::Some(cfg.freeze())
122 }
123
124 fn runtime_components(
125 &self,
126 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
127 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
128 #[allow(unused_mut)]
129 let mut rcb =
130 ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("UpdateObjectEncryption")
131 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
132 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
133 ))
134 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
135 UpdateObjectEncryptionEndpointParamsInterceptor,
136 ))
137 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
138 crate::http_request_checksum::RequestChecksumInterceptor::new(
139 |input: &::aws_smithy_runtime_api::client::interceptors::context::Input| {
140 let input: &crate::operation::update_object_encryption::UpdateObjectEncryptionInput =
141 input.downcast_ref().expect("correct type");
142 let checksum_algorithm = input.checksum_algorithm();
143 let checksum_algorithm = checksum_algorithm.map(|algorithm| algorithm.as_str());
144 (checksum_algorithm.map(|s| s.to_string()), true)
145 },
146 |request: &mut ::aws_smithy_runtime_api::http::Request, cfg: &::aws_smithy_types::config_bag::ConfigBag| {
147 let mut user_set_checksum_value = false;
149 let headers_to_check =
150 request.headers().iter().filter_map(
151 |(name, _val)| {
152 if name.starts_with("x-amz-checksum-") {
153 Some(name)
154 } else {
155 None
156 }
157 },
158 );
159 for algo_header in headers_to_check {
160 if request.headers().get(algo_header).is_some() {
161 user_set_checksum_value = true;
162 }
163 }
164
165 let user_set_checksum_algo = request.headers().get("x-amz-sdk-checksum-algorithm").is_some();
167
168 let request_checksum_calculation = cfg
170 .load::<::aws_smithy_types::checksum_config::RequestChecksumCalculation>()
171 .unwrap_or(&::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported);
172
173 let http_checksum_required = true;
175
176 let is_presigned_req = cfg.load::<crate::presigning::PresigningMarker>().is_some();
177
178 match (
183 request_checksum_calculation,
184 http_checksum_required,
185 user_set_checksum_value,
186 user_set_checksum_algo,
187 is_presigned_req,
188 ) {
189 (_, _, _, _, true) => {}
190 (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported, _, false, false, _)
191 | (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenRequired, true, false, false, _) => {
192 request.headers_mut().insert("x-amz-sdk-checksum-algorithm", "CRC32");
193 }
194 _ => {}
195 }
196
197 Ok(user_set_checksum_value)
200 },
201 ),
202 ))
203 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
204 crate::operation::update_object_encryption::UpdateObjectEncryptionError,
205 >::new())
206 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
207 crate::operation::update_object_encryption::UpdateObjectEncryptionError,
208 >::new())
209 .with_retry_classifier(
210 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
211 crate::operation::update_object_encryption::UpdateObjectEncryptionError,
212 >::builder()
213 .transient_errors({
214 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
215 transient_errors.push("InternalError");
216 ::std::borrow::Cow::Owned(transient_errors)
217 })
218 .build(),
219 );
220
221 ::std::borrow::Cow::Owned(rcb)
222 }
223}
224
225#[derive(Debug)]
226struct UpdateObjectEncryptionResponseDeserializer;
227impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for UpdateObjectEncryptionResponseDeserializer {
228 fn deserialize_nonstreaming_with_config(
229 &self,
230 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
231 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
232 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
233 let (success, status) = (response.status().is_success(), response.status().as_u16());
234 let headers = response.headers();
235 let body = response.body().bytes().expect("body loaded");
236 #[allow(unused_mut)]
237 let mut force_error = false;
238 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
239 if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
240 force_error = true;
241 }
242 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
243 let parse_result = if !success && status != 200 || force_error {
244 crate::protocol_serde::shape_update_object_encryption::de_update_object_encryption_http_error(status, headers, body)
245 } else {
246 crate::protocol_serde::shape_update_object_encryption::de_update_object_encryption_http_response(status, headers, body)
247 };
248 crate::protocol_serde::type_erase_result(parse_result)
249 }
250}
251#[derive(Debug)]
252struct UpdateObjectEncryptionRequestSerializer;
253impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for UpdateObjectEncryptionRequestSerializer {
254 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
255 fn serialize_input(
256 &self,
257 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
258 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
259 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
260 let input = input
261 .downcast::<crate::operation::update_object_encryption::UpdateObjectEncryptionInput>()
262 .expect("correct type");
263 let _header_serialization_settings = _cfg
264 .load::<crate::serialization_settings::HeaderSerializationSettings>()
265 .cloned()
266 .unwrap_or_default();
267 let mut request_builder = {
268 #[allow(clippy::uninlined_format_args)]
269 fn uri_base(
270 _input: &crate::operation::update_object_encryption::UpdateObjectEncryptionInput,
271 output: &mut ::std::string::String,
272 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
273 use ::std::fmt::Write as _;
274 let input_1 = &_input.key;
275 let input_1 = input_1
276 .as_ref()
277 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
278 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
279 if key.is_empty() {
280 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
281 "key",
282 "cannot be empty or unset",
283 ));
284 }
285 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
286 ::std::result::Result::Ok(())
287 }
288 fn uri_query(
289 _input: &crate::operation::update_object_encryption::UpdateObjectEncryptionInput,
290 mut output: &mut ::std::string::String,
291 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
292 let mut query = ::aws_smithy_http::query::Writer::new(output);
293 query.push_v("encryption");
294 if let ::std::option::Option::Some(inner_2) = &_input.version_id {
295 {
296 query.push_kv("versionId", &::aws_smithy_http::query::fmt_string(inner_2));
297 }
298 }
299 ::std::result::Result::Ok(())
300 }
301 #[allow(clippy::unnecessary_wraps)]
302 fn update_http_builder(
303 input: &crate::operation::update_object_encryption::UpdateObjectEncryptionInput,
304 builder: ::http_1x::request::Builder,
305 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
306 let mut uri = ::std::string::String::new();
307 uri_base(input, &mut uri)?;
308 uri_query(input, &mut uri)?;
309 let builder = crate::protocol_serde::shape_update_object_encryption::ser_update_object_encryption_headers(input, builder)?;
310 ::std::result::Result::Ok(builder.method("PUT").uri(uri))
311 }
312 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
313 builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/xml");
314 builder
315 };
316 let body = ::aws_smithy_types::body::SdkBody::from(
317 crate::protocol_serde::shape_update_object_encryption_input::ser_object_encryption_http_payload(&input.object_encryption)?,
318 );
319 if let Some(content_length) = body.content_length() {
320 let content_length = content_length.to_string();
321 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
322 }
323 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
324 }
325}
326#[derive(Debug)]
327struct UpdateObjectEncryptionEndpointParamsInterceptor;
328
329#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
330impl ::aws_smithy_runtime_api::client::interceptors::Intercept for UpdateObjectEncryptionEndpointParamsInterceptor {
331 fn name(&self) -> &'static str {
332 "UpdateObjectEncryptionEndpointParamsInterceptor"
333 }
334
335 fn read_before_execution(
336 &self,
337 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
338 '_,
339 ::aws_smithy_runtime_api::client::interceptors::context::Input,
340 ::aws_smithy_runtime_api::client::interceptors::context::Output,
341 ::aws_smithy_runtime_api::client::interceptors::context::Error,
342 >,
343 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
344 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
345 let _input = context
346 .input()
347 .downcast_ref::<UpdateObjectEncryptionInput>()
348 .ok_or("failed to downcast to UpdateObjectEncryptionInput")?;
349
350 let params = crate::config::endpoint::Params::builder()
351 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
352 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
353 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
354 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
355 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
356 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
357 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
358 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
359 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
360 .set_bucket(Some(
361 _input
362 .bucket
363 .clone()
364 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
365 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
366 ))
367 .build()
368 .map_err(|err| {
369 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
370 })?;
371 cfg.interceptor_state()
372 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
373 ::std::result::Result::Ok(())
374 }
375}
376
377#[non_exhaustive]
382#[derive(::std::fmt::Debug)]
383pub enum UpdateObjectEncryptionError {
384 AccessDenied(crate::types::error::AccessDenied),
386 InvalidRequest(crate::types::error::InvalidRequest),
388 NoSuchKey(crate::types::error::NoSuchKey),
390 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
392 variable wildcard pattern and check `.code()`:
393 \
394 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
395 \
396 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-UpdateObjectEncryptionError) for what information is available for the error.")]
397 Unhandled(crate::error::sealed_unhandled::Unhandled),
398}
399impl UpdateObjectEncryptionError {
400 pub fn unhandled(
402 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
403 ) -> Self {
404 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
405 source: err.into(),
406 meta: ::std::default::Default::default(),
407 })
408 }
409
410 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
412 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
413 source: err.clone().into(),
414 meta: err,
415 })
416 }
417 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
422 match self {
423 Self::AccessDenied(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
424 Self::InvalidRequest(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
425 Self::NoSuchKey(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
426 Self::Unhandled(e) => &e.meta,
427 }
428 }
429 pub fn is_access_denied(&self) -> bool {
431 matches!(self, Self::AccessDenied(_))
432 }
433 pub fn is_invalid_request(&self) -> bool {
435 matches!(self, Self::InvalidRequest(_))
436 }
437 pub fn is_no_such_key(&self) -> bool {
439 matches!(self, Self::NoSuchKey(_))
440 }
441}
442impl ::std::error::Error for UpdateObjectEncryptionError {
443 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
444 match self {
445 Self::AccessDenied(_inner) => ::std::option::Option::Some(_inner),
446 Self::InvalidRequest(_inner) => ::std::option::Option::Some(_inner),
447 Self::NoSuchKey(_inner) => ::std::option::Option::Some(_inner),
448 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
449 }
450 }
451}
452impl ::std::fmt::Display for UpdateObjectEncryptionError {
453 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
454 match self {
455 Self::AccessDenied(_inner) => _inner.fmt(f),
456 Self::InvalidRequest(_inner) => _inner.fmt(f),
457 Self::NoSuchKey(_inner) => _inner.fmt(f),
458 Self::Unhandled(_inner) => {
459 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
460 write!(f, "unhandled error ({code})")
461 } else {
462 f.write_str("unhandled error")
463 }
464 }
465 }
466 }
467}
468impl ::aws_smithy_types::retry::ProvideErrorKind for UpdateObjectEncryptionError {
469 fn code(&self) -> ::std::option::Option<&str> {
470 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
471 }
472 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
473 ::std::option::Option::None
474 }
475}
476impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for UpdateObjectEncryptionError {
477 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
478 match self {
479 Self::AccessDenied(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
480 Self::InvalidRequest(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
481 Self::NoSuchKey(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
482 Self::Unhandled(_inner) => &_inner.meta,
483 }
484 }
485}
486impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for UpdateObjectEncryptionError {
487 fn create_unhandled_error(
488 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
489 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
490 ) -> Self {
491 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
492 source,
493 meta: meta.unwrap_or_default(),
494 })
495 }
496}
497impl crate::s3_request_id::RequestIdExt for crate::operation::update_object_encryption::UpdateObjectEncryptionError {
498 fn extended_request_id(&self) -> Option<&str> {
499 self.meta().extended_request_id()
500 }
501}
502impl ::aws_types::request_id::RequestId for crate::operation::update_object_encryption::UpdateObjectEncryptionError {
503 fn request_id(&self) -> Option<&str> {
504 self.meta().request_id()
505 }
506}
507
508pub use crate::operation::update_object_encryption::_update_object_encryption_input::UpdateObjectEncryptionInput;
509
510pub use crate::operation::update_object_encryption::_update_object_encryption_output::UpdateObjectEncryptionOutput;
511
512mod _update_object_encryption_input;
513
514mod _update_object_encryption_output;
515
516pub mod builders;