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