Skip to main content

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