Skip to main content

aws_sdk_eksauth/config/
endpoint.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use ::aws_smithy_runtime_api::client::endpoint::EndpointFuture;
3pub use ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver;
4pub use ::aws_smithy_types::endpoint::Endpoint;
5
6/// Interceptor that tracks endpoint override business metric.
7#[derive(Debug, Default)]
8pub(crate) struct EndpointOverrideFeatureTrackerInterceptor;
9
10#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
11impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOverrideFeatureTrackerInterceptor {
12    fn name(&self) -> &'static str {
13        "EndpointOverrideFeatureTrackerInterceptor"
14    }
15
16    fn read_before_execution(
17        &self,
18        _context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_>,
19        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
20    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
21        if cfg.load::<::aws_types::endpoint_config::EndpointUrl>().is_some() {
22            cfg.interceptor_state()
23                .store_append(::aws_runtime::sdk_feature::AwsSdkFeature::EndpointOverride);
24        }
25        ::std::result::Result::Ok(())
26    }
27}
28
29#[cfg(test)]
30mod test {
31
32    /// For region us-east-1 with FIPS enabled and DualStack enabled
33    #[test]
34    fn test_1() {
35        let params = crate::config::endpoint::Params::builder()
36            .region("us-east-1".to_string())
37            .use_fips(true)
38            .build()
39            .expect("invalid params");
40        let resolver = crate::config::endpoint::DefaultResolver::new();
41        let endpoint = resolver.resolve_endpoint(&params);
42        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth-fips.us-east-1.api.aws");
43        assert_eq!(
44            endpoint,
45            ::aws_smithy_types::endpoint::Endpoint::builder()
46                .url("https://eks-auth-fips.us-east-1.api.aws")
47                .build()
48        );
49    }
50
51    /// For region us-east-1 with FIPS disabled and DualStack enabled
52    #[test]
53    fn test_2() {
54        let params = crate::config::endpoint::Params::builder()
55            .region("us-east-1".to_string())
56            .use_fips(false)
57            .build()
58            .expect("invalid params");
59        let resolver = crate::config::endpoint::DefaultResolver::new();
60        let endpoint = resolver.resolve_endpoint(&params);
61        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth.us-east-1.api.aws");
62        assert_eq!(
63            endpoint,
64            ::aws_smithy_types::endpoint::Endpoint::builder()
65                .url("https://eks-auth.us-east-1.api.aws")
66                .build()
67        );
68    }
69
70    /// For region cn-north-1 with FIPS enabled and DualStack enabled
71    #[test]
72    fn test_3() {
73        let params = crate::config::endpoint::Params::builder()
74            .region("cn-north-1".to_string())
75            .use_fips(true)
76            .build()
77            .expect("invalid params");
78        let resolver = crate::config::endpoint::DefaultResolver::new();
79        let endpoint = resolver.resolve_endpoint(&params);
80        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth-fips.cn-north-1.api.amazonwebservices.com.cn");
81        assert_eq!(
82            endpoint,
83            ::aws_smithy_types::endpoint::Endpoint::builder()
84                .url("https://eks-auth-fips.cn-north-1.api.amazonwebservices.com.cn")
85                .build()
86        );
87    }
88
89    /// For region cn-north-1 with FIPS disabled and DualStack enabled
90    #[test]
91    fn test_4() {
92        let params = crate::config::endpoint::Params::builder()
93            .region("cn-north-1".to_string())
94            .use_fips(false)
95            .build()
96            .expect("invalid params");
97        let resolver = crate::config::endpoint::DefaultResolver::new();
98        let endpoint = resolver.resolve_endpoint(&params);
99        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth.cn-north-1.api.amazonwebservices.com.cn");
100        assert_eq!(
101            endpoint,
102            ::aws_smithy_types::endpoint::Endpoint::builder()
103                .url("https://eks-auth.cn-north-1.api.amazonwebservices.com.cn")
104                .build()
105        );
106    }
107
108    /// For region us-gov-east-1 with FIPS enabled and DualStack enabled
109    #[test]
110    fn test_5() {
111        let params = crate::config::endpoint::Params::builder()
112            .region("us-gov-east-1".to_string())
113            .use_fips(true)
114            .build()
115            .expect("invalid params");
116        let resolver = crate::config::endpoint::DefaultResolver::new();
117        let endpoint = resolver.resolve_endpoint(&params);
118        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth-fips.us-gov-east-1.api.aws");
119        assert_eq!(
120            endpoint,
121            ::aws_smithy_types::endpoint::Endpoint::builder()
122                .url("https://eks-auth-fips.us-gov-east-1.api.aws")
123                .build()
124        );
125    }
126
127    /// For region us-gov-east-1 with FIPS disabled and DualStack enabled
128    #[test]
129    fn test_6() {
130        let params = crate::config::endpoint::Params::builder()
131            .region("us-gov-east-1".to_string())
132            .use_fips(false)
133            .build()
134            .expect("invalid params");
135        let resolver = crate::config::endpoint::DefaultResolver::new();
136        let endpoint = resolver.resolve_endpoint(&params);
137        let endpoint = endpoint.expect("Expected valid endpoint: https://eks-auth.us-gov-east-1.api.aws");
138        assert_eq!(
139            endpoint,
140            ::aws_smithy_types::endpoint::Endpoint::builder()
141                .url("https://eks-auth.us-gov-east-1.api.aws")
142                .build()
143        );
144    }
145
146    /// For custom endpoint with region set and fips disabled and dualstack disabled
147    #[test]
148    fn test_7() {
149        let params = crate::config::endpoint::Params::builder()
150            .region("us-east-1".to_string())
151            .use_fips(false)
152            .endpoint("https://example.com".to_string())
153            .build()
154            .expect("invalid params");
155        let resolver = crate::config::endpoint::DefaultResolver::new();
156        let endpoint = resolver.resolve_endpoint(&params);
157        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
158        assert_eq!(
159            endpoint,
160            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
161        );
162    }
163
164    /// For custom endpoint with region not set and fips disabled and dualstack disabled
165    #[test]
166    fn test_8() {
167        let params = crate::config::endpoint::Params::builder()
168            .use_fips(false)
169            .endpoint("https://example.com".to_string())
170            .build()
171            .expect("invalid params");
172        let resolver = crate::config::endpoint::DefaultResolver::new();
173        let endpoint = resolver.resolve_endpoint(&params);
174        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
175        assert_eq!(
176            endpoint,
177            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
178        );
179    }
180
181    /// For custom endpoint with fips enabled and dualstack disabled
182    #[test]
183    fn test_9() {
184        let params = crate::config::endpoint::Params::builder()
185            .region("us-east-1".to_string())
186            .use_fips(true)
187            .endpoint("https://example.com".to_string())
188            .build()
189            .expect("invalid params");
190        let resolver = crate::config::endpoint::DefaultResolver::new();
191        let endpoint = resolver.resolve_endpoint(&params);
192        let error = endpoint.expect_err("expected error: Invalid Configuration: FIPS and custom endpoint are not supported [For custom endpoint with fips enabled and dualstack disabled]");
193        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
194    }
195
196    /// Missing region
197    #[test]
198    fn test_10() {
199        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
200        let resolver = crate::config::endpoint::DefaultResolver::new();
201        let endpoint = resolver.resolve_endpoint(&params);
202        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
203        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
204    }
205}
206
207/// Endpoint resolver trait specific to Amazon EKS Auth
208pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
209    /// Resolve an endpoint with the given parameters
210    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
211
212    /// Convert this service-specific resolver into a `SharedEndpointResolver`
213    ///
214    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
215    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
216    where
217        Self: Sized + 'static,
218    {
219        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
220    }
221}
222
223#[derive(Debug)]
224struct DowncastParams<T>(T);
225impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
226where
227    T: ResolveEndpoint,
228{
229    fn resolve_endpoint<'a>(
230        &'a self,
231        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
232    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
233        let ep = match params.get::<crate::config::endpoint::Params>() {
234            Some(params) => self.0.resolve_endpoint(params),
235            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
236        };
237        ep
238    }
239}
240
241#[derive(Debug)]
242/// The default endpoint resolver.
243pub struct DefaultResolver {
244    partition_resolver: &'static crate::endpoint_lib::partition::PartitionResolver,
245    endpoint_cache: ::arc_swap::ArcSwap<::std::option::Option<(Params, ::aws_smithy_types::endpoint::Endpoint)>>,
246}
247
248impl Default for DefaultResolver {
249    fn default() -> Self {
250        Self::new()
251    }
252}
253
254impl DefaultResolver {
255    /// Create a new DefaultResolver
256    pub fn new() -> Self {
257        Self {
258            partition_resolver: &crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER,
259            endpoint_cache: ::arc_swap::ArcSwap::from_pointee(None),
260        }
261    }
262
263    #[allow(
264        unused_variables,
265        unused_parens,
266        clippy::double_parens,
267        clippy::useless_conversion,
268        clippy::bool_comparison,
269        clippy::comparison_to_empty,
270        clippy::needless_borrow,
271        clippy::useless_asref,
272        clippy::redundant_closure_call,
273        clippy::clone_on_copy
274    )]
275    fn resolve_endpoint<'a>(
276        &'a self,
277        params: &'a crate::config::endpoint::Params,
278    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
279        let mut _diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
280        #[allow(unused_mut)]
281        let mut context = ConditionContext::default();
282
283        // Param bindings
284        let region = &params.region;
285        let use_fips = &params.use_fips;
286        let endpoint = &params.endpoint;
287
288        let mut current_ref: i32 = 2;
289        loop {
290            match current_ref {
291                ref_val if ref_val >= 100_000_000 => {
292                    return match (ref_val - 100_000_000) as usize {
293                        0 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
294                            "No endpoint rule matched",
295                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
296                        1 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
297                            "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
298                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
299                        2 => {
300                            let endpoint = params.endpoint.as_deref().unwrap_or_default();
301                            ::std::result::Result::Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build())
302                        }
303                        3 => {
304                            let region = params.region.as_deref().unwrap_or_default();
305                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
306                            ::std::result::Result::Ok(
307                                ::aws_smithy_types::endpoint::Endpoint::builder()
308                                    .url({
309                                        let mut out = String::new();
310                                        out.push_str("https://eks-auth-fips.");
311                                        #[allow(clippy::needless_borrow)]
312                                        out.push_str(&region.as_ref());
313                                        out.push('.');
314                                        #[allow(clippy::needless_borrow)]
315                                        out.push_str(&partition_result.dual_stack_dns_suffix());
316                                        out
317                                    })
318                                    .build(),
319                            )
320                        }
321                        4 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
322                            "FIPS is enabled but this partition does not support FIPS".to_string(),
323                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
324                        5 => {
325                            let region = params.region.as_deref().unwrap_or_default();
326                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
327                            ::std::result::Result::Ok(
328                                ::aws_smithy_types::endpoint::Endpoint::builder()
329                                    .url({
330                                        let mut out = String::new();
331                                        out.push_str("https://eks-auth.");
332                                        #[allow(clippy::needless_borrow)]
333                                        out.push_str(&region.as_ref());
334                                        out.push('.');
335                                        #[allow(clippy::needless_borrow)]
336                                        out.push_str(&partition_result.dual_stack_dns_suffix());
337                                        out
338                                    })
339                                    .build(),
340                            )
341                        }
342                        6 => {
343                            let region = params.region.as_deref().unwrap_or_default();
344                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
345                            ::std::result::Result::Ok(
346                                ::aws_smithy_types::endpoint::Endpoint::builder()
347                                    .url({
348                                        let mut out = String::new();
349                                        out.push_str("https://eks-auth-fips.");
350                                        #[allow(clippy::needless_borrow)]
351                                        out.push_str(&region.as_ref());
352                                        out.push('.');
353                                        #[allow(clippy::needless_borrow)]
354                                        out.push_str(&partition_result.dns_suffix());
355                                        out
356                                    })
357                                    .build(),
358                            )
359                        }
360                        7 => {
361                            let region = params.region.as_deref().unwrap_or_default();
362                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
363                            ::std::result::Result::Ok(
364                                ::aws_smithy_types::endpoint::Endpoint::builder()
365                                    .url({
366                                        let mut out = String::new();
367                                        out.push_str("https://eks-auth.");
368                                        #[allow(clippy::needless_borrow)]
369                                        out.push_str(&region.as_ref());
370                                        out.push('.');
371                                        #[allow(clippy::needless_borrow)]
372                                        out.push_str(&partition_result.dns_suffix());
373                                        out
374                                    })
375                                    .build(),
376                            )
377                        }
378                        8 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
379                            "Invalid Configuration: Missing Region".to_string(),
380                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
381                        _ => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
382                            "No endpoint rule matched",
383                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
384                    };
385                }
386                1 | -1 => {
387                    return ::std::result::Result::Err(
388                        Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message("No endpoint rule matched"))
389                            as ::aws_smithy_runtime_api::box_error::BoxError,
390                    )
391                }
392                ref_val => {
393                    let is_complement = ref_val < 0;
394                    let node = &NODES[(ref_val.unsigned_abs() as usize) - 1];
395                    let condition_result = match node.condition_index {
396                        0 => endpoint.is_some(),
397                        1 => region.is_some(),
398                        2 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
399                            let partition_result = &mut context.partition_result;
400                            let partition_resolver = &self.partition_resolver;
401                            {
402                                *partition_result = partition_resolver
403                                    .resolve_partition(if let Some(param) = region { param } else { return false }, _diagnostic_collector)
404                                    .map(|inner| inner.into());
405                                partition_result.is_some()
406                            }
407                        })(&mut _diagnostic_collector),
408                        3 => (use_fips) == (&true),
409                        4 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
410                            let partition_result = &context.partition_result;
411                            let partition_resolver = &self.partition_resolver;
412                            (if let Some(inner) = partition_result {
413                                inner.supports_fips()
414                            } else {
415                                return false;
416                            }) == (true)
417                        })(&mut _diagnostic_collector),
418                        5 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
419                            let partition_result = &context.partition_result;
420                            let partition_resolver = &self.partition_resolver;
421                            (if let Some(inner) = partition_result {
422                                inner.supports_dual_stack()
423                            } else {
424                                return false;
425                            }) == (true)
426                        })(&mut _diagnostic_collector),
427                        _ => unreachable!("Invalid condition index"),
428                    };
429                    current_ref = if is_complement ^ condition_result { node.high_ref } else { node.low_ref };
430                }
431            }
432        }
433    }
434}
435
436impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
437    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
438        // Check single-entry cache (lock-free read via ArcSwap)
439        let cached = self.endpoint_cache.load();
440        if let Some((cached_params, cached_endpoint)) = cached.as_ref() {
441            if cached_params == params {
442                return ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(::std::result::Result::Ok(cached_endpoint.clone()));
443            }
444        }
445        drop(cached);
446        let result = self.resolve_endpoint(params);
447        if let ::std::result::Result::Ok(ref endpoint) = result {
448            self.endpoint_cache.store(::std::sync::Arc::new(Some((params.clone(), endpoint.clone()))));
449        }
450        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(result)
451    }
452}
453const NODES: [crate::endpoint_lib::bdd_interpreter::BddNode; 9] = [
454    crate::endpoint_lib::bdd_interpreter::BddNode {
455        condition_index: -1,
456        high_ref: 1,
457        low_ref: -1,
458    },
459    crate::endpoint_lib::bdd_interpreter::BddNode {
460        condition_index: 0,
461        high_ref: 9,
462        low_ref: 3,
463    },
464    crate::endpoint_lib::bdd_interpreter::BddNode {
465        condition_index: 1,
466        high_ref: 4,
467        low_ref: 100000008,
468    },
469    crate::endpoint_lib::bdd_interpreter::BddNode {
470        condition_index: 2,
471        high_ref: 5,
472        low_ref: 100000008,
473    },
474    crate::endpoint_lib::bdd_interpreter::BddNode {
475        condition_index: 3,
476        high_ref: 7,
477        low_ref: 6,
478    },
479    crate::endpoint_lib::bdd_interpreter::BddNode {
480        condition_index: 5,
481        high_ref: 100000005,
482        low_ref: 100000007,
483    },
484    crate::endpoint_lib::bdd_interpreter::BddNode {
485        condition_index: 4,
486        high_ref: 8,
487        low_ref: 100000004,
488    },
489    crate::endpoint_lib::bdd_interpreter::BddNode {
490        condition_index: 5,
491        high_ref: 100000003,
492        low_ref: 100000006,
493    },
494    crate::endpoint_lib::bdd_interpreter::BddNode {
495        condition_index: 3,
496        high_ref: 100000001,
497        low_ref: 100000002,
498    },
499];
500// These are all optional since they are set by conditions and will
501// all be unset when we start evaluation
502#[derive(Default)]
503#[allow(unused_lifetimes)]
504pub(crate) struct ConditionContext<'a> {
505    pub(crate) partition_result: Option<crate::endpoint_lib::partition::Partition<'a>>,
506    // Sometimes none of the members reference the lifetime, this makes it still valid
507    phantom: std::marker::PhantomData<&'a ()>,
508}
509
510#[non_exhaustive]
511#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
512/// Configuration parameters for resolving the correct endpoint
513pub struct Params {
514    /// The AWS region used to dispatch the request.
515    pub(crate) region: ::std::option::Option<::std::string::String>,
516    /// 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.
517    pub(crate) use_fips: bool,
518    /// Override the endpoint used to send this request
519    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
520}
521impl Params {
522    /// Create a builder for [`Params`]
523    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
524        crate::config::endpoint::ParamsBuilder::default()
525    }
526    /// The AWS region used to dispatch the request.
527    pub fn region(&self) -> ::std::option::Option<&str> {
528        self.region.as_deref()
529    }
530    /// 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.
531    pub fn use_fips(&self) -> ::std::option::Option<bool> {
532        Some(self.use_fips)
533    }
534    /// Override the endpoint used to send this request
535    pub fn endpoint(&self) -> ::std::option::Option<&str> {
536        self.endpoint.as_deref()
537    }
538}
539
540/// Builder for [`Params`]
541#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
542pub struct ParamsBuilder {
543    region: ::std::option::Option<::std::string::String>,
544    use_fips: ::std::option::Option<bool>,
545    endpoint: ::std::option::Option<::std::string::String>,
546}
547impl ParamsBuilder {
548    /// Consume this builder, creating [`Params`].
549    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
550        if let Some(region) = &self.region {
551            if !crate::endpoint_lib::host::is_valid_host_label(
552                region.as_ref() as &str,
553                true,
554                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
555            ) {
556                return Err(crate::config::endpoint::InvalidParams::invalid_value(
557                    "region",
558                    "must be a valid host label",
559                ));
560            }
561        };
562        Ok(
563            #[allow(clippy::unnecessary_lazy_evaluations)]
564            crate::config::endpoint::Params {
565                region: self.region,
566                use_fips: self
567                    .use_fips
568                    .or_else(|| Some(false))
569                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
570                endpoint: self.endpoint,
571            },
572        )
573    }
574    /// Sets the value for region
575    ///
576    /// The AWS region used to dispatch the request.
577    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
578        self.region = Some(value.into());
579        self
580    }
581
582    /// Sets the value for region
583    ///
584    /// The AWS region used to dispatch the request.
585    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
586        self.region = param;
587        self
588    }
589    /// Sets the value for use_fips
590    ///
591    /// When unset, this parameter has a default value of `false`.
592    /// 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.
593    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
594        self.use_fips = Some(value.into());
595        self
596    }
597
598    /// Sets the value for use_fips
599    ///
600    /// When unset, this parameter has a default value of `false`.
601    /// 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.
602    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
603        self.use_fips = param;
604        self
605    }
606    /// Sets the value for endpoint
607    ///
608    /// Override the endpoint used to send this request
609    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
610        self.endpoint = Some(value.into());
611        self
612    }
613
614    /// Sets the value for endpoint
615    ///
616    /// Override the endpoint used to send this request
617    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
618        self.endpoint = param;
619        self
620    }
621}
622
623/// An error that occurred during endpoint resolution
624#[derive(Debug)]
625pub struct InvalidParams {
626    field: std::borrow::Cow<'static, str>,
627    kind: InvalidParamsErrorKind,
628}
629
630/// The kind of invalid parameter error
631#[derive(Debug)]
632enum InvalidParamsErrorKind {
633    MissingField,
634    InvalidValue { message: &'static str },
635}
636
637impl InvalidParams {
638    #[allow(dead_code)]
639    fn missing(field: &'static str) -> Self {
640        Self {
641            field: field.into(),
642            kind: InvalidParamsErrorKind::MissingField,
643        }
644    }
645
646    #[allow(dead_code)]
647    fn invalid_value(field: &'static str, message: &'static str) -> Self {
648        Self {
649            field: field.into(),
650            kind: InvalidParamsErrorKind::InvalidValue { message },
651        }
652    }
653}
654
655impl std::fmt::Display for InvalidParams {
656    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
657        match self.kind {
658            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
659            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
660        }
661    }
662}
663
664impl std::error::Error for InvalidParams {}