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