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