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