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