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