1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CreateMultipartUpload;
6impl CreateMultipartUpload {
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::create_multipart_upload::CreateMultipartUploadInput,
14 ) -> ::std::result::Result<
15 crate::operation::create_multipart_upload::CreateMultipartUploadOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::create_multipart_upload::CreateMultipartUploadError,
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::create_multipart_upload::CreateMultipartUploadError>()
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 .instrument(::tracing::debug_span!(
35 "s3.CreateMultipartUpload",
36 "rpc.service" = "s3",
37 "rpc.method" = "CreateMultipartUpload",
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::create_multipart_upload::CreateMultipartUploadOutput>()
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::create_multipart_upload::CreateMultipartUploadInput,
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", "CreateMultipartUpload", 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 CreateMultipartUpload {
95 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
96 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CreateMultipartUpload");
97
98 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
99 CreateMultipartUploadRequestSerializer,
100 ));
101 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
102 CreateMultipartUploadResponseDeserializer,
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(
111 "CreateMultipartUpload",
112 "s3",
113 ));
114 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
115 signing_options.double_uri_encode = false;
116 signing_options.content_sha256_header = true;
117 signing_options.normalize_uri_path = false;
118 signing_options.payload_override = None;
119
120 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
121 signing_options,
122 ..::std::default::Default::default()
123 });
124
125 ::std::option::Option::Some(cfg.freeze())
126 }
127
128 fn runtime_components(
129 &self,
130 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
131 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
132 #[allow(unused_mut)]
133 let mut rcb =
134 ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CreateMultipartUpload")
135 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
136 .with_interceptor(CreateMultipartUploadEndpointParamsInterceptor)
137 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
138 crate::operation::create_multipart_upload::CreateMultipartUploadError,
139 >::new())
140 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
141 crate::operation::create_multipart_upload::CreateMultipartUploadError,
142 >::new())
143 .with_retry_classifier(
144 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
145 crate::operation::create_multipart_upload::CreateMultipartUploadError,
146 >::builder()
147 .transient_errors({
148 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
149 transient_errors.push("InternalError");
150 ::std::borrow::Cow::Owned(transient_errors)
151 })
152 .build(),
153 );
154
155 ::std::borrow::Cow::Owned(rcb)
156 }
157}
158
159#[derive(Debug)]
160struct CreateMultipartUploadResponseDeserializer;
161impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CreateMultipartUploadResponseDeserializer {
162 fn deserialize_nonstreaming(
163 &self,
164 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
165 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
166 let (success, status) = (response.status().is_success(), response.status().as_u16());
167 let headers = response.headers();
168 let body = response.body().bytes().expect("body loaded");
169 #[allow(unused_mut)]
170 let mut force_error = false;
171 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
172 if matches!(crate::rest_xml_unwrapped_errors::body_is_error(body), Ok(true)) {
173 force_error = true;
174 }
175 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
176 let parse_result = if !success && status != 200 || force_error {
177 crate::protocol_serde::shape_create_multipart_upload::de_create_multipart_upload_http_error(status, headers, body)
178 } else {
179 crate::protocol_serde::shape_create_multipart_upload::de_create_multipart_upload_http_response(status, headers, body)
180 };
181 crate::protocol_serde::type_erase_result(parse_result)
182 }
183}
184#[derive(Debug)]
185struct CreateMultipartUploadRequestSerializer;
186impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CreateMultipartUploadRequestSerializer {
187 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
188 fn serialize_input(
189 &self,
190 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
191 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
192 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
193 let input = input
194 .downcast::<crate::operation::create_multipart_upload::CreateMultipartUploadInput>()
195 .expect("correct type");
196 let _header_serialization_settings = _cfg
197 .load::<crate::serialization_settings::HeaderSerializationSettings>()
198 .cloned()
199 .unwrap_or_default();
200 let mut request_builder = {
201 fn uri_base(
202 _input: &crate::operation::create_multipart_upload::CreateMultipartUploadInput,
203 output: &mut ::std::string::String,
204 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
205 use ::std::fmt::Write as _;
206 let input_1 = &_input.key;
207 let input_1 = input_1
208 .as_ref()
209 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
210 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
211 if key.is_empty() {
212 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
213 "key",
214 "cannot be empty or unset",
215 ));
216 }
217 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
218 ::std::result::Result::Ok(())
219 }
220 fn uri_query(
221 _input: &crate::operation::create_multipart_upload::CreateMultipartUploadInput,
222 mut output: &mut ::std::string::String,
223 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
224 let mut query = ::aws_smithy_http::query::Writer::new(output);
225 query.push_v("uploads");
226 ::std::result::Result::Ok(())
227 }
228 #[allow(clippy::unnecessary_wraps)]
229 fn update_http_builder(
230 input: &crate::operation::create_multipart_upload::CreateMultipartUploadInput,
231 builder: ::http::request::Builder,
232 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
233 let mut uri = ::std::string::String::new();
234 uri_base(input, &mut uri)?;
235 uri_query(input, &mut uri)?;
236 let builder = crate::protocol_serde::shape_create_multipart_upload::ser_create_multipart_upload_headers(input, builder)?;
237 ::std::result::Result::Ok(builder.method("POST").uri(uri))
238 }
239 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
240 builder
241 };
242 let body = ::aws_smithy_types::body::SdkBody::from("");
243
244 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
245 }
246}
247#[derive(Debug)]
248struct CreateMultipartUploadEndpointParamsInterceptor;
249
250impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateMultipartUploadEndpointParamsInterceptor {
251 fn name(&self) -> &'static str {
252 "CreateMultipartUploadEndpointParamsInterceptor"
253 }
254
255 fn read_before_execution(
256 &self,
257 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
258 '_,
259 ::aws_smithy_runtime_api::client::interceptors::context::Input,
260 ::aws_smithy_runtime_api::client::interceptors::context::Output,
261 ::aws_smithy_runtime_api::client::interceptors::context::Error,
262 >,
263 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
264 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
265 let _input = context
266 .input()
267 .downcast_ref::<CreateMultipartUploadInput>()
268 .ok_or("failed to downcast to CreateMultipartUploadInput")?;
269
270 let params = crate::config::endpoint::Params::builder()
271 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
272 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
273 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
274 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
275 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
276 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
277 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
278 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
279 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
280 .set_bucket(Some(
281 _input
282 .bucket
283 .clone()
284 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
285 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
286 ))
287 .set_key(Some(
288 _input
289 .key
290 .clone()
291 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
292 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
293 ))
294 .build()
295 .map_err(|err| {
296 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
297 })?;
298 cfg.interceptor_state()
299 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
300 ::std::result::Result::Ok(())
301 }
302}
303
304#[allow(unreachable_code, unused_variables)]
308#[cfg(test)]
309mod create_multipart_upload_test {
310
311 #[::tokio::test]
314 #[::tracing_test::traced_test]
315 async fn create_multipart_upload_uri_construction_request() {
316 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
317 let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
318 let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
319 let mut config_builder = config_builder;
320 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
321
322 let config = config_builder.http_client(http_client).build();
323 let client = crate::Client::from_conf(config);
324 let result = client
325 .create_multipart_upload()
326 .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
327 .set_key(::std::option::Option::Some("object.txt".to_owned()))
328 .send()
329 .await;
330 let _ = dbg!(result);
331 let http_request = request_receiver.expect_request();
332 let expected_query_params = &["uploads"];
333 ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_query_string(&http_request, expected_query_params));
334 let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
335 ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
336 ::pretty_assertions::assert_eq!(uri.path(), "/object.txt", "path was incorrect");
337 }
338}
339
340#[non_exhaustive]
342#[derive(::std::fmt::Debug)]
343pub enum CreateMultipartUploadError {
344 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
346 variable wildcard pattern and check `.code()`:
347 \
348 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
349 \
350 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CreateMultipartUploadError) for what information is available for the error.")]
351 Unhandled(crate::error::sealed_unhandled::Unhandled),
352}
353impl CreateMultipartUploadError {
354 pub fn unhandled(
356 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
357 ) -> Self {
358 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
359 source: err.into(),
360 meta: ::std::default::Default::default(),
361 })
362 }
363
364 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
366 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
367 source: err.clone().into(),
368 meta: err,
369 })
370 }
371 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
376 match self {
377 Self::Unhandled(e) => &e.meta,
378 }
379 }
380}
381impl ::std::error::Error for CreateMultipartUploadError {
382 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
383 match self {
384 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
385 }
386 }
387}
388impl ::std::fmt::Display for CreateMultipartUploadError {
389 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
390 match self {
391 Self::Unhandled(_inner) => {
392 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
393 write!(f, "unhandled error ({code})")
394 } else {
395 f.write_str("unhandled error")
396 }
397 }
398 }
399 }
400}
401impl ::aws_smithy_types::retry::ProvideErrorKind for CreateMultipartUploadError {
402 fn code(&self) -> ::std::option::Option<&str> {
403 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
404 }
405 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
406 ::std::option::Option::None
407 }
408}
409impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CreateMultipartUploadError {
410 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
411 match self {
412 Self::Unhandled(_inner) => &_inner.meta,
413 }
414 }
415}
416impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CreateMultipartUploadError {
417 fn create_unhandled_error(
418 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
419 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
420 ) -> Self {
421 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
422 source,
423 meta: meta.unwrap_or_default(),
424 })
425 }
426}
427impl crate::s3_request_id::RequestIdExt for crate::operation::create_multipart_upload::CreateMultipartUploadError {
428 fn extended_request_id(&self) -> Option<&str> {
429 self.meta().extended_request_id()
430 }
431}
432impl ::aws_types::request_id::RequestId for crate::operation::create_multipart_upload::CreateMultipartUploadError {
433 fn request_id(&self) -> Option<&str> {
434 self.meta().request_id()
435 }
436}
437
438pub use crate::operation::create_multipart_upload::_create_multipart_upload_output::CreateMultipartUploadOutput;
439
440pub use crate::operation::create_multipart_upload::_create_multipart_upload_input::CreateMultipartUploadInput;
441
442mod _create_multipart_upload_input;
443
444mod _create_multipart_upload_output;
445
446pub mod builders;