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