aws_sdk_s3/config.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// Configuration for a aws_sdk_s3 service client.
4///
5
6///
7/// Service configuration allows for customization of endpoints, region, credentials providers,
8/// and retry configuration. Generally, it is constructed automatically for you from a shared
9/// configuration loaded by the `aws-config` crate. For example:
10///
11/// ```ignore
12/// // Load a shared config from the environment
13/// let shared_config = aws_config::from_env().load().await;
14/// // The client constructor automatically converts the shared config into the service config
15/// let client = Client::new(&shared_config);
16/// ```
17///
18/// The service config can also be constructed manually using its builder.
19///
20#[derive(::std::clone::Clone, ::std::fmt::Debug)]
21pub struct Config {
22 // Both `config` and `cloneable` are the same config, but the cloneable one
23 // is kept around so that it is possible to convert back into a builder. This can be
24 // optimized in the future.
25 pub(crate) config: crate::config::FrozenLayer,
26 cloneable: ::aws_smithy_types::config_bag::CloneableLayer,
27 pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
28 pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
29 behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
30}
31impl Config {
32 ///
33 /// Constructs a config builder.
34 /// <div class="warning">
35 /// Note that a config created from this builder will not have the same safe defaults as one created by
36 /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
37 /// </div>
38 ///
39 pub fn builder() -> Builder {
40 Builder::default()
41 }
42 /// Converts this config back into a builder so that it can be tweaked.
43 pub fn to_builder(&self) -> Builder {
44 Builder {
45 config: self.cloneable.clone(),
46 runtime_components: self.runtime_components.clone(),
47 runtime_plugins: self.runtime_plugins.clone(),
48 behavior_version: self.behavior_version,
49 }
50 }
51 /// Return a reference to the stalled stream protection configuration contained in this config, if any.
52 pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
53 self.config.load::<crate::config::StalledStreamProtectionConfig>()
54 }
55 /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
56 pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
57 self.runtime_components.http_client()
58 }
59
60 /// Returns the endpoint resolver.
61 pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
62 self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
63 }
64 /// Return a reference to the retry configuration contained in this config, if any.
65 pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
66 self.config.load::<::aws_smithy_types::retry::RetryConfig>()
67 }
68
69 /// Return a cloned shared async sleep implementation from this config, if any.
70 pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
71 self.runtime_components.sleep_impl()
72 }
73
74 /// Return a reference to the timeout configuration contained in this config, if any.
75 pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
76 self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
77 }
78
79 /// Returns a reference to the retry partition contained in this config, if any.
80 ///
81 /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
82 /// method for anything!
83 pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
84 self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
85 }
86 /// Returns the configured identity cache for auth.
87 pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
88 self.runtime_components.identity_cache()
89 }
90 /// Returns interceptors currently registered by the user.
91 pub fn interceptors(&self) -> impl Iterator<Item = crate::config::SharedInterceptor> + '_ {
92 self.runtime_components.interceptors()
93 }
94 /// Return time source used for this service.
95 pub fn time_source(&self) -> ::std::option::Option<::aws_smithy_async::time::SharedTimeSource> {
96 self.runtime_components.time_source()
97 }
98 /// Returns retry classifiers currently registered by the user.
99 pub fn retry_classifiers(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier> + '_ {
100 self.runtime_components.retry_classifiers()
101 }
102 /// Returns the name of the app that is using the client, if it was provided.
103 ///
104 /// This _optional_ name is used to identify the application in the user agent that
105 /// gets sent along with requests.
106 pub fn app_name(&self) -> ::std::option::Option<&::aws_types::app_name::AppName> {
107 self.config.load::<::aws_types::app_name::AppName>()
108 }
109 /// Returns the invocation ID generator if one was given in config.
110 ///
111 /// 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.
112 pub fn invocation_id_generator(&self) -> ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator> {
113 self.config.load::<::aws_runtime::invocation_id::SharedInvocationIdGenerator>().cloned()
114 }
115 /// Creates a new [service config](crate::Config) from a [shared `config`](::aws_types::sdk_config::SdkConfig).
116 pub fn new(config: &::aws_types::sdk_config::SdkConfig) -> Self {
117 Builder::from(config).build()
118 }
119 /// Return a reference to the response_checksum_validation value contained in this config, if any.
120 pub fn response_checksum_validation(&self) -> ::std::option::Option<&crate::config::ResponseChecksumValidation> {
121 self.config.load::<crate::config::ResponseChecksumValidation>()
122 }
123 /// Return a reference to the request_checksum_calculation value contained in this config, if any.
124 pub fn request_checksum_calculation(&self) -> ::std::option::Option<&crate::config::RequestChecksumCalculation> {
125 self.config.load::<crate::config::RequestChecksumCalculation>()
126 }
127 /// The signature version 4 service signing name to use in the credential scope when signing requests.
128 ///
129 /// The signing service may be overridden by the `Endpoint`, or by specifying a custom
130 /// [`SigningName`](aws_types::SigningName) during operation construction
131 pub fn signing_name(&self) -> &'static str {
132 "s3"
133 }
134 /// Returns the AWS region, if it was provided.
135 pub fn region(&self) -> ::std::option::Option<&crate::config::Region> {
136 self.config.load::<crate::config::Region>()
137 }
138 /// 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.
139 #[deprecated(
140 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."
141 )]
142 pub fn credentials_provider(&self) -> Option<crate::config::SharedCredentialsProvider> {
143 ::std::option::Option::None
144 }
145}
146/// Builder for creating a `Config`.
147#[derive(::std::clone::Clone, ::std::fmt::Debug)]
148pub struct Builder {
149 pub(crate) config: ::aws_smithy_types::config_bag::CloneableLayer,
150 pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
151 pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
152 pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
153}
154impl ::std::default::Default for Builder {
155 fn default() -> Self {
156 Self {
157 config: ::std::default::Default::default(),
158 runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
159 runtime_plugins: ::std::default::Default::default(),
160 behavior_version: ::std::default::Default::default(),
161 }
162 }
163}
164impl Builder {
165 ///
166 /// Constructs a config builder.
167 /// <div class="warning">
168 /// Note that a config created from this builder will not have the same safe defaults as one created by
169 /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
170 /// </div>
171 ///
172 pub fn new() -> Self {
173 Self::default()
174 }
175 /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
176 /// but not those in runtime components.
177 #[allow(unused)]
178 pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
179 let mut builder = Self::new();
180 builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
181 builder.set_force_path_style(config_bag.load::<crate::config::ForcePathStyle>().map(|ty| ty.0));
182
183 builder.set_use_arn_region(config_bag.load::<crate::config::UseArnRegion>().map(|ty| ty.0));
184
185 builder.set_disable_multi_region_access_points(config_bag.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0));
186
187 builder.set_accelerate(config_bag.load::<crate::config::Accelerate>().map(|ty| ty.0));
188
189 builder.set_disable_s3_express_session_auth(config_bag.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0));
190 builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
191 builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
192 builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
193 builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
194 builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
195 builder.set_use_dual_stack(config_bag.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0));
196 builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
197 builder.set_response_checksum_validation(config_bag.load::<crate::config::ResponseChecksumValidation>().cloned());
198 builder.set_request_checksum_calculation(config_bag.load::<crate::config::RequestChecksumCalculation>().cloned());
199 builder.set_region(config_bag.load::<crate::config::Region>().cloned());
200 builder
201 }
202 /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
203 /// to configure protection for stalled streams.
204 pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
205 self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
206 self
207 }
208 /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
209 /// to configure protection for stalled streams.
210 pub fn set_stalled_stream_protection(
211 &mut self,
212 stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
213 ) -> &mut Self {
214 self.config.store_or_unset(stalled_stream_protection_config);
215 self
216 }
217 /// Sets the HTTP client to use when making requests.
218 ///
219 /// # Examples
220 /// ```no_run
221 /// # #[cfg(test)]
222 /// # mod tests {
223 /// # #[test]
224 /// # fn example() {
225 /// use std::time::Duration;
226 /// use aws_sdk_s3::config::Config;
227 /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
228 ///
229 /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
230 /// .with_webpki_roots()
231 /// .https_only()
232 /// .enable_http1()
233 /// .enable_http2()
234 /// .build();
235 /// let hyper_client = HyperClientBuilder::new().build(https_connector);
236 ///
237 /// // This connector can then be given to a generated service Config
238 /// let config = my_service_client::Config::builder()
239 /// .endpoint_url("https://example.com")
240 /// .http_client(hyper_client)
241 /// .build();
242 /// let client = my_service_client::Client::from_conf(config);
243 /// # }
244 /// # }
245 /// ```
246 pub fn http_client(mut self, http_client: impl crate::config::HttpClient + 'static) -> Self {
247 self.set_http_client(::std::option::Option::Some(crate::config::IntoShared::into_shared(http_client)));
248 self
249 }
250
251 /// Sets the HTTP client to use when making requests.
252 ///
253 /// # Examples
254 /// ```no_run
255 /// # #[cfg(test)]
256 /// # mod tests {
257 /// # #[test]
258 /// # fn example() {
259 /// use std::time::Duration;
260 /// use aws_sdk_s3::config::{Builder, Config};
261 /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
262 ///
263 /// fn override_http_client(builder: &mut Builder) {
264 /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
265 /// .with_webpki_roots()
266 /// .https_only()
267 /// .enable_http1()
268 /// .enable_http2()
269 /// .build();
270 /// let hyper_client = HyperClientBuilder::new().build(https_connector);
271 /// builder.set_http_client(Some(hyper_client));
272 /// }
273 ///
274 /// let mut builder = aws_sdk_s3::Config::builder();
275 /// override_http_client(&mut builder);
276 /// let config = builder.build();
277 /// # }
278 /// # }
279 /// ```
280 pub fn set_http_client(&mut self, http_client: Option<crate::config::SharedHttpClient>) -> &mut Self {
281 self.runtime_components.set_http_client(http_client);
282 self
283 }
284 /// Forces this client to use path-style addressing for buckets.
285 pub fn force_path_style(mut self, force_path_style: impl Into<bool>) -> Self {
286 self.set_force_path_style(Some(force_path_style.into()));
287 self
288 }
289 /// Forces this client to use path-style addressing for buckets.
290 pub fn set_force_path_style(&mut self, force_path_style: Option<bool>) -> &mut Self {
291 self.config.store_or_unset(force_path_style.map(crate::config::ForcePathStyle));
292 self
293 }
294
295 /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
296 pub fn use_arn_region(mut self, use_arn_region: impl Into<bool>) -> Self {
297 self.set_use_arn_region(Some(use_arn_region.into()));
298 self
299 }
300 /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
301 pub fn set_use_arn_region(&mut self, use_arn_region: Option<bool>) -> &mut Self {
302 self.config.store_or_unset(use_arn_region.map(crate::config::UseArnRegion));
303 self
304 }
305
306 /// Disables this client's usage of Multi-Region Access Points.
307 pub fn disable_multi_region_access_points(mut self, disable_multi_region_access_points: impl Into<bool>) -> Self {
308 self.set_disable_multi_region_access_points(Some(disable_multi_region_access_points.into()));
309 self
310 }
311 /// Disables this client's usage of Multi-Region Access Points.
312 pub fn set_disable_multi_region_access_points(&mut self, disable_multi_region_access_points: Option<bool>) -> &mut Self {
313 self.config
314 .store_or_unset(disable_multi_region_access_points.map(crate::config::DisableMultiRegionAccessPoints));
315 self
316 }
317
318 /// Enables this client to use S3 Transfer Acceleration endpoints.
319 pub fn accelerate(mut self, accelerate: impl Into<bool>) -> Self {
320 self.set_accelerate(Some(accelerate.into()));
321 self
322 }
323 /// Enables this client to use S3 Transfer Acceleration endpoints.
324 pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Self {
325 self.config.store_or_unset(accelerate.map(crate::config::Accelerate));
326 self
327 }
328
329 /// Disables this client's usage of Session Auth for S3Express buckets and reverts to using conventional SigV4 for those.
330 pub fn disable_s3_express_session_auth(mut self, disable_s3_express_session_auth: impl Into<bool>) -> Self {
331 self.set_disable_s3_express_session_auth(Some(disable_s3_express_session_auth.into()));
332 self
333 }
334 /// Disables this client's usage of Session Auth for S3Express buckets and reverts to using conventional SigV4 for those.
335 pub fn set_disable_s3_express_session_auth(&mut self, disable_s3_express_session_auth: Option<bool>) -> &mut Self {
336 self.config
337 .store_or_unset(disable_s3_express_session_auth.map(crate::config::DisableS3ExpressSessionAuth));
338 self
339 }
340 /// Sets the endpoint resolver to use when making requests.
341 ///
342
343 /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
344 /// rules for `aws_sdk_s3`.
345
346 ///
347 /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
348 /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
349 /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
350 ///
351 /// # Examples
352 /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
353 /// ```no_run
354 /// use aws_sdk_s3::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
355 /// #[derive(Debug)]
356 /// struct StageResolver { stage: String }
357 /// impl ResolveEndpoint for StageResolver {
358 /// fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
359 /// let stage = &self.stage;
360 /// EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
361 /// }
362 /// }
363 /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
364 /// let config = aws_sdk_s3::Config::builder().endpoint_resolver(resolver).build();
365 /// let client = aws_sdk_s3::Client::from_conf(config);
366 /// ```
367 pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
368 self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
369 self
370 }
371
372 /// Sets the endpoint resolver to use when making requests.
373 ///
374
375 /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
376 /// rules for `aws_sdk_s3`.
377 pub fn set_endpoint_resolver(
378 &mut self,
379 endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
380 ) -> &mut Self {
381 self.runtime_components.set_endpoint_resolver(endpoint_resolver);
382 self
383 }
384 /// Set the retry_config for the builder
385 ///
386 /// # Examples
387 /// ```no_run
388 /// use aws_sdk_s3::config::Config;
389 /// use aws_sdk_s3::config::retry::RetryConfig;
390 ///
391 /// let retry_config = RetryConfig::standard().with_max_attempts(5);
392 /// let config = Config::builder().retry_config(retry_config).build();
393 /// ```
394 pub fn retry_config(mut self, retry_config: ::aws_smithy_types::retry::RetryConfig) -> Self {
395 self.set_retry_config(Some(retry_config));
396 self
397 }
398
399 /// Set the retry_config for the builder
400 ///
401 /// # Examples
402 /// ```no_run
403 /// use aws_sdk_s3::config::{Builder, Config};
404 /// use aws_sdk_s3::config::retry::RetryConfig;
405 ///
406 /// fn disable_retries(builder: &mut Builder) {
407 /// let retry_config = RetryConfig::standard().with_max_attempts(1);
408 /// builder.set_retry_config(Some(retry_config));
409 /// }
410 ///
411 /// let mut builder = Config::builder();
412 /// disable_retries(&mut builder);
413 /// let config = builder.build();
414 /// ```
415 pub fn set_retry_config(&mut self, retry_config: ::std::option::Option<::aws_smithy_types::retry::RetryConfig>) -> &mut Self {
416 retry_config.map(|r| self.config.store_put(r));
417 self
418 }
419 /// Set the sleep_impl for the builder
420 ///
421 /// # Examples
422 ///
423 /// ```no_run
424 /// use aws_sdk_s3::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
425 ///
426 /// #[derive(Debug)]
427 /// pub struct ForeverSleep;
428 ///
429 /// impl AsyncSleep for ForeverSleep {
430 /// fn sleep(&self, duration: std::time::Duration) -> Sleep {
431 /// Sleep::new(std::future::pending())
432 /// }
433 /// }
434 ///
435 /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
436 /// let config = Config::builder().sleep_impl(sleep_impl).build();
437 /// ```
438 pub fn sleep_impl(mut self, sleep_impl: impl crate::config::AsyncSleep + 'static) -> Self {
439 self.set_sleep_impl(Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(sleep_impl)));
440 self
441 }
442
443 /// Set the sleep_impl for the builder
444 ///
445 /// # Examples
446 ///
447 /// ```no_run
448 /// use aws_sdk_s3::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
449 ///
450 /// #[derive(Debug)]
451 /// pub struct ForeverSleep;
452 ///
453 /// impl AsyncSleep for ForeverSleep {
454 /// fn sleep(&self, duration: std::time::Duration) -> Sleep {
455 /// Sleep::new(std::future::pending())
456 /// }
457 /// }
458 ///
459 /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
460 /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
461 /// builder.set_sleep_impl(Some(sleep_impl));
462 /// }
463 ///
464 /// let mut builder = Config::builder();
465 /// set_never_ending_sleep_impl(&mut builder);
466 /// let config = builder.build();
467 /// ```
468 pub fn set_sleep_impl(&mut self, sleep_impl: ::std::option::Option<crate::config::SharedAsyncSleep>) -> &mut Self {
469 self.runtime_components.set_sleep_impl(sleep_impl);
470 self
471 }
472 /// Set the timeout_config for the builder
473 ///
474 /// # Examples
475 ///
476 /// ```no_run
477 /// # use std::time::Duration;
478 /// use aws_sdk_s3::config::Config;
479 /// use aws_sdk_s3::config::timeout::TimeoutConfig;
480 ///
481 /// let timeout_config = TimeoutConfig::builder()
482 /// .operation_attempt_timeout(Duration::from_secs(1))
483 /// .build();
484 /// let config = Config::builder().timeout_config(timeout_config).build();
485 /// ```
486 pub fn timeout_config(mut self, timeout_config: ::aws_smithy_types::timeout::TimeoutConfig) -> Self {
487 self.set_timeout_config(Some(timeout_config));
488 self
489 }
490
491 /// Set the timeout_config for the builder.
492 ///
493 /// Setting this to `None` has no effect if another source of configuration has set timeouts. If you
494 /// are attempting to disable timeouts, use [`TimeoutConfig::disabled`](::aws_smithy_types::timeout::TimeoutConfig::disabled)
495 ///
496 ///
497 /// # Examples
498 ///
499 /// ```no_run
500 /// # use std::time::Duration;
501 /// use aws_sdk_s3::config::{Builder, Config};
502 /// use aws_sdk_s3::config::timeout::TimeoutConfig;
503 ///
504 /// fn set_request_timeout(builder: &mut Builder) {
505 /// let timeout_config = TimeoutConfig::builder()
506 /// .operation_attempt_timeout(Duration::from_secs(1))
507 /// .build();
508 /// builder.set_timeout_config(Some(timeout_config));
509 /// }
510 ///
511 /// let mut builder = Config::builder();
512 /// set_request_timeout(&mut builder);
513 /// let config = builder.build();
514 /// ```
515 pub fn set_timeout_config(&mut self, timeout_config: ::std::option::Option<::aws_smithy_types::timeout::TimeoutConfig>) -> &mut Self {
516 // passing None has no impact.
517 let Some(mut timeout_config) = timeout_config else { return self };
518
519 if let Some(base) = self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>() {
520 timeout_config.take_defaults_from(base);
521 }
522 self.config.store_put(timeout_config);
523 self
524 }
525 /// Set the partition for retry-related state. When clients share a retry partition, they will
526 /// also share things like token buckets and client rate limiters. By default, all clients
527 /// for the same service will share a partition.
528 pub fn retry_partition(mut self, retry_partition: ::aws_smithy_runtime::client::retries::RetryPartition) -> Self {
529 self.set_retry_partition(Some(retry_partition));
530 self
531 }
532 /// Set the partition for retry-related state. When clients share a retry partition, they will
533 /// also share things like token buckets and client rate limiters. By default, all clients
534 /// for the same service will share a partition.
535 pub fn set_retry_partition(
536 &mut self,
537 retry_partition: ::std::option::Option<::aws_smithy_runtime::client::retries::RetryPartition>,
538 ) -> &mut Self {
539 retry_partition.map(|r| self.config.store_put(r));
540 self
541 }
542 /// Set the identity cache for auth.
543 ///
544 /// The identity cache defaults to a lazy caching implementation that will resolve
545 /// an identity when it is requested, and place it in the cache thereafter. Subsequent
546 /// requests will take the value from the cache while it is still valid. Once it expires,
547 /// the next request will result in refreshing the identity.
548 ///
549 /// This configuration allows you to disable or change the default caching mechanism.
550 /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
551 /// trait and pass that implementation into this function.
552 ///
553 /// # Examples
554 ///
555 /// Disabling identity caching:
556 /// ```no_run
557 /// use aws_sdk_s3::config::IdentityCache;
558 ///
559 /// let config = aws_sdk_s3::Config::builder()
560 /// .identity_cache(IdentityCache::no_cache())
561 /// // ...
562 /// .build();
563 /// let client = aws_sdk_s3::Client::from_conf(config);
564 /// ```
565 ///
566 /// Customizing lazy caching:
567 /// ```no_run
568 /// use aws_sdk_s3::config::IdentityCache;
569 /// use std::time::Duration;
570 ///
571 /// let config = aws_sdk_s3::Config::builder()
572 /// .identity_cache(
573 /// IdentityCache::lazy()
574 /// // change the load timeout to 10 seconds
575 /// .load_timeout(Duration::from_secs(10))
576 /// .build()
577 /// )
578 /// // ...
579 /// .build();
580 /// let client = aws_sdk_s3::Client::from_conf(config);
581 /// ```
582
583 pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
584 self.set_identity_cache(identity_cache);
585 self
586 }
587
588 /// Set the identity cache for auth.
589 ///
590 /// The identity cache defaults to a lazy caching implementation that will resolve
591 /// an identity when it is requested, and place it in the cache thereafter. Subsequent
592 /// requests will take the value from the cache while it is still valid. Once it expires,
593 /// the next request will result in refreshing the identity.
594 ///
595 /// This configuration allows you to disable or change the default caching mechanism.
596 /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
597 /// trait and pass that implementation into this function.
598 ///
599 /// # Examples
600 ///
601 /// Disabling identity caching:
602 /// ```no_run
603 /// use aws_sdk_s3::config::IdentityCache;
604 ///
605 /// let config = aws_sdk_s3::Config::builder()
606 /// .identity_cache(IdentityCache::no_cache())
607 /// // ...
608 /// .build();
609 /// let client = aws_sdk_s3::Client::from_conf(config);
610 /// ```
611 ///
612 /// Customizing lazy caching:
613 /// ```no_run
614 /// use aws_sdk_s3::config::IdentityCache;
615 /// use std::time::Duration;
616 ///
617 /// let config = aws_sdk_s3::Config::builder()
618 /// .identity_cache(
619 /// IdentityCache::lazy()
620 /// // change the load timeout to 10 seconds
621 /// .load_timeout(Duration::from_secs(10))
622 /// .build()
623 /// )
624 /// // ...
625 /// .build();
626 /// let client = aws_sdk_s3::Client::from_conf(config);
627 /// ```
628
629 pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
630 self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
631 self
632 }
633 /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
634 ///
635 /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
636 /// The SDK provides a default set of interceptors. An interceptor configured by this method
637 /// will run after those default interceptors.
638 ///
639 /// # Examples
640 /// ```no_run
641 /// # #[cfg(test)]
642 /// # mod tests {
643 /// # #[test]
644 /// # fn example() {
645 /// use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
646 /// use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext};
647 /// use aws_smithy_types::config_bag::ConfigBag;
648 /// use aws_sdk_s3::config::Config;
649 ///
650 /// fn base_url() -> String {
651 /// // ...
652 /// # String::new()
653 /// }
654 ///
655 /// #[derive(Debug)]
656 /// pub struct UriModifierInterceptor;
657 /// impl Intercept for UriModifierInterceptor {
658 /// fn modify_before_signing(
659 /// &self,
660 /// context: &mut InterceptorContext<BeforeTransmit>,
661 /// _cfg: &mut ConfigBag,
662 /// ) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
663 /// let request = context.request_mut();
664 /// let uri = format!("{}{}", base_url(), request.uri().path());
665 /// *request.uri_mut() = uri.parse()?;
666 ///
667 /// Ok(())
668 /// }
669 /// }
670 ///
671 /// let config = Config::builder()
672 /// .interceptor(UriModifierInterceptor)
673 /// .build();
674 /// # }
675 /// # }
676 /// ```
677 pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
678 self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
679 self
680 }
681
682 /// Add a [`SharedInterceptor`](crate::config::SharedInterceptor) that runs at specific stages of the request execution pipeline.
683 ///
684 /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
685 /// The SDK provides a default set of interceptors. An interceptor configured by this method
686 /// will run after those default interceptors.
687 ///
688 /// # Examples
689 /// ```no_run
690 /// # #[cfg(test)]
691 /// # mod tests {
692 /// # #[test]
693 /// # fn example() {
694 /// use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
695 /// use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext, SharedInterceptor};
696 /// use aws_smithy_types::config_bag::ConfigBag;
697 /// use aws_sdk_s3::config::{Builder, Config};
698 ///
699 /// fn base_url() -> String {
700 /// // ...
701 /// # String::new()
702 /// }
703 ///
704 /// fn modify_request_uri(builder: &mut Builder) {
705 /// #[derive(Debug)]
706 /// pub struct UriModifierInterceptor;
707 /// impl Intercept for UriModifierInterceptor {
708 /// fn modify_before_signing(
709 /// &self,
710 /// context: &mut InterceptorContext<BeforeTransmit>,
711 /// _cfg: &mut ConfigBag,
712 /// ) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
713 /// let request = context.request_mut();
714 /// let uri = format!("{}{}", base_url(), request.uri().path());
715 /// *request.uri_mut() = uri.parse()?;
716 ///
717 /// Ok(())
718 /// }
719 /// }
720 /// builder.push_interceptor(SharedInterceptor::new(UriModifierInterceptor));
721 /// }
722 ///
723 /// let mut builder = Config::builder();
724 /// modify_request_uri(&mut builder);
725 /// let config = builder.build();
726 /// # }
727 /// # }
728 /// ```
729 pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
730 self.runtime_components.push_interceptor(interceptor);
731 self
732 }
733
734 /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
735 pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
736 self.runtime_components.set_interceptors(interceptors.into_iter());
737 self
738 }
739 /// Sets the time source used for this service
740 pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
741 self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
742 time_source,
743 )));
744 self
745 }
746 /// Sets the time source used for this service
747 pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
748 self.runtime_components.set_time_source(time_source);
749 self
750 }
751 /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
752 /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
753 ///
754 /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
755 ///
756 /// # Examples
757 /// ```no_run
758 /// # #[cfg(test)]
759 /// # mod tests {
760 /// # #[test]
761 /// # fn example() {
762 /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
763 /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
764 /// use aws_smithy_runtime_api::client::retries::classifiers::{
765 /// ClassifyRetry, RetryAction, RetryClassifierPriority,
766 /// };
767 /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
768 /// use aws_smithy_types::retry::ErrorKind;
769 /// use std::error::Error as StdError;
770 /// use std::marker::PhantomData;
771 /// use aws_sdk_s3::config::Config;
772 /// # struct SomeOperationError {}
773 ///
774 /// const RETRYABLE_ERROR_CODES: &[&str] = [
775 /// // List error codes to be retried here...
776 /// ];
777 ///
778 /// // When classifying at an operation's error type, classifiers require a generic parameter.
779 /// // When classifying the HTTP response alone, no generic is needed.
780 /// #[derive(Debug, Default)]
781 /// pub struct ErrorCodeClassifier<E> {
782 /// _inner: PhantomData<E>,
783 /// }
784 ///
785 /// impl<E> ExampleErrorCodeClassifier<E> {
786 /// pub fn new() -> Self {
787 /// Self {
788 /// _inner: PhantomData,
789 /// }
790 /// }
791 /// }
792 ///
793 /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
794 /// where
795 /// // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
796 /// E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
797 /// {
798 /// fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
799 /// // Check for a result
800 /// let output_or_error = ctx.output_or_error();
801 /// // Check for an error
802 /// let error = match output_or_error {
803 /// Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
804 /// Some(Err(err)) => err,
805 /// };
806 ///
807 /// // Downcast the generic error and extract the code
808 /// let error_code = OrchestratorError::as_operation_error(error)
809 /// .and_then(|err| err.downcast_ref::<E>())
810 /// .and_then(|err| err.code());
811 ///
812 /// // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
813 /// if let Some(error_code) = error_code {
814 /// if RETRYABLE_ERROR_CODES.contains(&error_code) {
815 /// return RetryAction::transient_error();
816 /// }
817 /// }
818 ///
819 /// // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
820 /// // Another classifier may still classify this response as retryable.
821 /// RetryAction::NoActionIndicated
822 /// }
823 ///
824 /// fn name(&self) -> &'static str { "Example Error Code Classifier" }
825 /// }
826 ///
827 /// let config = Config::builder()
828 /// .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
829 /// .build();
830 /// # }
831 /// # }
832 /// ```
833 pub fn retry_classifier(
834 mut self,
835 retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
836 ) -> Self {
837 self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
838 retry_classifier,
839 ));
840 self
841 }
842
843 /// Add a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier) that will be used by the
844 /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
845 ///
846 /// A retry classifier configured by this method will run according to its priority.
847 ///
848 /// # Examples
849 /// ```no_run
850 /// # #[cfg(test)]
851 /// # mod tests {
852 /// # #[test]
853 /// # fn example() {
854 /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
855 /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
856 /// use aws_smithy_runtime_api::client::retries::classifiers::{
857 /// ClassifyRetry, RetryAction, RetryClassifierPriority,
858 /// };
859 /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
860 /// use aws_smithy_types::retry::ErrorKind;
861 /// use std::error::Error as StdError;
862 /// use std::marker::PhantomData;
863 /// use aws_sdk_s3::config::{Builder, Config};
864 /// # struct SomeOperationError {}
865 ///
866 /// const RETRYABLE_ERROR_CODES: &[&str] = [
867 /// // List error codes to be retried here...
868 /// ];
869 /// fn set_example_error_code_classifier(builder: &mut Builder) {
870 /// // When classifying at an operation's error type, classifiers require a generic parameter.
871 /// // When classifying the HTTP response alone, no generic is needed.
872 /// #[derive(Debug, Default)]
873 /// pub struct ExampleErrorCodeClassifier<E> {
874 /// _inner: PhantomData<E>,
875 /// }
876 ///
877 /// impl<E> ExampleErrorCodeClassifier<E> {
878 /// pub fn new() -> Self {
879 /// Self {
880 /// _inner: PhantomData,
881 /// }
882 /// }
883 /// }
884 ///
885 /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
886 /// where
887 /// // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
888 /// E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
889 /// {
890 /// fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
891 /// // Check for a result
892 /// let output_or_error = ctx.output_or_error();
893 /// // Check for an error
894 /// let error = match output_or_error {
895 /// Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
896 /// Some(Err(err)) => err,
897 /// };
898 ///
899 /// // Downcast the generic error and extract the code
900 /// let error_code = OrchestratorError::as_operation_error(error)
901 /// .and_then(|err| err.downcast_ref::<E>())
902 /// .and_then(|err| err.code());
903 ///
904 /// // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
905 /// if let Some(error_code) = error_code {
906 /// if RETRYABLE_ERROR_CODES.contains(&error_code) {
907 /// return RetryAction::transient_error();
908 /// }
909 /// }
910 ///
911 /// // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
912 /// // Another classifier may still classify this response as retryable.
913 /// RetryAction::NoActionIndicated
914 /// }
915 ///
916 /// fn name(&self) -> &'static str { "Example Error Code Classifier" }
917 /// }
918 ///
919 /// builder.push_retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
920 /// }
921 ///
922 /// let mut builder = Config::builder();
923 /// set_example_error_code_classifier(&mut builder);
924 /// let config = builder.build();
925 /// # }
926 /// # }
927 /// ```
928 pub fn push_retry_classifier(
929 &mut self,
930 retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
931 ) -> &mut Self {
932 self.runtime_components.push_retry_classifier(retry_classifier);
933 self
934 }
935
936 /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
937 /// were previously set.
938 pub fn set_retry_classifiers(
939 &mut self,
940 retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
941 ) -> &mut Self {
942 self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
943 self
944 }
945 /// Sets the name of the app that is using the client.
946 ///
947 /// This _optional_ name is used to identify the application in the user agent that
948 /// gets sent along with requests.
949 pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
950 self.set_app_name(Some(app_name));
951 self
952 }
953 /// Sets the name of the app that is using the client.
954 ///
955 /// This _optional_ name is used to identify the application in the user agent that
956 /// gets sent along with requests.
957 pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
958 self.config.store_or_unset(app_name);
959 self
960 }
961 /// Overrides the default invocation ID generator.
962 ///
963 /// 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.
964 pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
965 self.set_invocation_id_generator(::std::option::Option::Some(
966 ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
967 ));
968 self
969 }
970 /// Overrides the default invocation ID generator.
971 ///
972 /// 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.
973 pub fn set_invocation_id_generator(
974 &mut self,
975 gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
976 ) -> &mut Self {
977 self.config.store_or_unset(gen);
978 self
979 }
980 /// Sets the endpoint URL used to communicate with this service
981
982 /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
983 /// will be prefixed onto this URL. To fully override the endpoint resolver, use
984 /// [`Builder::endpoint_resolver`].
985 pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
986 self.set_endpoint_url(Some(endpoint_url.into()));
987 self
988 }
989 /// Sets the endpoint URL used to communicate with this service
990
991 /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
992 /// will be prefixed onto this URL. To fully override the endpoint resolver, use
993 /// [`Builder::endpoint_resolver`].
994 pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
995 self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
996 self
997 }
998 /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
999 pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
1000 self.set_use_dual_stack(Some(use_dual_stack.into()));
1001 self
1002 }
1003 /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1004 pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
1005 self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
1006 self
1007 }
1008 /// 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.
1009 pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
1010 self.set_use_fips(Some(use_fips.into()));
1011 self
1012 }
1013 /// 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.
1014 pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
1015 self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
1016 self
1017 }
1018 /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1019 /// to determine when checksum validation will be performed on response payloads.
1020 pub fn response_checksum_validation(mut self, response_checksum_validation: crate::config::ResponseChecksumValidation) -> Self {
1021 self.set_response_checksum_validation(::std::option::Option::Some(response_checksum_validation));
1022 self
1023 }
1024 /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1025 /// to determine when checksum validation will be performed on response payloads.
1026 pub fn set_response_checksum_validation(
1027 &mut self,
1028 response_checksum_validation: ::std::option::Option<crate::config::ResponseChecksumValidation>,
1029 ) -> &mut Self {
1030 self.config.store_or_unset(response_checksum_validation);
1031 self
1032 }
1033 /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1034 /// to determine when a checksum will be calculated for request payloads.
1035 pub fn request_checksum_calculation(mut self, request_checksum_calculation: crate::config::RequestChecksumCalculation) -> Self {
1036 self.set_request_checksum_calculation(::std::option::Option::Some(request_checksum_calculation));
1037 self
1038 }
1039 /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1040 /// to determine when a checksum will be calculated for request payloads.
1041 pub fn set_request_checksum_calculation(
1042 &mut self,
1043 request_checksum_calculation: ::std::option::Option<crate::config::RequestChecksumCalculation>,
1044 ) -> &mut Self {
1045 self.config.store_or_unset(request_checksum_calculation);
1046 self
1047 }
1048 /// Sets the AWS region to use when making requests.
1049 ///
1050 /// # Examples
1051 /// ```no_run
1052 /// use aws_types::region::Region;
1053 /// use aws_sdk_s3::config::{Builder, Config};
1054 ///
1055 /// let config = aws_sdk_s3::Config::builder()
1056 /// .region(Region::new("us-east-1"))
1057 /// .build();
1058 /// ```
1059 pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1060 self.set_region(region.into());
1061 self
1062 }
1063 /// Sets the AWS region to use when making requests.
1064 pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1065 self.config.store_or_unset(region);
1066 self
1067 }
1068 /// Sets the credentials provider for this service
1069 pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1070 self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1071 credentials_provider,
1072 )));
1073 self
1074 }
1075 /// Sets the credentials provider for this service
1076 pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1077 if let Some(credentials_provider) = credentials_provider {
1078 #[cfg(feature = "sigv4a")]
1079 {
1080 self.runtime_components
1081 .set_identity_resolver(::aws_runtime::auth::sigv4a::SCHEME_ID, credentials_provider.clone());
1082 }
1083 self.runtime_components
1084 .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1085 }
1086 self
1087 }
1088 /// Sets the credentials provider for S3 Express One Zone
1089 pub fn express_credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1090 self.set_express_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1091 credentials_provider,
1092 )));
1093 self
1094 }
1095 /// Sets the credentials provider for S3 Express One Zone
1096 pub fn set_express_credentials_provider(
1097 &mut self,
1098 credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>,
1099 ) -> &mut Self {
1100 if let ::std::option::Option::Some(credentials_provider) = credentials_provider {
1101 self.runtime_components
1102 .set_identity_resolver(crate::s3_express::auth::SCHEME_ID, credentials_provider);
1103 }
1104 self
1105 }
1106 /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1107 ///
1108 /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1109 /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1110 /// all operations might be the ideal behavior but could break existing applications.
1111 ///
1112 /// # Examples
1113 ///
1114 /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1115 /// ```no_run
1116 /// use aws_sdk_s3::config::BehaviorVersion;
1117 ///
1118 /// let config = aws_sdk_s3::Config::builder()
1119 /// .behavior_version(BehaviorVersion::latest())
1120 /// // ...
1121 /// .build();
1122 /// let client = aws_sdk_s3::Client::from_conf(config);
1123 /// ```
1124 ///
1125 /// Customizing behavior major version:
1126 /// ```no_run
1127 /// use aws_sdk_s3::config::BehaviorVersion;
1128 ///
1129 /// let config = aws_sdk_s3::Config::builder()
1130 /// .behavior_version(BehaviorVersion::v2023_11_09())
1131 /// // ...
1132 /// .build();
1133 /// let client = aws_sdk_s3::Client::from_conf(config);
1134 /// ```
1135
1136 pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1137 self.set_behavior_version(Some(behavior_version));
1138 self
1139 }
1140
1141 /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1142 ///
1143 /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1144 /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1145 /// all operations might be the ideal behavior but could break existing applications.
1146 ///
1147 /// # Examples
1148 ///
1149 /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1150 /// ```no_run
1151 /// use aws_sdk_s3::config::BehaviorVersion;
1152 ///
1153 /// let config = aws_sdk_s3::Config::builder()
1154 /// .behavior_version(BehaviorVersion::latest())
1155 /// // ...
1156 /// .build();
1157 /// let client = aws_sdk_s3::Client::from_conf(config);
1158 /// ```
1159 ///
1160 /// Customizing behavior major version:
1161 /// ```no_run
1162 /// use aws_sdk_s3::config::BehaviorVersion;
1163 ///
1164 /// let config = aws_sdk_s3::Config::builder()
1165 /// .behavior_version(BehaviorVersion::v2023_11_09())
1166 /// // ...
1167 /// .build();
1168 /// let client = aws_sdk_s3::Client::from_conf(config);
1169 /// ```
1170
1171 pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1172 self.behavior_version = behavior_version;
1173 self
1174 }
1175
1176 /// Convenience method to set the latest behavior major version
1177 ///
1178 /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1179 pub fn behavior_version_latest(mut self) -> Self {
1180 self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1181 self
1182 }
1183 /// Adds a runtime plugin to the config.
1184 #[allow(unused)]
1185 pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1186 self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1187 self
1188 }
1189 /// Adds a runtime plugin to the config.
1190 #[allow(unused)]
1191 pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1192 self.runtime_plugins.push(plugin);
1193 self
1194 }
1195 #[cfg(any(feature = "test-util", test))]
1196 #[allow(unused_mut)]
1197 /// Apply test defaults to the builder
1198 pub fn apply_test_defaults(&mut self) -> &mut Self {
1199 self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1200 ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1201 )));
1202 self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1203 self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1204 ::aws_credential_types::Credentials::for_tests(),
1205 )));
1206 self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1207 self
1208 }
1209 #[cfg(any(feature = "test-util", test))]
1210 #[allow(unused_mut)]
1211 /// Apply test defaults to the builder
1212 pub fn with_test_defaults(mut self) -> Self {
1213 self.apply_test_defaults();
1214 self
1215 }
1216 /// Builds a [`Config`].
1217 #[allow(unused_mut)]
1218 pub fn build(mut self) -> Config {
1219 let mut layer = self.config;
1220
1221 if self.runtime_components.time_source().is_none() {
1222 self.runtime_components
1223 .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1224 }
1225 layer.store_put(crate::meta::API_METADATA.clone());
1226 layer.store_put(::aws_types::SigningName::from_static("s3"));
1227 layer
1228 .load::<::aws_types::region::Region>()
1229 .cloned()
1230 .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1231 Config {
1232 config: crate::config::Layer::from(layer.clone()).with_name("aws_sdk_s3::config::Config").freeze(),
1233 cloneable: layer,
1234 runtime_components: self.runtime_components,
1235 runtime_plugins: self.runtime_plugins,
1236 behavior_version: self.behavior_version,
1237 }
1238 }
1239}
1240#[derive(::std::fmt::Debug)]
1241pub(crate) struct ServiceRuntimePlugin {
1242 config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1243 runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1244}
1245
1246impl ServiceRuntimePlugin {
1247 pub fn new(_service_config: crate::config::Config) -> Self {
1248 let config = { None };
1249 let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1250 runtime_components.set_endpoint_resolver(Some({
1251 use crate::config::endpoint::ResolveEndpoint;
1252 crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1253 }));
1254 runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
1255 runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1256 runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
1257 runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
1258 runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1259 runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1260 runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1261 runtime_components.push_interceptor(::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new());
1262 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1263 ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1264 ));
1265 #[cfg(feature = "sigv4a")]
1266 {
1267 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1268 ::aws_runtime::auth::sigv4a::SigV4aAuthScheme::new(),
1269 ));
1270 }
1271 runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1272 crate::s3_express::auth::S3ExpressAuthScheme::new(),
1273 ));
1274 runtime_components.set_identity_resolver(crate::s3_express::auth::SCHEME_ID, crate::s3_express::identity_provider::DefaultS3ExpressIdentityProvider::builder()
1275 .behavior_version(_service_config.behavior_version.expect("Invalid client configuration: A behavior version must be set when creating an inner S3 client. A behavior version should be set in the outer S3 client, so it needs to be passed down to the inner client."))
1276 .time_source(_service_config.time_source().unwrap_or_default())
1277 .build());
1278 Self { config, runtime_components }
1279 }
1280}
1281
1282impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1283 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1284 self.config.clone()
1285 }
1286
1287 fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1288 ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1289 }
1290
1291 fn runtime_components(
1292 &self,
1293 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1294 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1295 ::std::borrow::Cow::Borrowed(&self.runtime_components)
1296 }
1297}
1298
1299/// Cross-operation shared-state singletons
1300
1301/// A plugin that enables configuration for a single operation invocation
1302///
1303/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1304/// In the case of default values requested, they will be obtained from `client_config`.
1305#[derive(Debug)]
1306pub(crate) struct ConfigOverrideRuntimePlugin {
1307 pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1308 pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1309}
1310
1311impl ConfigOverrideRuntimePlugin {
1312 #[allow(dead_code)] // unused when a service does not provide any operations
1313 pub(crate) fn new(
1314 config_override: Builder,
1315 initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1316 initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1317 ) -> Self {
1318 let mut layer = config_override.config;
1319 let mut components = config_override.runtime_components;
1320 #[allow(unused_mut)]
1321 let mut resolver =
1322 ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1323
1324 resolver
1325 .config_mut()
1326 .load::<::aws_types::region::Region>()
1327 .cloned()
1328 .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1329
1330 let _ = resolver;
1331 Self {
1332 config: ::aws_smithy_types::config_bag::Layer::from(layer)
1333 .with_name("aws_sdk_s3::config::ConfigOverrideRuntimePlugin")
1334 .freeze(),
1335 components,
1336 }
1337 }
1338}
1339
1340impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1341 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1342 Some(self.config.clone())
1343 }
1344
1345 fn runtime_components(
1346 &self,
1347 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1348 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1349 ::std::borrow::Cow::Borrowed(&self.components)
1350 }
1351}
1352
1353pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1354pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1355pub use ::aws_smithy_types::config_bag::ConfigBag;
1356
1357pub use ::aws_credential_types::Credentials;
1358
1359impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1360 fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1361 let mut builder = Builder::default();
1362 builder.set_disable_s3_express_session_auth(input.service_config().and_then(|conf| {
1363 let str_config = conf.load_config(service_config_key(
1364 "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH",
1365 "s3_disable_express_session_auth",
1366 ));
1367 str_config.and_then(|it| it.parse::<bool>().ok())
1368 }));
1369 builder.set_credentials_provider(input.credentials_provider());
1370 builder = builder.region(input.region().cloned());
1371 builder.set_request_checksum_calculation(input.request_checksum_calculation());
1372 builder.set_response_checksum_validation(input.response_checksum_validation());
1373 builder.set_use_fips(input.use_fips());
1374 builder.set_use_dual_stack(input.use_dual_stack());
1375 if input.get_origin("endpoint_url").is_client_config() {
1376 builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1377 } else {
1378 builder.set_endpoint_url(
1379 input
1380 .service_config()
1381 .and_then(|conf| {
1382 conf.load_config(service_config_key("AWS_ENDPOINT_URL", "endpoint_url"))
1383 .map(|it| it.parse().unwrap())
1384 })
1385 .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1386 );
1387 }
1388 // resiliency
1389 builder.set_retry_config(input.retry_config().cloned());
1390 builder.set_timeout_config(input.timeout_config().cloned());
1391 builder.set_sleep_impl(input.sleep_impl());
1392
1393 builder.set_http_client(input.http_client());
1394 builder.set_time_source(input.time_source());
1395 builder.set_behavior_version(input.behavior_version());
1396 // setting `None` here removes the default
1397 if let Some(config) = input.stalled_stream_protection() {
1398 builder.set_stalled_stream_protection(Some(config));
1399 }
1400
1401 if let Some(cache) = input.identity_cache() {
1402 builder.set_identity_cache(cache);
1403 }
1404 builder.set_app_name(input.app_name().cloned());
1405
1406 builder
1407 }
1408}
1409
1410impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1411 fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1412 Builder::from(sdk_config).build()
1413 }
1414}
1415
1416pub use ::aws_types::app_name::AppName;
1417
1418#[allow(dead_code)]
1419fn service_config_key<'a>(env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1420 ::aws_types::service_config::ServiceConfigKey::builder()
1421 .service_id("s3")
1422 .env(env)
1423 .profile(profile)
1424 .build()
1425 .expect("all field sets explicitly, can't fail")
1426}
1427
1428pub use ::aws_smithy_async::rt::sleep::Sleep;
1429
1430pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1431 let mut configured_plugins = ::std::vec::Vec::new();
1432 ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1433 #[cfg(feature = "behavior-version-latest")]
1434 {
1435 if config.behavior_version.is_none() {
1436 config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1437 }
1438 }
1439
1440 let default_retry_partition = "s3";
1441 let default_retry_partition = match config.region() {
1442 Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{}", region)),
1443 None => ::std::borrow::Cow::from(default_retry_partition),
1444 };
1445
1446 let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1447 // defaults
1448 .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1449 ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1450 .with_retry_partition_name(default_retry_partition)
1451 .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."))
1452 ))
1453 // user config
1454 .with_client_plugin(
1455 ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1456 .with_config(config.config.clone())
1457 .with_runtime_components(config.runtime_components.clone())
1458 )
1459 // codegen config
1460 .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1461 .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new());
1462
1463 plugins = plugins.with_client_plugin(crate::s3_express::runtime_plugin::S3ExpressRuntimePlugin::new(
1464 config.config.load::<crate::config::DisableS3ExpressSessionAuth>().cloned(),
1465 ));
1466
1467 for plugin in configured_plugins {
1468 plugins = plugins.with_client_plugin(plugin);
1469 }
1470 plugins
1471}
1472
1473pub use ::aws_smithy_types::config_bag::FrozenLayer;
1474
1475pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1476
1477pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1478
1479pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1480
1481pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1482
1483pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1484
1485pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1486
1487pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1488
1489pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1490
1491pub use ::aws_smithy_types::checksum_config::ResponseChecksumValidation;
1492
1493pub use ::aws_smithy_types::checksum_config::RequestChecksumCalculation;
1494
1495pub use ::aws_types::region::Region;
1496
1497pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1498
1499#[derive(Debug, Clone)]
1500pub(crate) struct ForcePathStyle(pub(crate) bool);
1501impl ::aws_smithy_types::config_bag::Storable for ForcePathStyle {
1502 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1503}
1504
1505#[derive(Debug, Clone)]
1506pub(crate) struct UseArnRegion(pub(crate) bool);
1507impl ::aws_smithy_types::config_bag::Storable for UseArnRegion {
1508 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1509}
1510
1511#[derive(Debug, Clone)]
1512pub(crate) struct DisableMultiRegionAccessPoints(pub(crate) bool);
1513impl ::aws_smithy_types::config_bag::Storable for DisableMultiRegionAccessPoints {
1514 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1515}
1516
1517#[derive(Debug, Clone)]
1518pub(crate) struct Accelerate(pub(crate) bool);
1519impl ::aws_smithy_types::config_bag::Storable for Accelerate {
1520 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1521}
1522
1523#[derive(Debug, Clone)]
1524pub(crate) struct DisableS3ExpressSessionAuth(pub(crate) bool);
1525impl ::aws_smithy_types::config_bag::Storable for DisableS3ExpressSessionAuth {
1526 type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1527}
1528
1529pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1530
1531pub use ::aws_smithy_runtime_api::shared::IntoShared;
1532
1533pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1534
1535pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1536
1537pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1538
1539pub use ::aws_credential_types::provider::ProvideCredentials;
1540
1541pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1542
1543pub use ::aws_smithy_types::config_bag::Layer;
1544
1545/// Types needed to configure endpoint resolution.
1546pub mod endpoint;
1547
1548/// HTTP request and response types.
1549pub mod http;
1550
1551/// Types needed to implement [`Intercept`](crate::config::Intercept).
1552pub mod interceptors;
1553
1554/// Retry configuration.
1555pub mod retry;
1556
1557/// Timeout configuration.
1558pub mod timeout;