1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CopyObject;
6impl CopyObject {
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::copy_object::CopyObjectInput,
14 ) -> ::std::result::Result<
15 crate::operation::copy_object::CopyObjectOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::copy_object::CopyObjectError,
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::copy_object::CopyObjectError>()
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::copy_object::CopyObjectOutput>()
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::copy_object::CopyObjectInput,
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", "CopyObject", 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 CopyObject {
85 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
86 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CopyObject");
87
88 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
89 CopyObjectRequestSerializer,
90 ));
91 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
92 CopyObjectResponseDeserializer,
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::SensitiveOutput);
100 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("CopyObject", "s3"));
101 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
102 signing_options.double_uri_encode = false;
103 signing_options.content_sha256_header = true;
104 signing_options.normalize_uri_path = false;
105 signing_options.payload_override = None;
106
107 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
108 signing_options,
109 ..::std::default::Default::default()
110 });
111
112 ::std::option::Option::Some(cfg.freeze())
113 }
114
115 fn runtime_components(
116 &self,
117 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
118 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
119 #[allow(unused_mut)]
120 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CopyObject")
121 .with_interceptor(CopyObjectEndpointParamsInterceptor)
122 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
123 crate::operation::copy_object::CopyObjectError,
124 >::new())
125 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
126 crate::operation::copy_object::CopyObjectError,
127 >::new())
128 .with_retry_classifier(
129 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::copy_object::CopyObjectError>::builder()
130 .transient_errors({
131 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
132 transient_errors.push("InternalError");
133 ::std::borrow::Cow::Owned(transient_errors)
134 })
135 .build(),
136 );
137
138 ::std::borrow::Cow::Owned(rcb)
139 }
140}
141
142#[derive(Debug)]
143struct CopyObjectResponseDeserializer;
144impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CopyObjectResponseDeserializer {
145 fn deserialize_nonstreaming(
146 &self,
147 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
148 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
149 let (success, status) = (response.status().is_success(), response.status().as_u16());
150 let headers = response.headers();
151 let body = response.body().bytes().expect("body loaded");
152 #[allow(unused_mut)]
153 let mut force_error = false;
154 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
155 if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
156 force_error = true;
157 }
158 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
159 let parse_result = if !success && status != 200 || force_error {
160 crate::protocol_serde::shape_copy_object::de_copy_object_http_error(status, headers, body)
161 } else {
162 crate::protocol_serde::shape_copy_object::de_copy_object_http_response(status, headers, body)
163 };
164 crate::protocol_serde::type_erase_result(parse_result)
165 }
166}
167#[derive(Debug)]
168struct CopyObjectRequestSerializer;
169impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CopyObjectRequestSerializer {
170 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
171 fn serialize_input(
172 &self,
173 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
174 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
175 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
176 let input = input.downcast::<crate::operation::copy_object::CopyObjectInput>().expect("correct type");
177 let _header_serialization_settings = _cfg
178 .load::<crate::serialization_settings::HeaderSerializationSettings>()
179 .cloned()
180 .unwrap_or_default();
181 let mut request_builder = {
182 fn uri_base(
183 _input: &crate::operation::copy_object::CopyObjectInput,
184 output: &mut ::std::string::String,
185 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
186 use ::std::fmt::Write as _;
187 let input_1 = &_input.key;
188 let input_1 = input_1
189 .as_ref()
190 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
191 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
192 if key.is_empty() {
193 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
194 "key",
195 "cannot be empty or unset",
196 ));
197 }
198 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
199 ::std::result::Result::Ok(())
200 }
201 fn uri_query(
202 _input: &crate::operation::copy_object::CopyObjectInput,
203 mut output: &mut ::std::string::String,
204 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
205 let mut query = ::aws_smithy_http::query::Writer::new(output);
206 query.push_kv("x-id", "CopyObject");
207 ::std::result::Result::Ok(())
208 }
209 #[allow(clippy::unnecessary_wraps)]
210 fn update_http_builder(
211 input: &crate::operation::copy_object::CopyObjectInput,
212 builder: ::http::request::Builder,
213 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
214 let mut uri = ::std::string::String::new();
215 uri_base(input, &mut uri)?;
216 uri_query(input, &mut uri)?;
217 let builder = crate::protocol_serde::shape_copy_object::ser_copy_object_headers(input, builder)?;
218 ::std::result::Result::Ok(builder.method("PUT").uri(uri))
219 }
220 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
221 builder
222 };
223 let body = ::aws_smithy_types::body::SdkBody::from("");
224
225 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
226 }
227}
228#[derive(Debug)]
229struct CopyObjectEndpointParamsInterceptor;
230
231impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CopyObjectEndpointParamsInterceptor {
232 fn name(&self) -> &'static str {
233 "CopyObjectEndpointParamsInterceptor"
234 }
235
236 fn read_before_execution(
237 &self,
238 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
239 '_,
240 ::aws_smithy_runtime_api::client::interceptors::context::Input,
241 ::aws_smithy_runtime_api::client::interceptors::context::Output,
242 ::aws_smithy_runtime_api::client::interceptors::context::Error,
243 >,
244 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
245 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
246 let _input = context
247 .input()
248 .downcast_ref::<CopyObjectInput>()
249 .ok_or("failed to downcast to CopyObjectInput")?;
250
251 let params = crate::config::endpoint::Params::builder()
252 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
253 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
254 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
255 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
256 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
257 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
258 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
259 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
260 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
261 .set_disable_s3_express_session_auth(Some(true))
262 .set_bucket(Some(
263 _input
264 .bucket
265 .clone()
266 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
267 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
268 ))
269 .set_copy_source(Some(
270 _input
271 .copy_source
272 .clone()
273 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
274 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("copy_source", "A required field was not set"))?,
275 ))
276 .set_key(Some(
277 _input
278 .key
279 .clone()
280 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
281 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
282 ))
283 .build()
284 .map_err(|err| {
285 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
286 })?;
287 cfg.interceptor_state()
288 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
289 ::std::result::Result::Ok(())
290 }
291}
292
293#[non_exhaustive]
298#[derive(::std::fmt::Debug)]
299pub enum CopyObjectError {
300 ObjectNotInActiveTierError(crate::types::error::ObjectNotInActiveTierError),
302 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
304 variable wildcard pattern and check `.code()`:
305 \
306 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
307 \
308 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CopyObjectError) for what information is available for the error.")]
309 Unhandled(crate::error::sealed_unhandled::Unhandled),
310}
311impl CopyObjectError {
312 pub fn unhandled(
314 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
315 ) -> Self {
316 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
317 source: err.into(),
318 meta: ::std::default::Default::default(),
319 })
320 }
321
322 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
324 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
325 source: err.clone().into(),
326 meta: err,
327 })
328 }
329 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
334 match self {
335 Self::ObjectNotInActiveTierError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
336 Self::Unhandled(e) => &e.meta,
337 }
338 }
339 pub fn is_object_not_in_active_tier_error(&self) -> bool {
341 matches!(self, Self::ObjectNotInActiveTierError(_))
342 }
343}
344impl ::std::error::Error for CopyObjectError {
345 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
346 match self {
347 Self::ObjectNotInActiveTierError(_inner) => ::std::option::Option::Some(_inner),
348 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
349 }
350 }
351}
352impl ::std::fmt::Display for CopyObjectError {
353 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
354 match self {
355 Self::ObjectNotInActiveTierError(_inner) => _inner.fmt(f),
356 Self::Unhandled(_inner) => {
357 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
358 write!(f, "unhandled error ({code})")
359 } else {
360 f.write_str("unhandled error")
361 }
362 }
363 }
364 }
365}
366impl ::aws_smithy_types::retry::ProvideErrorKind for CopyObjectError {
367 fn code(&self) -> ::std::option::Option<&str> {
368 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
369 }
370 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
371 ::std::option::Option::None
372 }
373}
374impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CopyObjectError {
375 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
376 match self {
377 Self::ObjectNotInActiveTierError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
378 Self::Unhandled(_inner) => &_inner.meta,
379 }
380 }
381}
382impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CopyObjectError {
383 fn create_unhandled_error(
384 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
385 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
386 ) -> Self {
387 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
388 source,
389 meta: meta.unwrap_or_default(),
390 })
391 }
392}
393impl crate::s3_request_id::RequestIdExt for crate::operation::copy_object::CopyObjectError {
394 fn extended_request_id(&self) -> Option<&str> {
395 self.meta().extended_request_id()
396 }
397}
398impl ::aws_types::request_id::RequestId for crate::operation::copy_object::CopyObjectError {
399 fn request_id(&self) -> Option<&str> {
400 self.meta().request_id()
401 }
402}
403
404pub use crate::operation::copy_object::_copy_object_output::CopyObjectOutput;
405
406pub use crate::operation::copy_object::_copy_object_input::CopyObjectInput;
407
408mod _copy_object_input;
409
410mod _copy_object_output;
411
412pub mod builders;