aws_sdk_s3/config.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#![allow(clippy::empty_line_after_doc_comments)]
3/// Configuration for a aws_sdk_s3 service client.
4///
5
6/// Service configuration allows for customization of endpoints, region, credentials providers,
7/// and retry configuration. Generally, it is constructed automatically for you from a shared
8/// configuration loaded by the `aws-config` crate. For example:
9///
10/// ```ignore
11/// // Load a shared config from the environment
12/// let shared_config = aws_config::from_env().load().await;
13/// // The client constructor automatically converts the shared config into the service config
14/// let client = Client::new(&shared_config);
15/// ```
16///
17/// The service config can also be constructed manually using its builder.
18///
19#[derive(::std::clone::Clone, ::std::fmt::Debug)]
20pub struct Config {
21 // Both `config` and `cloneable` are the same config, but the cloneable one
22 // is kept around so that it is possible to convert back into a builder. This can be
23 // optimized in the future.
24 pub(crate) config: crate::config::FrozenLayer,
25 cloneable: ::aws_smithy_types::config_bag::CloneableLayer,
26 pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
27 pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
28 pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
29}
30impl Config {
31 ///
32 /// Constructs a config builder.
33 /// <div class="warning">
34 /// Note that a config created from this builder will not have the same safe defaults as one created by
35 /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
36 /// </div>
37 ///
38 pub fn builder() -> Builder {
39 Builder::default()
40 }
41 /// Converts this config back into a builder so that it can be tweaked.
42 pub fn to_builder(&self) -> Builder {
43 Builder {
44 config: self.cloneable.clone(),
45 runtime_components: self.runtime_components.clone(),
46 runtime_plugins: self.runtime_plugins.clone(),
47 behavior_version: self.behavior_version,
48 }
49 }
50 /// Return a reference to the stalled stream protection configuration contained in this config, if any.
51 pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
52 self.config.load::<crate::config::StalledStreamProtectionConfig>()
53 }
54 /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
55 pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
56 self.runtime_components.http_client()
57 }
58 /// Return the auth schemes configured on this service config
59 pub fn auth_schemes(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::auth::SharedAuthScheme> + '_ {
60 self.runtime_components.auth_schemes()
61 }
62
63 /// Return the auth scheme resolver configured on this service config
64 pub fn auth_scheme_resolver(&self) -> ::std::option::Option<::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver> {
65 self.runtime_components.auth_scheme_option_resolver()
66 }
67 /// Returns the configured auth scheme preference
68 pub fn auth_scheme_preference(&self) -> ::std::option::Option<&::aws_smithy_runtime_api::client::auth::AuthSchemePreference> {
69 self.config.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>()
70 }
71
72 /// Returns the endpoint resolver.
73 pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
74 self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
75 }
76 /// Return a reference to the retry configuration contained in this config, if any.
77 pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
78 self.config.load::<::aws_smithy_types::retry::RetryConfig>()
79 }
80
81 /// Return a cloned shared async sleep implementation from this config, if any.
82 pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
83 self.runtime_components.sleep_impl()
84 }
85
86 /// Return a reference to the timeout configuration contained in this config, if any.
87 pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
88 self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
89 }
90
91 /// Returns a reference to the retry partition contained in this config, if any.
92 ///
93 /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
94 /// method for anything!
95 pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
96 self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
97 }
98 /// Returns the configured identity cache for auth.
99 pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
100 self.runtime_components.identity_cache()
101 }
102 /// Returns interceptors currently registered by the user.
103 pub fn interceptors(&self) -> impl Iterator<Item = crate::config::SharedInterceptor> + '_ {
104 self.runtime_components.interceptors()
105 }
106 /// Return time source used for this service.
107 pub fn time_source(&self) -> ::std::option::Option<::aws_smithy_async::time::SharedTimeSource> {
108 self.runtime_components.time_source()
109 }
110 /// Returns retry classifiers currently registered by the user.
111 pub fn retry_classifiers(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier> + '_ {
112 self.runtime_components.retry_classifiers()
113 }
114 /// Returns the name of the app that is using the client, if it was provided.
115 ///
116 /// This _optional_ name is used to identify the application in the user agent that
117 /// gets sent along with requests.
118 pub fn app_name(&self) -> ::std::option::Option<&::aws_types::app_name::AppName> {
119 self.config.load::<::aws_types::app_name::AppName>()
120 }
121 /// Returns the framework metadata that has been configured, if any.
122 ///
123 /// This _optional_ metadata identifies software frameworks or third-party libraries
124 /// being used with the client, rendered into the user agent as `lib/{name}/{version}`.
125 /// Entries are returned in first-seen (insertion) order, matching the order they are
126 /// rendered into the user agent.
127 pub fn framework_metadata(&self) -> ::std::vec::Vec<&::aws_types::sdk_ua_metadata::FrameworkMetadata> {
128 // `StoreAppend` loads entries newest-first; reverse to first-seen order so
129 // this getter agrees with both the user agent and `SdkConfig::framework_metadata`.
130 let mut entries: ::std::vec::Vec<&::aws_types::sdk_ua_metadata::FrameworkMetadata> =
131 self.config.load::<::aws_types::sdk_ua_metadata::FrameworkMetadata>().collect();
132 entries.reverse();
133 entries
134 }
135 /// Returns the invocation ID generator if one was given in config.
136 ///
137 /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
138 pub fn invocation_id_generator(&self) -> ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator> {
139 self.config.load::<::aws_runtime::invocation_id::SharedInvocationIdGenerator>().cloned()
140 }
141 /// Creates a new [service config](crate::Config) from a [shared `config`](::aws_types::sdk_config::SdkConfig).
142 pub fn new(config: &::aws_types::sdk_config::SdkConfig) -> Self {
143 Builder::from(config).build()
144 }
145 /// Return a reference to the response_checksum_validation value contained in this config, if any.
146 pub fn response_checksum_validation(&self) -> ::std::option::Option<&crate::config::ResponseChecksumValidation> {
147 self.config.load::<crate::config::ResponseChecksumValidation>()
148 }
149 /// Return a reference to the request_checksum_calculation value contained in this config, if any.
150 pub fn request_checksum_calculation(&self) -> ::std::option::Option<&crate::config::RequestChecksumCalculation> {
151 self.config.load::<crate::config::RequestChecksumCalculation>()
152 }
153 /// The signature version 4 service signing name to use in the credential scope when signing requests.
154 ///
155 /// The signing service may be overridden by the `Endpoint`, or by specifying a custom
156 /// [`SigningName`](aws_types::SigningName) during operation construction
157 pub fn signing_name(&self) -> &'static str {
158 "s3"
159 }
160 /// Returns the SigV4a signing region set, if configured.
161 pub fn sigv4a_signing_region_set(&self) -> Option<&::aws_types::region::SigningRegionSet> {
162 self.config.load::<::aws_types::region::SigningRegionSet>()
163 }
164 /// Returns the AWS region, if it was provided.
165 pub fn region(&self) -> ::std::option::Option<&crate::config::Region> {
166 self.config.load::<crate::config::Region>()
167 }
168 /// This function was intended to be removed, and has been broken since release-2023-11-15 as it always returns a `None`. Do not use.
169 #[deprecated(
170 note = "This function was intended to be removed, and has been broken since release-2023-11-15 as it always returns a `None`. Do not use."
171 )]
172 pub fn credentials_provider(&self) -> Option<crate::config::SharedCredentialsProvider> {
173 ::std::option::Option::None
174 }
175}
176/// Builder for creating a `Config`.
177#[derive(::std::clone::Clone, ::std::fmt::Debug)]
178pub struct Builder {
179 pub(crate) config: ::aws_smithy_types::config_bag::CloneableLayer,
180 pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
181 pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
182 pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
183}
184impl ::std::default::Default for Builder {
185 fn default() -> Self {
186 Self {
187 config: ::std::default::Default::default(),
188 runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
189 runtime_plugins: ::std::default::Default::default(),
190 behavior_version: ::std::default::Default::default(),
191 }
192 }
193}
194impl Builder {
195 ///
196 /// Constructs a config builder.
197 /// <div class="warning">
198 /// Note that a config created from this builder will not have the same safe defaults as one created by
199 /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
200 /// </div>
201 ///
202 pub fn new() -> Self {
203 Self::default()
204 }
205 /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
206 /// but not those in runtime components.
207 #[allow(unused)]
208 pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
209 let mut builder = Self::new();
210 builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
211 builder.set_auth_scheme_preference(config_bag.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>().cloned());
212 builder.set_force_path_style(config_bag.load::<crate::config::ForcePathStyle>().map(|ty| ty.0));
213
214 builder.set_use_arn_region(config_bag.load::<crate::config::UseArnRegion>().map(|ty| ty.0));
215
216 builder.set_disable_multi_region_access_points(config_bag.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0));
217
218 builder.set_accelerate(config_bag.load::<crate::config::Accelerate>().map(|ty| ty.0));
219
220 builder.set_disable_s3_express_session_auth(config_bag.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0));
221 builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
222 builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
223 builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
224 builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
225 for framework_metadata in config_bag.load::<::aws_types::sdk_ua_metadata::FrameworkMetadata>() {
226 builder.push_framework_metadata(framework_metadata.clone());
227 }
228 builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
229 builder.set_use_dual_stack(config_bag.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0));
230 builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
231 builder.set_response_checksum_validation(config_bag.load::<crate::config::ResponseChecksumValidation>().cloned());
232 builder.set_request_checksum_calculation(config_bag.load::<crate::config::RequestChecksumCalculation>().cloned());
233 builder.set_sigv4a_signing_region_set(config_bag.load::<::aws_types::region::SigningRegionSet>().cloned());
234 builder.set_region(config_bag.load::<crate::config::Region>().cloned());
235 builder
236 }
237 /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
238 /// to configure protection for stalled streams.
239 pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
240 self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
241 self
242 }
243 /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
244 /// to configure protection for stalled streams.
245 pub fn set_stalled_stream_protection(
246 &mut self,
247 stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
248 ) -> &mut Self {
249 self.config.store_or_unset(stalled_stream_protection_config);
250 self
251 }
252 /// Sets the idempotency token provider to use for service calls that require tokens.
253 pub fn idempotency_token_provider(
254 mut self,
255 idempotency_token_provider: impl ::std::convert::Into<crate::idempotency_token::IdempotencyTokenProvider>,
256 ) -> Self {
257 self.set_idempotency_token_provider(::std::option::Option::Some(idempotency_token_provider.into()));
258 self
259 }
260 /// Sets the idempotency token provider to use for service calls that require tokens.
261 pub fn set_idempotency_token_provider(
262 &mut self,
263 idempotency_token_provider: ::std::option::Option<crate::idempotency_token::IdempotencyTokenProvider>,
264 ) -> &mut Self {
265 self.config.store_or_unset(idempotency_token_provider);
266 self
267 }
268 /// Sets the HTTP client to use when making requests.
269 ///
270 /// # Examples
271 /// ```no_run
272 /// # #[cfg(test)]
273 /// # mod tests {
274 /// # #[test]
275 /// # fn example() {
276 /// use std::time::Duration;
277 /// use aws_sdk_s3::config::Config;
278 /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
279 ///
280 /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
281 /// .with_webpki_roots()
282 /// .https_only()
283 /// .enable_http1()
284 /// .enable_http2()
285 /// .build();
286 /// let hyper_client = HyperClientBuilder::new().build(https_connector);
287 ///
288 /// // This connector can then be given to a generated service Config
289 /// let config = my_service_client::Config::builder()
290 /// .endpoint_url("https://example.com")
291 /// .http_client(hyper_client)
292 /// .build();
293 /// let client = my_service_client::Client::from_conf(config);
294 /// # }
295 /// # }
296 /// ```
297 pub fn http_client(mut self, http_client: impl crate::config::HttpClient + 'static) -> Self {
298 self.set_http_client(::std::option::Option::Some(crate::config::IntoShared::into_shared(http_client)));
299 self
300 }
301
302 /// Sets the HTTP client to use when making requests.
303 ///
304 /// # Examples
305 /// ```no_run
306 /// # #[cfg(test)]
307 /// # mod tests {
308 /// # #[test]
309 /// # fn example() {
310 /// use std::time::Duration;
311 /// use aws_sdk_s3::config::{Builder, Config};
312 /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
313 ///
314 /// fn override_http_client(builder: &mut Builder) {
315 /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
316 /// .with_webpki_roots()
317 /// .https_only()
318 /// .enable_http1()
319 /// .enable_http2()
320 /// .build();
321 /// let hyper_client = HyperClientBuilder::new().build(https_connector);
322 /// builder.set_http_client(Some(hyper_client));
323 /// }
324 ///
325 /// let mut builder = aws_sdk_s3::Config::builder();
326 /// override_http_client(&mut builder);
327 /// let config = builder.build();
328 /// # }
329 /// # }
330 /// ```
331 pub fn set_http_client(&mut self, http_client: Option<crate::config::SharedHttpClient>) -> &mut Self {
332 self.runtime_components.set_http_client(http_client);
333 self
334 }
335 /// Adds an auth scheme to the builder
336 ///
337 /// If `auth_scheme` has an existing [AuthSchemeId](aws_smithy_runtime_api::client::auth::AuthSchemeId) in the runtime, the current identity
338 /// resolver and signer for that scheme will be replaced by those from `auth_scheme`.
339 ///
340 /// _Important:_ When introducing a custom auth scheme, ensure you override either
341 /// [`Self::auth_scheme_resolver`] or [`Self::set_auth_scheme_resolver`]
342 /// so that the custom auth scheme is included in the list of resolved auth scheme options.
343 /// [The default auth scheme resolver](crate::config::auth::DefaultAuthSchemeResolver) will not recognize your custom auth scheme.
344 ///
345 /// # Examples
346 /// ```no_run
347 /// # use aws_smithy_runtime_api::{
348 /// # box_error::BoxError,
349 /// # client::{
350 /// # auth::{
351 /// # AuthScheme, AuthSchemeEndpointConfig, AuthSchemeId, AuthSchemeOption,
352 /// # AuthSchemeOptionsFuture, Sign,
353 /// # },
354 /// # identity::{Identity, IdentityFuture, ResolveIdentity, SharedIdentityResolver},
355 /// # orchestrator::HttpRequest,
356 /// # runtime_components::{GetIdentityResolver, RuntimeComponents},
357 /// # },
358 /// # shared::IntoShared,
359 /// # };
360 /// # use aws_smithy_types::config_bag::ConfigBag;
361 /// // Auth scheme with customer identity resolver and signer
362 /// #[derive(Debug)]
363 /// struct CustomAuthScheme {
364 /// id: AuthSchemeId,
365 /// identity_resolver: SharedIdentityResolver,
366 /// signer: CustomSigner,
367 /// }
368 /// impl Default for CustomAuthScheme {
369 /// fn default() -> Self {
370 /// Self {
371 /// id: AuthSchemeId::new("custom"),
372 /// identity_resolver: CustomIdentityResolver.into_shared(),
373 /// signer: CustomSigner,
374 /// }
375 /// }
376 /// }
377 /// impl AuthScheme for CustomAuthScheme {
378 /// fn scheme_id(&self) -> AuthSchemeId {
379 /// self.id.clone()
380 /// }
381 /// fn identity_resolver(
382 /// &self,
383 /// _identity_resolvers: &dyn GetIdentityResolver,
384 /// ) -> Option<SharedIdentityResolver> {
385 /// Some(self.identity_resolver.clone())
386 /// }
387 /// fn signer(&self) -> &dyn Sign {
388 /// &self.signer
389 /// }
390 /// }
391 ///
392 /// #[derive(Debug, Default)]
393 /// struct CustomSigner;
394 /// impl Sign for CustomSigner {
395 /// fn sign_http_request(
396 /// &self,
397 /// _request: &mut HttpRequest,
398 /// _identity: &Identity,
399 /// _auth_scheme_endpoint_config: AuthSchemeEndpointConfig<'_>,
400 /// _runtime_components: &RuntimeComponents,
401 /// _config_bag: &ConfigBag,
402 /// ) -> Result<(), BoxError> {
403 /// // --snip--
404 /// # todo!()
405 /// }
406 /// }
407 ///
408 /// #[derive(Debug)]
409 /// struct CustomIdentityResolver;
410 /// impl ResolveIdentity for CustomIdentityResolver {
411 /// fn resolve_identity<'a>(
412 /// &'a self,
413 /// _runtime_components: &'a RuntimeComponents,
414 /// _config_bag: &'a ConfigBag,
415 /// ) -> IdentityFuture<'a> {
416 /// // --snip--
417 /// # todo!()
418 /// }
419 /// }
420 ///
421 /// // Auth scheme resolver that favors `CustomAuthScheme`
422 /// #[derive(Debug)]
423 /// struct CustomAuthSchemeResolver;
424 /// impl aws_sdk_s3::config::auth::ResolveAuthScheme for CustomAuthSchemeResolver {
425 /// fn resolve_auth_scheme<'a>(
426 /// &'a self,
427 /// _params: &'a aws_sdk_s3::config::auth::Params,
428 /// _cfg: &'a ConfigBag,
429 /// _runtime_components: &'a RuntimeComponents,
430 /// ) -> AuthSchemeOptionsFuture<'a> {
431 /// AuthSchemeOptionsFuture::ready(Ok(vec![AuthSchemeOption::from(AuthSchemeId::new(
432 /// "custom",
433 /// ))]))
434 /// }
435 /// }
436 ///
437 /// let config = aws_sdk_s3::Config::builder()
438 /// .push_auth_scheme(CustomAuthScheme::default())
439 /// .auth_scheme_resolver(CustomAuthSchemeResolver)
440 /// // other configurations
441 /// .build();
442 /// ```
443 pub fn push_auth_scheme(mut self, auth_scheme: impl ::aws_smithy_runtime_api::client::auth::AuthScheme + 'static) -> Self {
444 self.runtime_components.push_auth_scheme(auth_scheme);
445 self
446 }
447
448 /// Set the auth scheme resolver for the builder
449 ///
450 /// # Examples
451 /// ```no_run
452 /// # use aws_smithy_runtime_api::{
453 /// # client::{
454 /// # auth::AuthSchemeOptionsFuture,
455 /// # runtime_components::RuntimeComponents,
456 /// # },
457 /// # };
458 /// # use aws_smithy_types::config_bag::ConfigBag;
459 /// #[derive(Debug)]
460 /// struct CustomAuthSchemeResolver;
461 /// impl aws_sdk_s3::config::auth::ResolveAuthScheme for CustomAuthSchemeResolver {
462 /// fn resolve_auth_scheme<'a>(
463 /// &'a self,
464 /// _params: &'a aws_sdk_s3::config::auth::Params,
465 /// _cfg: &'a ConfigBag,
466 /// _runtime_components: &'a RuntimeComponents,
467 /// ) -> AuthSchemeOptionsFuture<'a> {
468 /// // --snip--
469 /// # todo!()
470 /// }
471 /// }
472 ///
473 /// let config = aws_sdk_s3::Config::builder()
474 /// .auth_scheme_resolver(CustomAuthSchemeResolver)
475 /// // other configurations
476 /// .build();
477 /// ```
478 pub fn auth_scheme_resolver(mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> Self {
479 self.set_auth_scheme_resolver(auth_scheme_resolver);
480 self
481 }
482
483 /// Set the auth scheme resolver for the builder
484 ///
485 /// # Examples
486 /// See an example for [`Self::auth_scheme_resolver`].
487 pub fn set_auth_scheme_resolver(&mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> &mut Self {
488 self.runtime_components
489 .set_auth_scheme_option_resolver(::std::option::Option::Some(auth_scheme_resolver.into_shared_resolver()));
490 self
491 }
492
493 /// Enable no authentication regardless of what authentication mechanisms operations support
494 ///
495 /// This adds [NoAuthScheme](aws_smithy_runtime::client::auth::no_auth::NoAuthScheme) as a fallback
496 /// and the auth scheme resolver will use it when no other auth schemes are applicable.
497 pub fn allow_no_auth(mut self) -> Self {
498 self.set_allow_no_auth();
499 self
500 }
501
502 /// Enable no authentication regardless of what authentication mechanisms operations support
503 ///
504 /// This adds [NoAuthScheme](aws_smithy_runtime::client::auth::no_auth::NoAuthScheme) as a fallback
505 /// and the auth scheme resolver will use it when no other auth schemes are applicable.
506 pub fn set_allow_no_auth(&mut self) -> &mut Self {
507 self.push_runtime_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePluginV2::new().into_shared());
508 self
509 }
510 /// Set the auth scheme preference for an auth scheme resolver
511 /// (typically the default auth scheme resolver).
512 ///
513 /// Each operation has a predefined order of auth schemes, as determined by the service,
514 /// for auth scheme resolution. By using the auth scheme preference, customers
515 /// can reorder the schemes resolved by the auth scheme resolver.
516 ///
517 /// The preference list is intended as a hint rather than a strict override.
518 /// Any schemes not present in the originally resolved auth schemes will be ignored.
519 ///
520 /// # Examples
521 ///
522 /// ```no_run
523 /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
524 /// let config = aws_sdk_s3::Config::builder()
525 /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
526 /// // ...
527 /// .build();
528 /// let client = aws_sdk_s3::Client::from_conf(config);
529 /// ```
530
531 pub fn auth_scheme_preference(
532 mut self,
533 preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
534 ) -> Self {
535 self.set_auth_scheme_preference(::std::option::Option::Some(preference.into()));
536 self
537 }
538
539 /// Set the auth scheme preference for an auth scheme resolver
540 /// (typically the default auth scheme resolver).
541 ///
542 /// Each operation has a predefined order of auth schemes, as determined by the service,
543 /// for auth scheme resolution. By using the auth scheme preference, customers
544 /// can reorder the schemes resolved by the auth scheme resolver.
545 ///
546 /// The preference list is intended as a hint rather than a strict override.
547 /// Any schemes not present in the originally resolved auth schemes will be ignored.
548 ///
549 /// # Examples
550 ///
551 /// ```no_run
552 /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
553 /// let config = aws_sdk_s3::Config::builder()
554 /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
555 /// // ...
556 /// .build();
557 /// let client = aws_sdk_s3::Client::from_conf(config);
558 /// ```
559
560 pub fn set_auth_scheme_preference(
561 &mut self,
562 preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
563 ) -> &mut Self {
564 self.config.store_or_unset(preference);
565 self
566 }
567 /// Forces this client to use path-style addressing for buckets.
568 pub fn force_path_style(mut self, force_path_style: impl Into<bool>) -> Self {
569 self.set_force_path_style(Some(force_path_style.into()));
570 self
571 }
572 /// Forces this client to use path-style addressing for buckets.
573 pub fn set_force_path_style(&mut self, force_path_style: Option<bool>) -> &mut Self {
574 self.config.store_or_unset(force_path_style.map(crate::config::ForcePathStyle));
575 self
576 }
577
578 /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
579 pub fn use_arn_region(mut self, use_arn_region: impl Into<bool>) -> Self {
580 self.set_use_arn_region(Some(use_arn_region.into()));
581 self
582 }
583 /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
584 pub fn set_use_arn_region(&mut self, use_arn_region: Option<bool>) -> &mut Self {
585 self.config.store_or_unset(use_arn_region.map(crate::config::UseArnRegion));
586 self
587 }
588
589 /// Disables this client's usage of Multi-Region Access Points.
590 pub fn disable_multi_region_access_points(mut self, disable_multi_region_access_points: impl Into<bool>) -> Self {
591 self.set_disable_multi_region_access_points(Some(disable_multi_region_access_points.into()));
592 self
593 }
594 /// Disables this client's usage of Multi-Region Access Points.
595 pub fn set_disable_multi_region_access_points(&mut self, disable_multi_region_access_points: Option<bool>) -> &mut Self {
596 self.config
597 .store_or_unset(disable_multi_region_access_points.map(crate::config::DisableMultiRegionAccessPoints));
598 self
599 }
600
601 /// Enables this client to use S3 Transfer Acceleration endpoints.
602 pub fn accelerate(mut self, accelerate: impl Into<bool>) -> Self {
603 self.set_accelerate(Some(accelerate.into()));
604 self
605 }
606 /// Enables this client to use S3 Transfer Acceleration endpoints.
607 pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Self {
608 self.config.store_or_unset(accelerate.map(crate::config::Accelerate));
609 self
610 }
611
612 /// Disables this client's usage of Session Auth for S3Express buckets and reverts to using conventional SigV4 for those.
613 pub fn disable_s3_express_session_auth(mut self, disable_s3_express_session_auth: impl Into<bool>) -> Self {
614 self.set_disable_s3_express_session_auth(Some(disable_s3_express_session_auth.into()));
615 self
616 }
617 /// Disables this client's usage of Session Auth for S3Express buckets and reverts to using conventional SigV4 for those.
618 pub fn set_disable_s3_express_session_auth(&mut self, disable_s3_express_session_auth: Option<bool>) -> &mut Self {
619 self.config
620 .store_or_unset(disable_s3_express_session_auth.map(crate::config::DisableS3ExpressSessionAuth));
621 self
622 }
623 /// Sets the endpoint resolver to use when making requests.
624 ///
625 ///
626 /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
627 /// rules for `aws_sdk_s3`.
628 ///
629 ///
630 /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
631 /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
632 /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
633 ///
634 /// # Examples
635 /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
636 /// ```no_run
637 /// use aws_sdk_s3::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
638 /// #[derive(Debug)]
639 /// struct StageResolver { stage: String }
640 /// impl ResolveEndpoint for StageResolver {
641 /// fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
642 /// let stage = &self.stage;
643 /// EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
644 /// }
645 /// }
646 /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
647 /// let config = aws_sdk_s3::Config::builder().endpoint_resolver(resolver).build();
648 /// let client = aws_sdk_s3::Client::from_conf(config);
649 /// ```
650 pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
651 self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
652 self
653 }
654
655 /// Sets the endpoint resolver to use when making requests.
656 ///
657 ///
658 /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
659 /// rules for `aws_sdk_s3`.
660 ///
661 pub fn set_endpoint_resolver(
662 &mut self,
663 endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
664 ) -> &mut Self {
665 self.runtime_components.set_endpoint_resolver(endpoint_resolver);
666 self
667 }
668 /// Set the retry_config for the builder
669 ///
670 /// # Examples
671 /// ```no_run
672 /// use aws_sdk_s3::config::Config;
673 /// use aws_sdk_s3::config::retry::RetryConfig;
674 ///
675 /// let retry_config = RetryConfig::standard().with_max_attempts(5);
676 /// let config = Config::builder().retry_config(retry_config).build();
677 /// ```
678 pub fn retry_config(mut self, retry_config: ::aws_smithy_types::retry::RetryConfig) -> Self {
679 self.set_retry_config(Some(retry_config));
680 self
681 }
682
683 /// Set the retry_config for the builder
684 ///
685 /// # Examples
686 /// ```no_run
687 /// use aws_sdk_s3::config::{Builder, Config};
688 /// use aws_sdk_s3::config::retry::RetryConfig;
689 ///
690 /// fn disable_retries(builder: &mut Builder) {
691 /// let retry_config = RetryConfig::standard().with_max_attempts(1);
692 /// builder.set_retry_config(Some(retry_config));
693 /// }
694 ///
695 /// let mut builder = Config::builder();
696 /// disable_retries(&mut builder);
697 /// let config = builder.build();
698 /// ```
699 pub fn set_retry_config(&mut self, retry_config: ::std::option::Option<::aws_smithy_types::retry::RetryConfig>) -> &mut Self {
700 retry_config.map(|r| self.config.store_put(r));
701 self
702 }
703 /// Set the sleep_impl for the builder
704 ///
705 /// # Examples
706 ///
707 /// ```no_run
708 /// use aws_sdk_s3::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
709 ///
710 /// #[derive(Debug)]
711 /// pub struct ForeverSleep;
712 ///
713 /// impl AsyncSleep for ForeverSleep {
714 /// fn sleep(&self, duration: std::time::Duration) -> Sleep {
715 /// Sleep::new(std::future::pending())
716 /// }
717 /// }
718 ///
719 /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
720 /// let config = Config::builder().sleep_impl(sleep_impl).build();
721 /// ```
722 pub fn sleep_impl(mut self, sleep_impl: impl crate::config::AsyncSleep + 'static) -> Self {
723 self.set_sleep_impl(Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(sleep_impl)));
724 self
725 }
726
727 /// Set the sleep_impl for the builder
728 ///
729 /// # Examples
730 ///
731 /// ```no_run
732 /// use aws_sdk_s3::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
733 ///
734 /// #[derive(Debug)]
735 /// pub struct ForeverSleep;
736 ///
737 /// impl AsyncSleep for ForeverSleep {
738 /// fn sleep(&self, duration: std::time::Duration) -> Sleep {
739 /// Sleep::new(std::future::pending())
740 /// }
741 /// }
742 ///
743 /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
744 /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
745 /// builder.set_sleep_impl(Some(sleep_impl));
746 /// }
747 ///
748 /// let mut builder = Config::builder();
749 /// set_never_ending_sleep_impl(&mut builder);
750 /// let config = builder.build();
751 /// ```
752 pub fn set_sleep_impl(&mut self, sleep_impl: ::std::option::Option<crate::config::SharedAsyncSleep>) -> &mut Self {
753 self.runtime_components.set_sleep_impl(sleep_impl);
754 self
755 }
756 /// Set the timeout_config for the builder
757 ///
758 /// # Examples
759 ///
760 /// ```no_run
761 /// # use std::time::Duration;
762 /// use aws_sdk_s3::config::Config;
763 /// use aws_sdk_s3::config::timeout::TimeoutConfig;
764 ///
765 /// let timeout_config = TimeoutConfig::builder()
766 /// .operation_attempt_timeout(Duration::from_secs(1))
767 /// .build();
768 /// let config = Config::builder().timeout_config(timeout_config).build();
769 /// ```
770 pub fn timeout_config(mut self, timeout_config: ::aws_smithy_types::timeout::TimeoutConfig) -> Self {
771 self.set_timeout_config(Some(timeout_config));
772 self
773 }
774
775 /// Set the timeout_config for the builder.
776 ///
777 /// Setting this to `None` has no effect if another source of configuration has set timeouts. If you
778 /// are attempting to disable timeouts, use [`TimeoutConfig::disabled`](::aws_smithy_types::timeout::TimeoutConfig::disabled)
779 ///
780 ///
781 /// # Examples
782 ///
783 /// ```no_run
784 /// # use std::time::Duration;
785 /// use aws_sdk_s3::config::{Builder, Config};
786 /// use aws_sdk_s3::config::timeout::TimeoutConfig;
787 ///
788 /// fn set_request_timeout(builder: &mut Builder) {
789 /// let timeout_config = TimeoutConfig::builder()
790 /// .operation_attempt_timeout(Duration::from_secs(1))
791 /// .build();
792 /// builder.set_timeout_config(Some(timeout_config));
793 /// }
794 ///
795 /// let mut builder = Config::builder();
796 /// set_request_timeout(&mut builder);
797 /// let config = builder.build();
798 /// ```
799 pub fn set_timeout_config(&mut self, timeout_config: ::std::option::Option<::aws_smithy_types::timeout::TimeoutConfig>) -> &mut Self {
800 // passing None has no impact.
801 let Some(mut timeout_config) = timeout_config else { return self };
802
803 if let Some(base) = self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>() {
804 timeout_config.take_defaults_from(base);
805 }
806 self.config.store_put(timeout_config);
807 self
808 }
809 /// Set the partition for retry-related state. When clients share a retry partition, they will
810 /// also share components such as token buckets and client rate limiters.
811 /// See the [`RetryPartition`](::aws_smithy_runtime::client::retries::RetryPartition) documentation for more details.
812 ///
813 /// # Default Behavior
814 ///
815 /// When no retry partition is explicitly set, the SDK automatically creates a default retry partition named `s3`
816 /// (or `s3-<region>` if a region is configured).
817 /// All S3 clients without an explicit retry partition will share this default partition.
818 ///
819 /// # Notes
820 ///
821 /// - This is an advanced setting — most users won't need to modify it.
822 /// - A configured client rate limiter has no effect unless [`RetryConfig::adaptive`](::aws_smithy_types::retry::RetryConfig::adaptive) is used.
823 ///
824 /// # Examples
825 ///
826 /// Creating a custom retry partition with a token bucket:
827 /// ```no_run
828 /// use aws_sdk_s3::config::Config;
829 /// use aws_sdk_s3::config::retry::{RetryPartition, TokenBucket};
830 ///
831 /// let token_bucket = TokenBucket::new(10);
832 /// let config = Config::builder()
833 /// .retry_partition(RetryPartition::custom("custom")
834 /// .token_bucket(token_bucket)
835 /// .build()
836 /// )
837 /// .build();
838 /// ```
839 ///
840 /// Configuring a client rate limiter with adaptive retry mode:
841 /// ```no_run
842 /// use aws_sdk_s3::config::Config;
843 /// use aws_sdk_s3::config::retry::{ClientRateLimiter, RetryConfig, RetryPartition};
844 ///
845 /// let client_rate_limiter = ClientRateLimiter::new(10.0);
846 /// let config = Config::builder()
847 /// .retry_partition(RetryPartition::custom("custom")
848 /// .client_rate_limiter(client_rate_limiter)
849 /// .build()
850 /// )
851 /// .retry_config(RetryConfig::adaptive())
852 /// .build();
853 /// ```
854 pub fn retry_partition(mut self, retry_partition: ::aws_smithy_runtime::client::retries::RetryPartition) -> Self {
855 self.set_retry_partition(Some(retry_partition));
856 self
857 }
858 /// Like [`Self::retry_partition`], but takes a mutable reference to the builder and an optional `RetryPartition`
859 pub fn set_retry_partition(
860 &mut self,
861 retry_partition: ::std::option::Option<::aws_smithy_runtime::client::retries::RetryPartition>,
862 ) -> &mut Self {
863 retry_partition.map(|r| self.config.store_put(r));
864 self
865 }
866 /// Set the identity cache for auth.
867 ///
868 /// The identity cache defaults to a lazy caching implementation that will resolve
869 /// an identity when it is requested, and place it in the cache thereafter. Subsequent
870 /// requests will take the value from the cache while it is still valid. Once it expires,
871 /// the next request will result in refreshing the identity.
872 ///
873 /// This configuration allows you to disable or change the default caching mechanism.
874 /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
875 /// trait and pass that implementation into this function.
876 ///
877 /// # Examples
878 ///
879 /// Disabling identity caching:
880 /// ```no_run
881 /// use aws_sdk_s3::config::IdentityCache;
882 ///
883 /// let config = aws_sdk_s3::Config::builder()
884 /// .identity_cache(IdentityCache::no_cache())
885 /// // ...
886 /// .build();
887 /// let client = aws_sdk_s3::Client::from_conf(config);
888 /// ```
889 ///
890 /// Customizing lazy caching:
891 /// ```no_run
892 /// use aws_sdk_s3::config::IdentityCache;
893 /// use std::time::Duration;
894 ///
895 /// let config = aws_sdk_s3::Config::builder()
896 /// .identity_cache(
897 /// IdentityCache::lazy()
898 /// // change the load timeout to 10 seconds
899 /// .load_timeout(Duration::from_secs(10))
900 /// .build()
901 /// )
902 /// // ...
903 /// .build();
904 /// let client = aws_sdk_s3::Client::from_conf(config);
905 /// ```
906 ///
907 pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
908 self.set_identity_cache(identity_cache);
909 self
910 }
911
912 /// Set the identity cache for auth.
913 ///
914 /// The identity cache defaults to a lazy caching implementation that will resolve
915 /// an identity when it is requested, and place it in the cache thereafter. Subsequent
916 /// requests will take the value from the cache while it is still valid. Once it expires,
917 /// the next request will result in refreshing the identity.
918 ///
919 /// This configuration allows you to disable or change the default caching mechanism.
920 /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
921 /// trait and pass that implementation into this function.
922 ///
923 /// # Examples
924 ///
925 /// Disabling identity caching:
926 /// ```no_run
927 /// use aws_sdk_s3::config::IdentityCache;
928 ///
929 /// let config = aws_sdk_s3::Config::builder()
930 /// .identity_cache(IdentityCache::no_cache())
931 /// // ...
932 /// .build();
933 /// let client = aws_sdk_s3::Client::from_conf(config);
934 /// ```
935 ///
936 /// Customizing lazy caching:
937 /// ```no_run
938 /// use aws_sdk_s3::config::IdentityCache;
939 /// use std::time::Duration;
940 ///
941 /// let config = aws_sdk_s3::Config::builder()
942 /// .identity_cache(
943 /// IdentityCache::lazy()
944 /// // change the load timeout to 10 seconds
945 /// .load_timeout(Duration::from_secs(10))
946 /// .build()
947 /// )
948 /// // ...
949 /// .build();
950 /// let client = aws_sdk_s3::Client::from_conf(config);
951 /// ```
952 ///
953 pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
954 self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
955 self
956 }
957 /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
958 ///
959 /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
960 /// The SDK provides a default set of interceptors. An interceptor configured by this method
961 /// will run after those default interceptors.
962 ///
963 /// # Examples
964 /// ```no_run
965 /// # fn example() {
966 /// use aws_smithy_runtime_api::box_error::BoxError;
967 /// use aws_smithy_runtime_api::client::interceptors::context::BeforeTransmitInterceptorContextMut;
968 /// use aws_smithy_runtime_api::client::interceptors::Intercept;
969 /// use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
970 /// use aws_smithy_types::config_bag::ConfigBag;
971 /// use aws_sdk_s3::config::Config;
972 /// use ::http::uri::Uri;
973 ///
974 /// fn base_url() -> String {
975 /// // ...
976 /// # String::new()
977 /// }
978 ///
979 /// #[derive(Debug)]
980 /// pub struct UriModifierInterceptor;
981 /// impl Intercept for UriModifierInterceptor {
982 /// fn name(&self) -> &'static str {
983 /// "UriModifierInterceptor"
984 /// }
985 /// fn modify_before_signing(
986 /// &self,
987 /// context: &mut BeforeTransmitInterceptorContextMut<'_>,
988 /// _runtime_components: &RuntimeComponents,
989 /// _cfg: &mut ConfigBag,
990 /// ) -> Result<(), BoxError> {
991 /// let request = context.request_mut();
992 /// let uri = format!("{}{}", base_url(), request.uri());
993 /// *request.uri_mut() = uri.parse::<Uri>()?.into();
994 ///
995 /// Ok(())
996 /// }
997 /// }
998 ///
999 /// let config = Config::builder()
1000 /// .interceptor(UriModifierInterceptor)
1001 /// .build();
1002 /// # }
1003 /// ```
1004 pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
1005 self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
1006 self
1007 }
1008
1009 /// Like [`Self::interceptor`], but takes a [`SharedInterceptor`](crate::config::SharedInterceptor).
1010 pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
1011 self.runtime_components.push_interceptor(interceptor);
1012 self
1013 }
1014
1015 /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
1016 pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
1017 self.runtime_components.set_interceptors(interceptors.into_iter());
1018 self
1019 }
1020 /// Sets the time source used for this service
1021 pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
1022 self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
1023 time_source,
1024 )));
1025 self
1026 }
1027 /// Sets the time source used for this service
1028 pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
1029 self.runtime_components.set_time_source(time_source);
1030 self
1031 }
1032 /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
1033 /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
1034 ///
1035 /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
1036 ///
1037 /// # Examples
1038 /// ```no_run
1039 /// # fn example() {
1040 /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
1041 /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
1042 /// use aws_smithy_runtime_api::client::retries::classifiers::{
1043 /// ClassifyRetry, RetryAction, RetryClassifierPriority,
1044 /// };
1045 /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
1046 /// use aws_smithy_types::retry::ErrorKind;
1047 /// use std::error::Error as StdError;
1048 /// use std::marker::PhantomData;
1049 /// use std::fmt;
1050 /// use aws_sdk_s3::config::Config;
1051 /// # #[derive(Debug)]
1052 /// # struct SomeOperationError {}
1053 /// # impl StdError for SomeOperationError {}
1054 /// # impl fmt::Display for SomeOperationError {
1055 /// # fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { todo!() }
1056 /// # }
1057 /// # impl ProvideErrorMetadata for SomeOperationError {
1058 /// # fn meta(&self) -> &aws_sdk_s3::error::ErrorMetadata { todo!() }
1059 /// # }
1060 ///
1061 /// const RETRYABLE_ERROR_CODES: &[&str] = &[
1062 /// // List error codes to be retried here...
1063 /// ];
1064 ///
1065 /// // When classifying at an operation's error type, classifiers require a generic parameter.
1066 /// // When classifying the HTTP response alone, no generic is needed.
1067 /// #[derive(Debug, Default)]
1068 /// pub struct ExampleErrorCodeClassifier<E> {
1069 /// _inner: PhantomData<E>,
1070 /// }
1071 ///
1072 /// impl<E> ExampleErrorCodeClassifier<E> {
1073 /// pub fn new() -> Self {
1074 /// Self {
1075 /// _inner: PhantomData,
1076 /// }
1077 /// }
1078 /// }
1079 ///
1080 /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
1081 /// where
1082 /// // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
1083 /// E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
1084 /// {
1085 /// fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
1086 /// // Check for a result
1087 /// let output_or_error = ctx.output_or_error();
1088 /// // Check for an error
1089 /// let error = match output_or_error {
1090 /// Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
1091 /// Some(Err(err)) => err,
1092 /// };
1093 ///
1094 /// // Downcast the generic error and extract the code
1095 /// let error_code = OrchestratorError::as_operation_error(error)
1096 /// .and_then(|err| err.downcast_ref::<E>())
1097 /// .and_then(|err| err.code());
1098 ///
1099 /// // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
1100 /// if let Some(error_code) = error_code {
1101 /// if RETRYABLE_ERROR_CODES.contains(&error_code) {
1102 /// return RetryAction::transient_error();
1103 /// }
1104 /// }
1105 ///
1106 /// // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
1107 /// // Another classifier may still classify this response as retryable.
1108 /// RetryAction::NoActionIndicated
1109 /// }
1110 ///
1111 /// fn name(&self) -> &'static str { "Example Error Code Classifier" }
1112 /// }
1113 ///
1114 /// let config = Config::builder()
1115 /// .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
1116 /// .build();
1117 /// # }
1118 /// ```
1119 pub fn retry_classifier(
1120 mut self,
1121 retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
1122 ) -> Self {
1123 self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
1124 retry_classifier,
1125 ));
1126 self
1127 }
1128
1129 /// Like [`Self::retry_classifier`], but takes a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier).
1130 pub fn push_retry_classifier(
1131 &mut self,
1132 retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
1133 ) -> &mut Self {
1134 self.runtime_components.push_retry_classifier(retry_classifier);
1135 self
1136 }
1137
1138 /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
1139 /// were previously set.
1140 pub fn set_retry_classifiers(
1141 &mut self,
1142 retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
1143 ) -> &mut Self {
1144 self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
1145 self
1146 }
1147 /// Sets the name of the app that is using the client.
1148 ///
1149 /// This _optional_ name is used to identify the application in the user agent that
1150 /// gets sent along with requests.
1151 pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
1152 self.set_app_name(Some(app_name));
1153 self
1154 }
1155 /// Sets the name of the app that is using the client.
1156 ///
1157 /// This _optional_ name is used to identify the application in the user agent that
1158 /// gets sent along with requests.
1159 pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
1160 self.config.store_or_unset(app_name);
1161 self
1162 }
1163 /// Appends framework metadata to the user agent.
1164 ///
1165 /// This _optional_ metadata identifies a software framework or third-party library
1166 /// that is being used with the client. It is rendered into the user agent string
1167 /// (as `lib/{name}/{version}`) so that libraries built on top of the AWS SDK can
1168 /// self-identify in the requests they make. Multiple entries may be added; each call
1169 /// appends another entry rather than replacing previous ones.
1170 ///
1171 /// Entries are de-duplicated on `(name, version)`, rendered in first-seen order, and
1172 /// the total number of unique entries included in the user agent is capped (currently
1173 /// at 10); additional entries beyond the cap are dropped with a warning.
1174 pub fn framework_metadata(mut self, framework_metadata: ::aws_types::sdk_ua_metadata::FrameworkMetadata) -> Self {
1175 self.push_framework_metadata(framework_metadata);
1176 self
1177 }
1178 /// Appends framework metadata to the user agent.
1179 ///
1180 /// This _optional_ metadata identifies a software framework or third-party library
1181 /// that is being used with the client. It is rendered into the user agent string
1182 /// (as `lib/{name}/{version}`) so that libraries built on top of the AWS SDK can
1183 /// self-identify in the requests they make. Multiple entries may be added; each call
1184 /// appends another entry rather than replacing previous ones.
1185 pub fn push_framework_metadata(&mut self, framework_metadata: ::aws_types::sdk_ua_metadata::FrameworkMetadata) -> &mut Self {
1186 self.config.store_append(framework_metadata);
1187 self
1188 }
1189 /// Sets the credentials provider for S3 Express One Zone
1190 pub fn express_credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1191 self.set_express_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1192 credentials_provider,
1193 )));
1194 self
1195 }
1196 /// Sets the credentials provider for S3 Express One Zone
1197 pub fn set_express_credentials_provider(
1198 &mut self,
1199 credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>,
1200 ) -> &mut Self {
1201 if let ::std::option::Option::Some(credentials_provider) = credentials_provider {
1202 self.runtime_components
1203 .set_identity_resolver(crate::s3_express::auth::SCHEME_ID, credentials_provider);
1204 }
1205 self
1206 }
1207 /// Overrides the default invocation ID generator.
1208 ///
1209 /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
1210 pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
1211 self.set_invocation_id_generator(::std::option::Option::Some(
1212 ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
1213 ));
1214 self
1215 }
1216 /// Overrides the default invocation ID generator.
1217 ///
1218 /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
1219 pub fn set_invocation_id_generator(
1220 &mut self,
1221 gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
1222 ) -> &mut Self {
1223 self.config.store_or_unset(gen);
1224 self
1225 }
1226 /// Sets the endpoint URL used to communicate with this service.
1227 ///
1228 /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1229 /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1230 /// [`Builder::endpoint_resolver`].
1231 pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
1232 self.set_endpoint_url(Some(endpoint_url.into()));
1233 self
1234 }
1235 /// Sets the endpoint URL used to communicate with this service.
1236 ///
1237 /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1238 /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1239 /// [`Builder::endpoint_resolver`].
1240 pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
1241 self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
1242 self
1243 }
1244 /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1245 pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
1246 self.set_use_dual_stack(Some(use_dual_stack.into()));
1247 self
1248 }
1249 /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1250 pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
1251 self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
1252 self
1253 }
1254 /// When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
1255 pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
1256 self.set_use_fips(Some(use_fips.into()));
1257 self
1258 }
1259 /// When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
1260 pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
1261 self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
1262 self
1263 }
1264 /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1265 /// to determine when checksum validation will be performed on response payloads.
1266 pub fn response_checksum_validation(mut self, response_checksum_validation: crate::config::ResponseChecksumValidation) -> Self {
1267 self.set_response_checksum_validation(::std::option::Option::Some(response_checksum_validation));
1268 self
1269 }
1270 /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1271 /// to determine when checksum validation will be performed on response payloads.
1272 pub fn set_response_checksum_validation(
1273 &mut self,
1274 response_checksum_validation: ::std::option::Option<crate::config::ResponseChecksumValidation>,
1275 ) -> &mut Self {
1276 self.config.store_or_unset(response_checksum_validation);
1277 self
1278 }
1279 /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1280 /// to determine when a checksum will be calculated for request payloads.
1281 pub fn request_checksum_calculation(mut self, request_checksum_calculation: crate::config::RequestChecksumCalculation) -> Self {
1282 self.set_request_checksum_calculation(::std::option::Option::Some(request_checksum_calculation));
1283 self
1284 }
1285 /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1286 /// to determine when a checksum will be calculated for request payloads.
1287 pub fn set_request_checksum_calculation(
1288 &mut self,
1289 request_checksum_calculation: ::std::option::Option<crate::config::RequestChecksumCalculation>,
1290 ) -> &mut Self {
1291 self.config.store_or_unset(request_checksum_calculation);
1292 self
1293 }
1294 /// Sets the SigV4a signing region set.
1295 pub fn sigv4a_signing_region_set(mut self, v: impl Into<::aws_types::region::SigningRegionSet>) -> Self {
1296 self.set_sigv4a_signing_region_set(Some(v.into()));
1297 self
1298 }
1299
1300 /// Sets the SigV4a signing region set.
1301 pub fn set_sigv4a_signing_region_set(&mut self, v: Option<::aws_types::region::SigningRegionSet>) -> &mut Self {
1302 self.config.store_or_unset(v);
1303 self
1304 }
1305 /// Sets the AWS region to use when making requests.
1306 ///
1307 /// # Examples
1308 /// ```no_run
1309 /// use aws_types::region::Region;
1310 /// use aws_sdk_s3::config::{Builder, Config};
1311 ///
1312 /// let config = aws_sdk_s3::Config::builder()
1313 /// .region(Region::new("us-east-1"))
1314 /// .build();
1315 /// ```
1316 pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1317 self.set_region(region.into());
1318 self
1319 }
1320 /// Sets the AWS region to use when making requests.
1321 pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1322 self.config.store_or_unset(region);
1323 self
1324 }
1325 /// Sets the credentials provider for this service
1326 pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1327 self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1328 credentials_provider,
1329 )));
1330 self
1331 }
1332 /// Sets the credentials provider for this service
1333 pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1334 if let Some(credentials_provider) = credentials_provider {
1335 #[cfg(feature = "sigv4a")]
1336 {
1337 self.runtime_components
1338 .set_identity_resolver(::aws_runtime::auth::sigv4a::SCHEME_ID, credentials_provider.clone());
1339 }
1340 self.runtime_components
1341 .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1342 }
1343 self
1344 }
1345 /// Sets the chunk size for [`aws-chunked encoding`].
1346 ///
1347 /// Pass `Some(size)` to use a specific chunk size (minimum 8 KiB).
1348 /// Pass `None` to use the content-length as chunk size (no chunking).
1349 ///
1350 /// The minimum chunk size of 8 KiB is validated when the request is sent.
1351 ///
1352 /// **Note:** This setting only applies to operations that support aws-chunked encoding
1353 /// and has no effect on other operations. If this method is not invoked, a default
1354 /// chunk size of 64 KiB is used.
1355 ///
1356 /// [`aws-chunked encoding`]: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
1357 ///
1358 /// # Example - Custom chunk size
1359 /// ```no_run
1360 /// # use aws_sdk_s3::{Client, Config};
1361 /// # async fn example(client: Client) -> Result<(), Box<dyn std::error::Error>> {
1362 /// let config = Config::builder()
1363 /// .aws_chunked_encoding_chunk_size(Some(10240)) // 10 KiB chunks
1364 /// .build();
1365 /// let client = Client::from_conf(config);
1366 /// # Ok(())
1367 /// # }
1368 /// ```
1369 ///
1370 /// # Example - No chunking (buffers entire body in memory)
1371 /// ```no_run
1372 /// # use aws_sdk_s3::{Client, Config};
1373 /// # async fn example(client: Client) -> Result<(), Box<dyn std::error::Error>> {
1374 /// let config = Config::builder()
1375 /// .aws_chunked_encoding_chunk_size(None) // Use entire content as one chunk
1376 /// .build();
1377 /// let client = Client::from_conf(config);
1378 /// # Ok(())
1379 /// # }
1380 /// ```
1381 pub fn aws_chunked_encoding_chunk_size(mut self, chunk_size: ::std::option::Option<usize>) -> Self {
1382 self.set_aws_chunked_encoding_chunk_size(::std::option::Option::Some(chunk_size));
1383 self
1384 }
1385
1386 /// Sets the chunk size for aws-chunked encoding.
1387 pub fn set_aws_chunked_encoding_chunk_size(&mut self, chunk_size: ::std::option::Option<::std::option::Option<usize>>) -> &mut Self {
1388 if let ::std::option::Option::Some(chunk_size) = chunk_size {
1389 let chunk_size = match chunk_size {
1390 ::std::option::Option::Some(size) => crate::aws_chunked::ChunkSize::Configured(size),
1391 ::std::option::Option::None => crate::aws_chunked::ChunkSize::DisableChunking,
1392 };
1393 self.push_runtime_plugin(crate::aws_chunked::ChunkSizeRuntimePlugin::new(chunk_size).into_shared());
1394 }
1395 self
1396 }
1397 /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1398 ///
1399 /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1400 /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1401 /// all operations might be the ideal behavior but could break existing applications.
1402 ///
1403 /// # Examples
1404 ///
1405 /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1406 /// ```no_run
1407 /// use aws_sdk_s3::config::BehaviorVersion;
1408 ///
1409 /// let config = aws_sdk_s3::Config::builder()
1410 /// .behavior_version(BehaviorVersion::latest())
1411 /// // ...
1412 /// .build();
1413 /// let client = aws_sdk_s3::Client::from_conf(config);
1414 /// ```
1415 ///
1416 /// Customizing behavior major version:
1417 /// ```no_run
1418 /// use aws_sdk_s3::config::BehaviorVersion;
1419 ///
1420 /// let config = aws_sdk_s3::Config::builder()
1421 /// .behavior_version(BehaviorVersion::v2023_11_09())
1422 /// // ...
1423 /// .build();
1424 /// let client = aws_sdk_s3::Client::from_conf(config);
1425 /// ```
1426 ///
1427 pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1428 self.set_behavior_version(Some(behavior_version));
1429 self
1430 }
1431
1432 /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1433 ///
1434 /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1435 /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1436 /// all operations might be the ideal behavior but could break existing applications.
1437 ///
1438 /// # Examples
1439 ///
1440 /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1441 /// ```no_run
1442 /// use aws_sdk_s3::config::BehaviorVersion;
1443 ///
1444 /// let config = aws_sdk_s3::Config::builder()
1445 /// .behavior_version(BehaviorVersion::latest())
1446 /// // ...
1447 /// .build();
1448 /// let client = aws_sdk_s3::Client::from_conf(config);
1449 /// ```
1450 ///
1451 /// Customizing behavior major version:
1452 /// ```no_run
1453 /// use aws_sdk_s3::config::BehaviorVersion;
1454 ///
1455 /// let config = aws_sdk_s3::Config::builder()
1456 /// .behavior_version(BehaviorVersion::v2023_11_09())
1457 /// // ...
1458 /// .build();
1459 /// let client = aws_sdk_s3::Client::from_conf(config);
1460 /// ```
1461 ///
1462 pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1463 self.behavior_version = behavior_version;
1464 self
1465 }
1466
1467 /// Convenience method to set the latest behavior major version
1468 ///
1469 /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1470 pub fn behavior_version_latest(mut self) -> Self {
1471 self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1472 self
1473 }
1474 /// Adds a runtime plugin to the config.
1475 #[allow(unused)]
1476 pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1477 self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1478 self
1479 }
1480 /// Adds a runtime plugin to the config.
1481 #[allow(unused)]
1482 pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1483 self.runtime_plugins.push(plugin);
1484 self
1485 }
1486 #[cfg(any(feature = "test-util", test))]
1487 #[allow(unused_mut)]
1488 /// Apply test defaults to the builder. NOTE: Consider migrating to use `apply_test_defaults_v2` instead.
1489 pub fn apply_test_defaults(&mut self) -> &mut Self {
1490 self.set_idempotency_token_provider(Some("00000000-0000-4000-8000-000000000000".into()));
1491
1492 self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1493 ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1494 )));
1495 self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1496 self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1497 ::aws_credential_types::Credentials::for_tests(),
1498 )));
1499 self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1500 self
1501 }
1502 #[cfg(any(feature = "test-util", test))]
1503 #[allow(unused_mut)]
1504 /// Apply test defaults to the builder. NOTE: Consider migrating to use `with_test_defaults_v2` instead.
1505 pub fn with_test_defaults(mut self) -> Self {
1506 self.apply_test_defaults();
1507 self
1508 }
1509 #[cfg(any(feature = "test-util", test))]
1510 #[allow(unused_mut)]
1511 /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1512 pub fn apply_test_defaults_v2(&mut self) -> &mut Self {
1513 self.apply_test_defaults();
1514
1515 if self.config.load::<crate::config::Region>().is_none() {
1516 self.set_region(::std::option::Option::Some(crate::config::Region::new("us-east-1")));
1517 }
1518 self
1519 }
1520 #[cfg(any(feature = "test-util", test))]
1521 #[allow(unused_mut)]
1522 /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1523 pub fn with_test_defaults_v2(mut self) -> Self {
1524 self.apply_test_defaults_v2();
1525 self
1526 }
1527 /// Builds a [`Config`].
1528 #[allow(unused_mut)]
1529 pub fn build(mut self) -> Config {
1530 let mut layer = self.config;
1531
1532 if self.runtime_components.time_source().is_none() {
1533 self.runtime_components
1534 .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1535 }
1536 layer.store_put(crate::meta::API_METADATA.clone());
1537 layer.store_put(::aws_types::SigningName::from_static("s3"));
1538 layer
1539 .load::<::aws_types::region::Region>()
1540 .cloned()
1541 .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1542 Config {
1543 config: crate::config::Layer::from(layer.clone()).with_name("aws_sdk_s3::config::Config").freeze(),
1544 cloneable: layer,
1545 runtime_components: self.runtime_components,
1546 runtime_plugins: self.runtime_plugins,
1547 behavior_version: self.behavior_version,
1548 }
1549 }
1550}
1551#[derive(::std::fmt::Debug)]
1552pub(crate) struct ServiceRuntimePlugin {
1553 config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1554 runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1555}
1556
1557impl ServiceRuntimePlugin {
1558 pub fn new(_service_config: crate::config::Config) -> Self {
1559 let config = {
1560 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AmazonS3");
1561 cfg.store_put(crate::idempotency_token::default_provider());
1562 cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
1563 ::std::option::Option::Some(cfg.freeze())
1564 };
1565 let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1566 runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
1567 use crate::config::auth::ResolveAuthScheme;
1568 crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
1569 }));
1570 runtime_components.set_endpoint_resolver(::std::option::Option::Some({
1571 use crate::config::endpoint::ResolveEndpoint;
1572 crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1573 }));
1574 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1575 ::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new(),
1576 ));
1577 runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1578 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1579 crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new(),
1580 ));
1581 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1582 ::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new(),
1583 ));
1584 runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1585 runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1586 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1587 crate::s3_express::auth::S3ExpressAuthScheme::new(),
1588 ));
1589 runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1590 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1591 ::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new(),
1592 ));
1593 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1594 ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1595 ));
1596 #[cfg(feature = "sigv4a")]
1597 {
1598 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1599 ::aws_runtime::auth::sigv4a::SigV4aAuthScheme::new(),
1600 ));
1601 }
1602 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1603 crate::config::endpoint::EndpointOverrideFeatureTrackerInterceptor,
1604 ));
1605 runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1606 crate::observability_feature::ObservabilityFeatureTrackerInterceptor,
1607 ));
1608 Self { config, runtime_components }
1609 }
1610}
1611
1612impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1613 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1614 self.config.clone()
1615 }
1616
1617 fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1618 ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1619 }
1620
1621 fn runtime_components(
1622 &self,
1623 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1624 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1625 ::std::borrow::Cow::Borrowed(&self.runtime_components)
1626 }
1627}
1628
1629// Cross-operation shared-state singletons
1630
1631/// A plugin that enables configuration for a single operation invocation
1632///
1633/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1634/// In the case of default values requested, they will be obtained from `client_config`.
1635#[derive(Debug)]
1636pub(crate) struct ConfigOverrideRuntimePlugin {
1637 pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1638 pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1639}
1640
1641impl ConfigOverrideRuntimePlugin {
1642 #[allow(dead_code)] // unused when a service does not provide any operations
1643 pub(crate) fn new(
1644 config_override: Builder,
1645 initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1646 initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1647 ) -> Self {
1648 let mut layer = config_override.config;
1649 let mut components = config_override.runtime_components;
1650 #[allow(unused_mut)]
1651 let mut resolver =
1652 ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1653
1654 resolver
1655 .config_mut()
1656 .load::<::aws_types::region::Region>()
1657 .cloned()
1658 .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1659
1660 let _ = resolver;
1661
1662 // When the config override supplies an identity resolver for any auth scheme
1663 // known to the client or the override itself, we give this operation its own
1664 // short-lived identity cache so that new partitions don't accumulate in the
1665 // shared client cache. A lazy cache (not `no_cache`) is used so that resolved
1666 // identities are served from the short-lived identity cache on retries.
1667 //
1668 // This is skipped if the override already sets its own identity cache.
1669 if components.has_identity_resolvers() && components.identity_cache().is_none() {
1670 components.set_identity_cache(::std::option::Option::Some(
1671 ::aws_smithy_runtime::client::identity::IdentityCache::lazy().max_partitions(1).build(),
1672 ));
1673 }
1674
1675 Self {
1676 config: ::aws_smithy_types::config_bag::Layer::from(layer)
1677 .with_name("aws_sdk_s3::config::ConfigOverrideRuntimePlugin")
1678 .freeze(),
1679 components,
1680 }
1681 }
1682}
1683
1684impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1685 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1686 Some(self.config.clone())
1687 }
1688
1689 fn runtime_components(
1690 &self,
1691 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1692 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1693 ::std::borrow::Cow::Borrowed(&self.components)
1694 }
1695}
1696
1697pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1698pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1699pub use ::aws_smithy_types::config_bag::ConfigBag;
1700
1701pub use ::aws_credential_types::Credentials;
1702
1703impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1704 fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1705 let mut builder = Builder::default();
1706 builder.set_credentials_provider(input.credentials_provider());
1707 builder = builder.region(input.region().cloned());
1708 builder.set_sigv4a_signing_region_set(input.sigv4a_signing_region_set().cloned());
1709 builder.set_request_checksum_calculation(input.request_checksum_calculation());
1710 builder.set_response_checksum_validation(input.response_checksum_validation());
1711 builder.set_use_fips(input.use_fips());
1712 builder.set_use_dual_stack(input.use_dual_stack());
1713 if input.get_origin("endpoint_url").is_client_config() {
1714 builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1715 } else {
1716 builder.set_endpoint_url(
1717 input
1718 .service_config()
1719 .and_then(|conf| {
1720 conf.load_config(service_config_key("S3", "AWS_ENDPOINT_URL", "endpoint_url"))
1721 .map(|it| it.parse().unwrap())
1722 })
1723 .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1724 );
1725 }
1726 // resiliency
1727 builder.set_retry_config(input.retry_config().cloned());
1728 builder.set_timeout_config(input.timeout_config().cloned());
1729 builder.set_sleep_impl(input.sleep_impl());
1730
1731 builder.set_http_client(input.http_client());
1732 builder.set_time_source(input.time_source());
1733 builder.set_behavior_version(input.behavior_version());
1734 builder.set_auth_scheme_preference(input.auth_scheme_preference().cloned());
1735 // setting `None` here removes the default
1736 if let Some(config) = input.stalled_stream_protection() {
1737 builder.set_stalled_stream_protection(Some(config));
1738 }
1739
1740 if let Some(cache) = input.identity_cache() {
1741 builder.set_identity_cache(cache);
1742 }
1743 builder.set_disable_s3_express_session_auth(input.service_config().and_then(|conf| {
1744 let str_config = conf.load_config(service_config_key(
1745 "S3",
1746 "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH",
1747 "s3_disable_express_session_auth",
1748 ));
1749 str_config.and_then(|it| it.parse::<bool>().ok())
1750 }));
1751 builder.set_app_name(input.app_name().cloned());
1752 for framework_metadata in input.framework_metadata() {
1753 builder.push_framework_metadata(framework_metadata.clone());
1754 }
1755
1756 builder
1757 }
1758}
1759
1760impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1761 fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1762 Builder::from(sdk_config).build()
1763 }
1764}
1765
1766pub use ::aws_types::app_name::AppName;
1767pub use ::aws_types::sdk_ua_metadata::FrameworkMetadata;
1768
1769#[allow(dead_code)]
1770fn service_config_key<'a>(service_id: &'a str, env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1771 ::aws_types::service_config::ServiceConfigKey::builder()
1772 .service_id(service_id)
1773 .env(env)
1774 .profile(profile)
1775 .build()
1776 .expect("all field sets explicitly, can't fail")
1777}
1778
1779pub use ::aws_smithy_async::rt::sleep::Sleep;
1780
1781pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1782 let mut configured_plugins = ::std::vec::Vec::new();
1783 ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1784 #[cfg(feature = "behavior-version-latest")]
1785 {
1786 if config.behavior_version.is_none() {
1787 config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1788 }
1789 }
1790
1791 let default_retry_partition = "s3";
1792 let default_retry_partition = match config.region() {
1793 Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{region}")),
1794 None => ::std::borrow::Cow::from(default_retry_partition),
1795 };
1796
1797 let scope = "aws-sdk-s3";
1798
1799 #[allow(deprecated)]
1800 let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1801 // defaults
1802 .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1803 ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1804 .with_retry_partition_name(default_retry_partition)
1805 .with_behavior_version(config.behavior_version.expect("Invalid client configuration: A behavior major version must be set when sending a request or constructing a client. You must set it during client construction or by enabling the `behavior-version-latest` cargo feature."))
1806 .with_is_aws_sdk(true)
1807 ))
1808 // user config
1809 .with_client_plugin(
1810 ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1811 .with_config(config.config.clone())
1812 .with_runtime_components(config.runtime_components.clone())
1813 )
1814 // codegen config
1815 .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1816 .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new())
1817 .with_client_plugin(
1818 ::aws_smithy_runtime::client::metrics::MetricsRuntimePlugin::builder()
1819 .with_scope(scope)
1820 .with_time_source(config.runtime_components.time_source().unwrap_or_default())
1821 .build()
1822 .expect("All required fields have been set")
1823 );
1824
1825 plugins = plugins.with_client_plugin(crate::s3_express::runtime_plugin::S3ExpressRuntimePlugin::new(config.clone()));
1826
1827 for plugin in configured_plugins {
1828 plugins = plugins.with_client_plugin(plugin);
1829 }
1830 plugins
1831}
1832
1833pub use ::aws_smithy_types::config_bag::FrozenLayer;
1834
1835pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1836
1837pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1838
1839pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1840
1841pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1842
1843pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1844
1845pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1846
1847pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1848
1849pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1850
1851pub use ::aws_smithy_types::checksum_config::ResponseChecksumValidation;
1852
1853pub use ::aws_smithy_types::checksum_config::RequestChecksumCalculation;
1854
1855pub use ::aws_types::region::Region;
1856
1857pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1858
1859#[derive(Debug, Clone)]
1860pub(crate) struct ForcePathStyle(pub(crate) bool);
1861impl ::aws_smithy_types::config_bag::Storable for ForcePathStyle {
1862 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1863}
1864
1865#[derive(Debug, Clone)]
1866pub(crate) struct UseArnRegion(pub(crate) bool);
1867impl ::aws_smithy_types::config_bag::Storable for UseArnRegion {
1868 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1869}
1870
1871#[derive(Debug, Clone)]
1872pub(crate) struct DisableMultiRegionAccessPoints(pub(crate) bool);
1873impl ::aws_smithy_types::config_bag::Storable for DisableMultiRegionAccessPoints {
1874 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1875}
1876
1877#[derive(Debug, Clone)]
1878pub(crate) struct Accelerate(pub(crate) bool);
1879impl ::aws_smithy_types::config_bag::Storable for Accelerate {
1880 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1881}
1882
1883#[derive(Debug, Clone)]
1884pub(crate) struct DisableS3ExpressSessionAuth(pub(crate) bool);
1885impl ::aws_smithy_types::config_bag::Storable for DisableS3ExpressSessionAuth {
1886 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1887}
1888
1889pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1890
1891pub use ::aws_smithy_runtime_api::shared::IntoShared;
1892
1893pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1894
1895pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1896
1897pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1898
1899pub use ::aws_credential_types::provider::ProvideCredentials;
1900
1901pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1902
1903pub use ::aws_smithy_types::config_bag::Layer;
1904
1905/// Types needed to configure endpoint resolution.
1906pub mod endpoint;
1907
1908/// HTTP request and response types.
1909pub mod http;
1910
1911/// Types needed to implement [`Intercept`](crate::config::Intercept).
1912pub mod interceptors;
1913
1914/// Retry configuration.
1915pub mod retry;
1916
1917/// Timeout configuration.
1918pub mod timeout;
1919
1920/// Types needed to configure auth scheme resolution.
1921pub mod auth;