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