1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct PutObjectLockConfiguration;
6impl PutObjectLockConfiguration {
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::put_object_lock_configuration::PutObjectLockConfigurationInput,
14 ) -> ::std::result::Result<
15 crate::operation::put_object_lock_configuration::PutObjectLockConfigurationOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError,
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_lock_configuration::PutObjectLockConfigurationError>()
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::put_object_lock_configuration::PutObjectLockConfigurationOutput>()
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::put_object_lock_configuration::PutObjectLockConfigurationInput,
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 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("s3", "PutObjectLockConfiguration", input, runtime_plugins, stop_point)
54 .await
55 }
56
57 pub(crate) fn operation_runtime_plugins(
58 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
59 client_config: &crate::config::Config,
60 config_override: ::std::option::Option<crate::config::Builder>,
61 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
62 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
63 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
64 ::aws_runtime::auth::sigv4::SCHEME_ID,
65 #[cfg(feature = "sigv4a")]
66 {
67 ::aws_runtime::auth::sigv4a::SCHEME_ID
68 },
69 crate::s3_express::auth::SCHEME_ID,
70 ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
71 ]));
72 if let ::std::option::Option::Some(config_override) = config_override {
73 for plugin in config_override.runtime_plugins.iter().cloned() {
74 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
75 }
76 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
77 config_override,
78 client_config.config.clone(),
79 &client_config.runtime_components,
80 ));
81 }
82 runtime_plugins
83 }
84}
85impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for PutObjectLockConfiguration {
86 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
87 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("PutObjectLockConfiguration");
88
89 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
90 PutObjectLockConfigurationRequestSerializer,
91 ));
92 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
93 PutObjectLockConfigurationResponseDeserializer,
94 ));
95
96 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
97 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
98 ));
99
100 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
101 "PutObjectLockConfiguration",
102 "s3",
103 ));
104 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
105 signing_options.double_uri_encode = false;
106 signing_options.content_sha256_header = true;
107 signing_options.normalize_uri_path = false;
108 signing_options.payload_override = None;
109
110 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
111 signing_options,
112 ..::std::default::Default::default()
113 });
114 cfg.store_put(crate::s3_express::checksum::provide_default_checksum_algorithm());
115
116 ::std::option::Option::Some(cfg.freeze())
117 }
118
119 fn runtime_components(
120 &self,
121 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
122 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
123 #[allow(unused_mut)]
124 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("PutObjectLockConfiguration")
125 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
126 .with_interceptor(PutObjectLockConfigurationEndpointParamsInterceptor)
127 .with_interceptor(crate::http_request_checksum::RequestChecksumInterceptor::new(
128 |input: &::aws_smithy_runtime_api::client::interceptors::context::Input| {
129 let input: &crate::operation::put_object_lock_configuration::PutObjectLockConfigurationInput =
130 input.downcast_ref().expect("correct type");
131 let checksum_algorithm = input.checksum_algorithm();
132 let checksum_algorithm = checksum_algorithm.map(|algorithm| algorithm.as_str());
133 (checksum_algorithm.map(|s| s.to_string()), true)
134 },
135 |request: &mut ::aws_smithy_runtime_api::http::Request, cfg: &::aws_smithy_types::config_bag::ConfigBag| {
136 let mut user_set_checksum_value = false;
138 let headers_to_check =
139 request
140 .headers()
141 .iter()
142 .filter_map(|(name, _val)| if name.starts_with("x-amz-checksum-") { Some(name) } else { None });
143 for algo_header in headers_to_check {
144 if request.headers().get(algo_header).is_some() {
145 user_set_checksum_value = true;
146 }
147 }
148
149 let user_set_checksum_algo = request.headers().get("x-amz-sdk-checksum-algorithm").is_some();
151
152 let request_checksum_calculation = cfg
154 .load::<::aws_smithy_types::checksum_config::RequestChecksumCalculation>()
155 .unwrap_or(&::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported);
156
157 let http_checksum_required = true;
159
160 let is_presigned_req = cfg.load::<crate::presigning::PresigningMarker>().is_some();
161
162 match (
167 request_checksum_calculation,
168 http_checksum_required,
169 user_set_checksum_value,
170 user_set_checksum_algo,
171 is_presigned_req,
172 ) {
173 (_, _, _, _, true) => {}
174 (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported, _, false, false, _)
175 | (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenRequired, true, false, false, _) => {
176 request.headers_mut().insert("x-amz-sdk-checksum-algorithm", "CRC32");
177 }
178 _ => {}
179 }
180
181 Ok(user_set_checksum_value)
184 },
185 ))
186 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
187 crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError,
188 >::new())
189 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
190 crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError,
191 >::new())
192 .with_retry_classifier(
193 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
194 crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError,
195 >::builder()
196 .transient_errors({
197 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
198 transient_errors.push("InternalError");
199 ::std::borrow::Cow::Owned(transient_errors)
200 })
201 .build(),
202 );
203
204 ::std::borrow::Cow::Owned(rcb)
205 }
206}
207
208#[derive(Debug)]
209struct PutObjectLockConfigurationResponseDeserializer;
210impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for PutObjectLockConfigurationResponseDeserializer {
211 fn deserialize_nonstreaming(
212 &self,
213 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
214 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
215 let (success, status) = (response.status().is_success(), response.status().as_u16());
216 let headers = response.headers();
217 let body = response.body().bytes().expect("body loaded");
218 #[allow(unused_mut)]
219 let mut force_error = false;
220 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
221 if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
222 force_error = true;
223 }
224 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
225 let parse_result = if !success && status != 200 || force_error {
226 crate::protocol_serde::shape_put_object_lock_configuration::de_put_object_lock_configuration_http_error(status, headers, body)
227 } else {
228 crate::protocol_serde::shape_put_object_lock_configuration::de_put_object_lock_configuration_http_response(status, headers, body)
229 };
230 crate::protocol_serde::type_erase_result(parse_result)
231 }
232}
233#[derive(Debug)]
234struct PutObjectLockConfigurationRequestSerializer;
235impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for PutObjectLockConfigurationRequestSerializer {
236 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
237 fn serialize_input(
238 &self,
239 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
240 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
241 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
242 let input = input
243 .downcast::<crate::operation::put_object_lock_configuration::PutObjectLockConfigurationInput>()
244 .expect("correct type");
245 let _header_serialization_settings = _cfg
246 .load::<crate::serialization_settings::HeaderSerializationSettings>()
247 .cloned()
248 .unwrap_or_default();
249 let mut request_builder = {
250 fn uri_base(
251 _input: &crate::operation::put_object_lock_configuration::PutObjectLockConfigurationInput,
252 output: &mut ::std::string::String,
253 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
254 use ::std::fmt::Write as _;
255 ::std::write!(output, "/").expect("formatting should succeed");
256 ::std::result::Result::Ok(())
257 }
258 fn uri_query(
259 _input: &crate::operation::put_object_lock_configuration::PutObjectLockConfigurationInput,
260 mut output: &mut ::std::string::String,
261 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
262 let mut query = ::aws_smithy_http::query::Writer::new(output);
263 query.push_v("object-lock");
264 ::std::result::Result::Ok(())
265 }
266 #[allow(clippy::unnecessary_wraps)]
267 fn update_http_builder(
268 input: &crate::operation::put_object_lock_configuration::PutObjectLockConfigurationInput,
269 builder: ::http::request::Builder,
270 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
271 let mut uri = ::std::string::String::new();
272 uri_base(input, &mut uri)?;
273 uri_query(input, &mut uri)?;
274 let builder = crate::protocol_serde::shape_put_object_lock_configuration::ser_put_object_lock_configuration_headers(input, builder)?;
275 ::std::result::Result::Ok(builder.method("PUT").uri(uri))
276 }
277 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
278 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/xml");
279 builder
280 };
281 let body = ::aws_smithy_types::body::SdkBody::from(
282 crate::protocol_serde::shape_put_object_lock_configuration_input::ser_object_lock_configuration_http_payload(
283 &input.object_lock_configuration,
284 )?,
285 );
286 if let Some(content_length) = body.content_length() {
287 let content_length = content_length.to_string();
288 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
289 }
290 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
291 }
292}
293#[derive(Debug)]
294struct PutObjectLockConfigurationEndpointParamsInterceptor;
295
296impl ::aws_smithy_runtime_api::client::interceptors::Intercept for PutObjectLockConfigurationEndpointParamsInterceptor {
297 fn name(&self) -> &'static str {
298 "PutObjectLockConfigurationEndpointParamsInterceptor"
299 }
300
301 fn read_before_execution(
302 &self,
303 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
304 '_,
305 ::aws_smithy_runtime_api::client::interceptors::context::Input,
306 ::aws_smithy_runtime_api::client::interceptors::context::Output,
307 ::aws_smithy_runtime_api::client::interceptors::context::Error,
308 >,
309 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
310 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
311 let _input = context
312 .input()
313 .downcast_ref::<PutObjectLockConfigurationInput>()
314 .ok_or("failed to downcast to PutObjectLockConfigurationInput")?;
315
316 let params = crate::config::endpoint::Params::builder()
317 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
318 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
319 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
320 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
321 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
322 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
323 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
324 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
325 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
326 .set_bucket(Some(
327 _input
328 .bucket
329 .clone()
330 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
331 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
332 ))
333 .build()
334 .map_err(|err| {
335 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
336 })?;
337 cfg.interceptor_state()
338 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
339 ::std::result::Result::Ok(())
340 }
341}
342
343#[non_exhaustive]
348#[derive(::std::fmt::Debug)]
349pub enum PutObjectLockConfigurationError {
350 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
352 variable wildcard pattern and check `.code()`:
353 \
354 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
355 \
356 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-PutObjectLockConfigurationError) for what information is available for the error.")]
357 Unhandled(crate::error::sealed_unhandled::Unhandled),
358}
359impl PutObjectLockConfigurationError {
360 pub fn unhandled(
362 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
363 ) -> Self {
364 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
365 source: err.into(),
366 meta: ::std::default::Default::default(),
367 })
368 }
369
370 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
372 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
373 source: err.clone().into(),
374 meta: err,
375 })
376 }
377 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
382 match self {
383 Self::Unhandled(e) => &e.meta,
384 }
385 }
386}
387impl ::std::error::Error for PutObjectLockConfigurationError {
388 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
389 match self {
390 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
391 }
392 }
393}
394impl ::std::fmt::Display for PutObjectLockConfigurationError {
395 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
396 match self {
397 Self::Unhandled(_inner) => {
398 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
399 write!(f, "unhandled error ({code})")
400 } else {
401 f.write_str("unhandled error")
402 }
403 }
404 }
405 }
406}
407impl ::aws_smithy_types::retry::ProvideErrorKind for PutObjectLockConfigurationError {
408 fn code(&self) -> ::std::option::Option<&str> {
409 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
410 }
411 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
412 ::std::option::Option::None
413 }
414}
415impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for PutObjectLockConfigurationError {
416 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
417 match self {
418 Self::Unhandled(_inner) => &_inner.meta,
419 }
420 }
421}
422impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for PutObjectLockConfigurationError {
423 fn create_unhandled_error(
424 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
425 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
426 ) -> Self {
427 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
428 source,
429 meta: meta.unwrap_or_default(),
430 })
431 }
432}
433impl crate::s3_request_id::RequestIdExt for crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError {
434 fn extended_request_id(&self) -> Option<&str> {
435 self.meta().extended_request_id()
436 }
437}
438impl ::aws_types::request_id::RequestId for crate::operation::put_object_lock_configuration::PutObjectLockConfigurationError {
439 fn request_id(&self) -> Option<&str> {
440 self.meta().request_id()
441 }
442}
443
444pub use crate::operation::put_object_lock_configuration::_put_object_lock_configuration_output::PutObjectLockConfigurationOutput;
445
446pub use crate::operation::put_object_lock_configuration::_put_object_lock_configuration_input::PutObjectLockConfigurationInput;
447
448mod _put_object_lock_configuration_input;
449
450mod _put_object_lock_configuration_output;
451
452pub mod builders;