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