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