1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct PutBucketOwnershipControls;
6impl PutBucketOwnershipControls {
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_bucket_ownership_controls::PutBucketOwnershipControlsInput,
14 ) -> ::std::result::Result<
15 crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError,
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_bucket_ownership_controls::PutBucketOwnershipControlsError>()
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.PutBucketOwnershipControls",
36 "rpc.service" = "s3",
37 "rpc.method" = "PutBucketOwnershipControls",
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::put_bucket_ownership_controls::PutBucketOwnershipControlsOutput>()
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::put_bucket_ownership_controls::PutBucketOwnershipControlsInput,
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", "PutBucketOwnershipControls", input, runtime_plugins, stop_point)
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 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
74 ::aws_runtime::auth::sigv4::SCHEME_ID,
75 #[cfg(feature = "sigv4a")]
76 {
77 ::aws_runtime::auth::sigv4a::SCHEME_ID
78 },
79 crate::s3_express::auth::SCHEME_ID,
80 ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
81 ]));
82 if let ::std::option::Option::Some(config_override) = config_override {
83 for plugin in config_override.runtime_plugins.iter().cloned() {
84 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
85 }
86 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
87 config_override,
88 client_config.config.clone(),
89 &client_config.runtime_components,
90 ));
91 }
92 runtime_plugins
93 }
94}
95impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for PutBucketOwnershipControls {
96 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
97 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("PutBucketOwnershipControls");
98
99 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
100 PutBucketOwnershipControlsRequestSerializer,
101 ));
102 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
103 PutBucketOwnershipControlsResponseDeserializer,
104 ));
105
106 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
107 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
108 ));
109
110 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
111 "PutBucketOwnershipControls",
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 cfg.store_put(crate::s3_express::checksum::provide_default_checksum_algorithm());
125
126 ::std::option::Option::Some(cfg.freeze())
127 }
128
129 fn runtime_components(
130 &self,
131 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
132 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
133 #[allow(unused_mut)]
134 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("PutBucketOwnershipControls")
135 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
136 .with_interceptor(PutBucketOwnershipControlsEndpointParamsInterceptor)
137 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
138 crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError,
139 >::new())
140 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
141 crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError,
142 >::new())
143 .with_retry_classifier(
144 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
145 crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError,
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 PutBucketOwnershipControlsResponseDeserializer;
161impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for PutBucketOwnershipControlsResponseDeserializer {
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_put_bucket_ownership_controls::de_put_bucket_ownership_controls_http_error(status, headers, body)
178 } else {
179 crate::protocol_serde::shape_put_bucket_ownership_controls::de_put_bucket_ownership_controls_http_response(status, headers, body)
180 };
181 crate::protocol_serde::type_erase_result(parse_result)
182 }
183}
184#[derive(Debug)]
185struct PutBucketOwnershipControlsRequestSerializer;
186impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for PutBucketOwnershipControlsRequestSerializer {
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::put_bucket_ownership_controls::PutBucketOwnershipControlsInput>()
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::put_bucket_ownership_controls::PutBucketOwnershipControlsInput,
203 output: &mut ::std::string::String,
204 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
205 use ::std::fmt::Write as _;
206 ::std::write!(output, "/").expect("formatting should succeed");
207 ::std::result::Result::Ok(())
208 }
209 fn uri_query(
210 _input: &crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsInput,
211 mut output: &mut ::std::string::String,
212 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
213 let mut query = ::aws_smithy_http::query::Writer::new(output);
214 query.push_v("ownershipControls");
215 ::std::result::Result::Ok(())
216 }
217 #[allow(clippy::unnecessary_wraps)]
218 fn update_http_builder(
219 input: &crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsInput,
220 builder: ::http::request::Builder,
221 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
222 let mut uri = ::std::string::String::new();
223 uri_base(input, &mut uri)?;
224 uri_query(input, &mut uri)?;
225 let builder = crate::protocol_serde::shape_put_bucket_ownership_controls::ser_put_bucket_ownership_controls_headers(input, builder)?;
226 ::std::result::Result::Ok(builder.method("PUT").uri(uri))
227 }
228 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
229 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/xml");
230 builder
231 };
232 let body = ::aws_smithy_types::body::SdkBody::from(
233 crate::protocol_serde::shape_put_bucket_ownership_controls_input::ser_ownership_controls_http_payload(&input.ownership_controls)?,
234 );
235 if let Some(content_length) = body.content_length() {
236 let content_length = content_length.to_string();
237 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
238 }
239 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
240 }
241}
242#[derive(Debug)]
243struct PutBucketOwnershipControlsEndpointParamsInterceptor;
244
245impl ::aws_smithy_runtime_api::client::interceptors::Intercept for PutBucketOwnershipControlsEndpointParamsInterceptor {
246 fn name(&self) -> &'static str {
247 "PutBucketOwnershipControlsEndpointParamsInterceptor"
248 }
249
250 fn read_before_execution(
251 &self,
252 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
253 '_,
254 ::aws_smithy_runtime_api::client::interceptors::context::Input,
255 ::aws_smithy_runtime_api::client::interceptors::context::Output,
256 ::aws_smithy_runtime_api::client::interceptors::context::Error,
257 >,
258 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
259 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
260 let _input = context
261 .input()
262 .downcast_ref::<PutBucketOwnershipControlsInput>()
263 .ok_or("failed to downcast to PutBucketOwnershipControlsInput")?;
264
265 let params = crate::config::endpoint::Params::builder()
266 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
267 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
268 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
269 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
270 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
271 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
272 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
273 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
274 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
275 .set_use_s3_express_control_endpoint(Some(true))
276 .set_bucket(Some(
277 _input
278 .bucket
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("bucket", "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 PutBucketOwnershipControlsError {
300 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
302 variable wildcard pattern and check `.code()`:
303 \
304 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
305 \
306 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-PutBucketOwnershipControlsError) for what information is available for the error.")]
307 Unhandled(crate::error::sealed_unhandled::Unhandled),
308}
309impl PutBucketOwnershipControlsError {
310 pub fn unhandled(
312 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
313 ) -> Self {
314 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
315 source: err.into(),
316 meta: ::std::default::Default::default(),
317 })
318 }
319
320 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
322 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
323 source: err.clone().into(),
324 meta: err,
325 })
326 }
327 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
332 match self {
333 Self::Unhandled(e) => &e.meta,
334 }
335 }
336}
337impl ::std::error::Error for PutBucketOwnershipControlsError {
338 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
339 match self {
340 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
341 }
342 }
343}
344impl ::std::fmt::Display for PutBucketOwnershipControlsError {
345 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
346 match self {
347 Self::Unhandled(_inner) => {
348 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
349 write!(f, "unhandled error ({code})")
350 } else {
351 f.write_str("unhandled error")
352 }
353 }
354 }
355 }
356}
357impl ::aws_smithy_types::retry::ProvideErrorKind for PutBucketOwnershipControlsError {
358 fn code(&self) -> ::std::option::Option<&str> {
359 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
360 }
361 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
362 ::std::option::Option::None
363 }
364}
365impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for PutBucketOwnershipControlsError {
366 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
367 match self {
368 Self::Unhandled(_inner) => &_inner.meta,
369 }
370 }
371}
372impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for PutBucketOwnershipControlsError {
373 fn create_unhandled_error(
374 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
375 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
376 ) -> Self {
377 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
378 source,
379 meta: meta.unwrap_or_default(),
380 })
381 }
382}
383impl crate::s3_request_id::RequestIdExt for crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError {
384 fn extended_request_id(&self) -> Option<&str> {
385 self.meta().extended_request_id()
386 }
387}
388impl ::aws_types::request_id::RequestId for crate::operation::put_bucket_ownership_controls::PutBucketOwnershipControlsError {
389 fn request_id(&self) -> Option<&str> {
390 self.meta().request_id()
391 }
392}
393
394pub use crate::operation::put_bucket_ownership_controls::_put_bucket_ownership_controls_output::PutBucketOwnershipControlsOutput;
395
396pub use crate::operation::put_bucket_ownership_controls::_put_bucket_ownership_controls_input::PutBucketOwnershipControlsInput;
397
398mod _put_bucket_ownership_controls_input;
399
400mod _put_bucket_ownership_controls_output;
401
402pub mod builders;