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