Skip to main content

aws_sdk_cloudfront/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 custom endpoint with region not set and fips disabled
33    #[test]
34    fn test_1() {
35        let params = crate::config::endpoint::Params::builder()
36            .endpoint("https://example.com".to_string())
37            .use_fips(false)
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://example.com");
43        assert_eq!(
44            endpoint,
45            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
46        );
47    }
48
49    /// For custom endpoint with fips enabled
50    #[test]
51    fn test_2() {
52        let params = crate::config::endpoint::Params::builder()
53            .endpoint("https://example.com".to_string())
54            .use_fips(true)
55            .build()
56            .expect("invalid params");
57        let resolver = crate::config::endpoint::DefaultResolver::new();
58        let endpoint = resolver.resolve_endpoint(&params);
59        let error = endpoint
60            .expect_err("expected error: Invalid Configuration: FIPS and custom endpoint are not supported [For custom endpoint with fips enabled]");
61        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
62    }
63
64    /// For custom endpoint with fips disabled and dualstack enabled
65    #[test]
66    fn test_3() {
67        let params = crate::config::endpoint::Params::builder()
68            .endpoint("https://example.com".to_string())
69            .use_fips(false)
70            .use_dual_stack(true)
71            .build()
72            .expect("invalid params");
73        let resolver = crate::config::endpoint::DefaultResolver::new();
74        let endpoint = resolver.resolve_endpoint(&params);
75        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]");
76        assert_eq!(
77            format!("{}", error),
78            "Invalid Configuration: Dualstack and custom endpoint are not supported"
79        )
80    }
81
82    /// For region us-east-1 with FIPS enabled and DualStack enabled
83    #[test]
84    fn test_4() {
85        let params = crate::config::endpoint::Params::builder()
86            .region("us-east-1".to_string())
87            .use_fips(true)
88            .use_dual_stack(true)
89            .build()
90            .expect("invalid params");
91        let resolver = crate::config::endpoint::DefaultResolver::new();
92        let endpoint = resolver.resolve_endpoint(&params);
93        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.global.api.aws");
94        assert_eq!(
95            endpoint,
96            ::aws_smithy_types::endpoint::Endpoint::builder()
97                .url("https://cloudfront-fips.global.api.aws")
98                .auth_scheme(
99                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-east-1".to_string())
100                )
101                .build()
102        );
103    }
104
105    /// For region us-east-1 with FIPS enabled and DualStack disabled
106    #[test]
107    fn test_5() {
108        let params = crate::config::endpoint::Params::builder()
109            .region("us-east-1".to_string())
110            .use_fips(true)
111            .use_dual_stack(false)
112            .build()
113            .expect("invalid params");
114        let resolver = crate::config::endpoint::DefaultResolver::new();
115        let endpoint = resolver.resolve_endpoint(&params);
116        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.amazonaws.com");
117        assert_eq!(
118            endpoint,
119            ::aws_smithy_types::endpoint::Endpoint::builder()
120                .url("https://cloudfront-fips.amazonaws.com")
121                .auth_scheme(
122                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-east-1".to_string())
123                )
124                .build()
125        );
126    }
127
128    /// For region us-east-1 with FIPS disabled and DualStack enabled
129    #[test]
130    fn test_6() {
131        let params = crate::config::endpoint::Params::builder()
132            .region("us-east-1".to_string())
133            .use_fips(false)
134            .use_dual_stack(true)
135            .build()
136            .expect("invalid params");
137        let resolver = crate::config::endpoint::DefaultResolver::new();
138        let endpoint = resolver.resolve_endpoint(&params);
139        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.global.api.aws");
140        assert_eq!(
141            endpoint,
142            ::aws_smithy_types::endpoint::Endpoint::builder()
143                .url("https://cloudfront.global.api.aws")
144                .auth_scheme(
145                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-east-1".to_string())
146                )
147                .build()
148        );
149    }
150
151    /// For region us-east-1 with FIPS disabled and DualStack disabled
152    #[test]
153    fn test_7() {
154        let params = crate::config::endpoint::Params::builder()
155            .region("us-east-1".to_string())
156            .use_fips(false)
157            .use_dual_stack(false)
158            .build()
159            .expect("invalid params");
160        let resolver = crate::config::endpoint::DefaultResolver::new();
161        let endpoint = resolver.resolve_endpoint(&params);
162        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.amazonaws.com");
163        assert_eq!(
164            endpoint,
165            ::aws_smithy_types::endpoint::Endpoint::builder()
166                .url("https://cloudfront.amazonaws.com")
167                .auth_scheme(
168                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-east-1".to_string())
169                )
170                .build()
171        );
172    }
173
174    /// For region cn-northwest-1 with FIPS enabled and DualStack enabled
175    #[test]
176    fn test_8() {
177        let params = crate::config::endpoint::Params::builder()
178            .region("cn-northwest-1".to_string())
179            .use_fips(true)
180            .use_dual_stack(true)
181            .build()
182            .expect("invalid params");
183        let resolver = crate::config::endpoint::DefaultResolver::new();
184        let endpoint = resolver.resolve_endpoint(&params);
185        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.api.amazonwebservices.com.cn");
186        assert_eq!(
187            endpoint,
188            ::aws_smithy_types::endpoint::Endpoint::builder()
189                .url("https://cloudfront-fips.api.amazonwebservices.com.cn")
190                .auth_scheme(
191                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "cn-northwest-1".to_string())
192                )
193                .build()
194        );
195    }
196
197    /// For region cn-northwest-1 with FIPS enabled and DualStack disabled
198    #[test]
199    fn test_9() {
200        let params = crate::config::endpoint::Params::builder()
201            .region("cn-northwest-1".to_string())
202            .use_fips(true)
203            .use_dual_stack(false)
204            .build()
205            .expect("invalid params");
206        let resolver = crate::config::endpoint::DefaultResolver::new();
207        let endpoint = resolver.resolve_endpoint(&params);
208        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.cn-northwest-1.amazonaws.com.cn");
209        assert_eq!(
210            endpoint,
211            ::aws_smithy_types::endpoint::Endpoint::builder()
212                .url("https://cloudfront-fips.cn-northwest-1.amazonaws.com.cn")
213                .auth_scheme(
214                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "cn-northwest-1".to_string())
215                )
216                .build()
217        );
218    }
219
220    /// For region cn-northwest-1 with FIPS disabled and DualStack enabled
221    #[test]
222    fn test_10() {
223        let params = crate::config::endpoint::Params::builder()
224            .region("cn-northwest-1".to_string())
225            .use_fips(false)
226            .use_dual_stack(true)
227            .build()
228            .expect("invalid params");
229        let resolver = crate::config::endpoint::DefaultResolver::new();
230        let endpoint = resolver.resolve_endpoint(&params);
231        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.api.amazonwebservices.com.cn");
232        assert_eq!(
233            endpoint,
234            ::aws_smithy_types::endpoint::Endpoint::builder()
235                .url("https://cloudfront.api.amazonwebservices.com.cn")
236                .auth_scheme(
237                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "cn-northwest-1".to_string())
238                )
239                .build()
240        );
241    }
242
243    /// For region cn-northwest-1 with FIPS disabled and DualStack disabled
244    #[test]
245    fn test_11() {
246        let params = crate::config::endpoint::Params::builder()
247            .region("cn-northwest-1".to_string())
248            .use_fips(false)
249            .use_dual_stack(false)
250            .build()
251            .expect("invalid params");
252        let resolver = crate::config::endpoint::DefaultResolver::new();
253        let endpoint = resolver.resolve_endpoint(&params);
254        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.cn-northwest-1.amazonaws.com.cn");
255        assert_eq!(
256            endpoint,
257            ::aws_smithy_types::endpoint::Endpoint::builder()
258                .url("https://cloudfront.cn-northwest-1.amazonaws.com.cn")
259                .auth_scheme(
260                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "cn-northwest-1".to_string())
261                )
262                .build()
263        );
264    }
265
266    /// For region eusc-de-east-1 with FIPS enabled and DualStack disabled
267    #[test]
268    fn test_12() {
269        let params = crate::config::endpoint::Params::builder()
270            .region("eusc-de-east-1".to_string())
271            .use_fips(true)
272            .use_dual_stack(false)
273            .build()
274            .expect("invalid params");
275        let resolver = crate::config::endpoint::DefaultResolver::new();
276        let endpoint = resolver.resolve_endpoint(&params);
277        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.amazonaws.eu");
278        assert_eq!(
279            endpoint,
280            ::aws_smithy_types::endpoint::Endpoint::builder()
281                .url("https://cloudfront-fips.amazonaws.eu")
282                .auth_scheme(
283                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "eusc-de-east-1".to_string())
284                )
285                .build()
286        );
287    }
288
289    /// For region eusc-de-east-1 with FIPS disabled and DualStack disabled
290    #[test]
291    fn test_13() {
292        let params = crate::config::endpoint::Params::builder()
293            .region("eusc-de-east-1".to_string())
294            .use_fips(false)
295            .use_dual_stack(false)
296            .build()
297            .expect("invalid params");
298        let resolver = crate::config::endpoint::DefaultResolver::new();
299        let endpoint = resolver.resolve_endpoint(&params);
300        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.amazonaws.eu");
301        assert_eq!(
302            endpoint,
303            ::aws_smithy_types::endpoint::Endpoint::builder()
304                .url("https://cloudfront.amazonaws.eu")
305                .auth_scheme(
306                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "eusc-de-east-1".to_string())
307                )
308                .build()
309        );
310    }
311
312    /// For region us-iso-east-1 with FIPS enabled and DualStack disabled
313    #[test]
314    fn test_14() {
315        let params = crate::config::endpoint::Params::builder()
316            .region("us-iso-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://cloudfront-fips.c2s.ic.gov");
324        assert_eq!(
325            endpoint,
326            ::aws_smithy_types::endpoint::Endpoint::builder()
327                .url("https://cloudfront-fips.c2s.ic.gov")
328                .auth_scheme(
329                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-iso-east-1".to_string())
330                )
331                .build()
332        );
333    }
334
335    /// For region us-iso-east-1 with FIPS disabled and DualStack disabled
336    #[test]
337    fn test_15() {
338        let params = crate::config::endpoint::Params::builder()
339            .region("us-iso-east-1".to_string())
340            .use_fips(false)
341            .use_dual_stack(false)
342            .build()
343            .expect("invalid params");
344        let resolver = crate::config::endpoint::DefaultResolver::new();
345        let endpoint = resolver.resolve_endpoint(&params);
346        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.c2s.ic.gov");
347        assert_eq!(
348            endpoint,
349            ::aws_smithy_types::endpoint::Endpoint::builder()
350                .url("https://cloudfront.c2s.ic.gov")
351                .auth_scheme(
352                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-iso-east-1".to_string())
353                )
354                .build()
355        );
356    }
357
358    /// For region us-isob-east-1 with FIPS enabled and DualStack disabled
359    #[test]
360    fn test_16() {
361        let params = crate::config::endpoint::Params::builder()
362            .region("us-isob-east-1".to_string())
363            .use_fips(true)
364            .use_dual_stack(false)
365            .build()
366            .expect("invalid params");
367        let resolver = crate::config::endpoint::DefaultResolver::new();
368        let endpoint = resolver.resolve_endpoint(&params);
369        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.sc2s.sgov.gov");
370        assert_eq!(
371            endpoint,
372            ::aws_smithy_types::endpoint::Endpoint::builder()
373                .url("https://cloudfront-fips.sc2s.sgov.gov")
374                .auth_scheme(
375                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-isob-east-1".to_string())
376                )
377                .build()
378        );
379    }
380
381    /// For region us-isob-east-1 with FIPS disabled and DualStack disabled
382    #[test]
383    fn test_17() {
384        let params = crate::config::endpoint::Params::builder()
385            .region("us-isob-east-1".to_string())
386            .use_fips(false)
387            .use_dual_stack(false)
388            .build()
389            .expect("invalid params");
390        let resolver = crate::config::endpoint::DefaultResolver::new();
391        let endpoint = resolver.resolve_endpoint(&params);
392        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.sc2s.sgov.gov");
393        assert_eq!(
394            endpoint,
395            ::aws_smithy_types::endpoint::Endpoint::builder()
396                .url("https://cloudfront.sc2s.sgov.gov")
397                .auth_scheme(
398                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-isob-east-1".to_string())
399                )
400                .build()
401        );
402    }
403
404    /// For region eu-isoe-west-1 with FIPS enabled and DualStack disabled
405    #[test]
406    fn test_18() {
407        let params = crate::config::endpoint::Params::builder()
408            .region("eu-isoe-west-1".to_string())
409            .use_fips(true)
410            .use_dual_stack(false)
411            .build()
412            .expect("invalid params");
413        let resolver = crate::config::endpoint::DefaultResolver::new();
414        let endpoint = resolver.resolve_endpoint(&params);
415        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.cloud.adc-e.uk");
416        assert_eq!(
417            endpoint,
418            ::aws_smithy_types::endpoint::Endpoint::builder()
419                .url("https://cloudfront-fips.cloud.adc-e.uk")
420                .auth_scheme(
421                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "eu-isoe-west-1".to_string())
422                )
423                .build()
424        );
425    }
426
427    /// For region eu-isoe-west-1 with FIPS disabled and DualStack disabled
428    #[test]
429    fn test_19() {
430        let params = crate::config::endpoint::Params::builder()
431            .region("eu-isoe-west-1".to_string())
432            .use_fips(false)
433            .use_dual_stack(false)
434            .build()
435            .expect("invalid params");
436        let resolver = crate::config::endpoint::DefaultResolver::new();
437        let endpoint = resolver.resolve_endpoint(&params);
438        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.cloud.adc-e.uk");
439        assert_eq!(
440            endpoint,
441            ::aws_smithy_types::endpoint::Endpoint::builder()
442                .url("https://cloudfront.cloud.adc-e.uk")
443                .auth_scheme(
444                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "eu-isoe-west-1".to_string())
445                )
446                .build()
447        );
448    }
449
450    /// For region us-isof-south-1 with FIPS enabled and DualStack disabled
451    #[test]
452    fn test_20() {
453        let params = crate::config::endpoint::Params::builder()
454            .region("us-isof-south-1".to_string())
455            .use_fips(true)
456            .use_dual_stack(false)
457            .build()
458            .expect("invalid params");
459        let resolver = crate::config::endpoint::DefaultResolver::new();
460        let endpoint = resolver.resolve_endpoint(&params);
461        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.csp.hci.ic.gov");
462        assert_eq!(
463            endpoint,
464            ::aws_smithy_types::endpoint::Endpoint::builder()
465                .url("https://cloudfront-fips.csp.hci.ic.gov")
466                .auth_scheme(
467                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-isof-south-1".to_string())
468                )
469                .build()
470        );
471    }
472
473    /// For region us-isof-south-1 with FIPS disabled and DualStack disabled
474    #[test]
475    fn test_21() {
476        let params = crate::config::endpoint::Params::builder()
477            .region("us-isof-south-1".to_string())
478            .use_fips(false)
479            .use_dual_stack(false)
480            .build()
481            .expect("invalid params");
482        let resolver = crate::config::endpoint::DefaultResolver::new();
483        let endpoint = resolver.resolve_endpoint(&params);
484        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.csp.hci.ic.gov");
485        assert_eq!(
486            endpoint,
487            ::aws_smithy_types::endpoint::Endpoint::builder()
488                .url("https://cloudfront.csp.hci.ic.gov")
489                .auth_scheme(
490                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-isof-south-1".to_string())
491                )
492                .build()
493        );
494    }
495
496    /// For region us-gov-west-1 with FIPS enabled and DualStack enabled
497    #[test]
498    fn test_22() {
499        let params = crate::config::endpoint::Params::builder()
500            .region("us-gov-west-1".to_string())
501            .use_fips(true)
502            .use_dual_stack(true)
503            .build()
504            .expect("invalid params");
505        let resolver = crate::config::endpoint::DefaultResolver::new();
506        let endpoint = resolver.resolve_endpoint(&params);
507        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.api.aws");
508        assert_eq!(
509            endpoint,
510            ::aws_smithy_types::endpoint::Endpoint::builder()
511                .url("https://cloudfront-fips.api.aws")
512                .auth_scheme(
513                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-gov-west-1".to_string())
514                )
515                .build()
516        );
517    }
518
519    /// For region us-gov-west-1 with FIPS enabled and DualStack disabled
520    #[test]
521    fn test_23() {
522        let params = crate::config::endpoint::Params::builder()
523            .region("us-gov-west-1".to_string())
524            .use_fips(true)
525            .use_dual_stack(false)
526            .build()
527            .expect("invalid params");
528        let resolver = crate::config::endpoint::DefaultResolver::new();
529        let endpoint = resolver.resolve_endpoint(&params);
530        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront-fips.amazonaws.com");
531        assert_eq!(
532            endpoint,
533            ::aws_smithy_types::endpoint::Endpoint::builder()
534                .url("https://cloudfront-fips.amazonaws.com")
535                .auth_scheme(
536                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-gov-west-1".to_string())
537                )
538                .build()
539        );
540    }
541
542    /// For region us-gov-west-1 with FIPS disabled and DualStack enabled
543    #[test]
544    fn test_24() {
545        let params = crate::config::endpoint::Params::builder()
546            .region("us-gov-west-1".to_string())
547            .use_fips(false)
548            .use_dual_stack(true)
549            .build()
550            .expect("invalid params");
551        let resolver = crate::config::endpoint::DefaultResolver::new();
552        let endpoint = resolver.resolve_endpoint(&params);
553        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.api.aws");
554        assert_eq!(
555            endpoint,
556            ::aws_smithy_types::endpoint::Endpoint::builder()
557                .url("https://cloudfront.api.aws")
558                .auth_scheme(
559                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-gov-west-1".to_string())
560                )
561                .build()
562        );
563    }
564
565    /// For region us-gov-west-1 with FIPS disabled and DualStack disabled
566    #[test]
567    fn test_25() {
568        let params = crate::config::endpoint::Params::builder()
569            .region("us-gov-west-1".to_string())
570            .use_fips(false)
571            .use_dual_stack(false)
572            .build()
573            .expect("invalid params");
574        let resolver = crate::config::endpoint::DefaultResolver::new();
575        let endpoint = resolver.resolve_endpoint(&params);
576        let endpoint = endpoint.expect("Expected valid endpoint: https://cloudfront.amazonaws.com");
577        assert_eq!(
578            endpoint,
579            ::aws_smithy_types::endpoint::Endpoint::builder()
580                .url("https://cloudfront.amazonaws.com")
581                .auth_scheme(
582                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 1).put("signingRegion", "us-gov-west-1".to_string())
583                )
584                .build()
585        );
586    }
587
588    /// Missing region
589    #[test]
590    fn test_26() {
591        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
592        let resolver = crate::config::endpoint::DefaultResolver::new();
593        let endpoint = resolver.resolve_endpoint(&params);
594        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
595        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
596    }
597}
598
599/// Endpoint resolver trait specific to Amazon CloudFront
600pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
601    /// Resolve an endpoint with the given parameters
602    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
603
604    /// Convert this service-specific resolver into a `SharedEndpointResolver`
605    ///
606    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
607    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
608    where
609        Self: Sized + 'static,
610    {
611        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
612    }
613}
614
615#[derive(Debug)]
616struct DowncastParams<T>(T);
617impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
618where
619    T: ResolveEndpoint,
620{
621    fn resolve_endpoint<'a>(
622        &'a self,
623        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
624    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
625        let ep = match params.get::<crate::config::endpoint::Params>() {
626            Some(params) => self.0.resolve_endpoint(params),
627            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
628        };
629        ep
630    }
631}
632
633#[derive(Debug)]
634/// The default endpoint resolver.
635pub struct DefaultResolver {
636    partition_resolver: &'static crate::endpoint_lib::partition::PartitionResolver,
637    endpoint_cache: ::arc_swap::ArcSwap<::std::option::Option<(Params, ::aws_smithy_types::endpoint::Endpoint)>>,
638}
639
640impl Default for DefaultResolver {
641    fn default() -> Self {
642        Self::new()
643    }
644}
645
646impl DefaultResolver {
647    /// Create a new DefaultResolver
648    pub fn new() -> Self {
649        Self {
650            partition_resolver: &crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER,
651            endpoint_cache: ::arc_swap::ArcSwap::from_pointee(None),
652        }
653    }
654
655    #[allow(
656        unused_variables,
657        unused_parens,
658        clippy::double_parens,
659        clippy::useless_conversion,
660        clippy::bool_comparison,
661        clippy::comparison_to_empty,
662        clippy::needless_borrow,
663        clippy::useless_asref,
664        clippy::redundant_closure_call,
665        clippy::clone_on_copy
666    )]
667    fn resolve_endpoint<'a>(
668        &'a self,
669        params: &'a crate::config::endpoint::Params,
670    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
671        let mut _diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
672        #[allow(unused_mut)]
673        let mut context = ConditionContext::default();
674
675        // Param bindings
676        let use_dual_stack = &params.use_dual_stack;
677        let use_fips = &params.use_fips;
678        let endpoint = &params.endpoint;
679        let region = &params.region;
680
681        let mut current_ref: i32 = 2;
682        loop {
683            match current_ref {
684                ref_val if ref_val >= 100_000_000 => {
685                    return match (ref_val - 100_000_000) as usize {
686                        0 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
687                            "No endpoint rule matched",
688                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
689                        1 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
690                            "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
691                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
692                        2 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
693                            "Invalid Configuration: Dualstack and custom endpoint are not supported".to_string(),
694                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
695                        3 => {
696                            let endpoint = params.endpoint.as_deref().unwrap_or_default();
697                            ::std::result::Result::Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build())
698                        }
699                        4 => ::std::result::Result::Ok(
700                            ::aws_smithy_types::endpoint::Endpoint::builder()
701                                .url("https://cloudfront.global.api.aws".to_string())
702                                .auth_scheme(
703                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
704                                        .put("signingRegion", "us-east-1"),
705                                )
706                                .build(),
707                        ),
708                        5 => ::std::result::Result::Ok(
709                            ::aws_smithy_types::endpoint::Endpoint::builder()
710                                .url("https://cloudfront-fips.global.api.aws".to_string())
711                                .auth_scheme(
712                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
713                                        .put("signingRegion", "us-east-1"),
714                                )
715                                .build(),
716                        ),
717                        6 => ::std::result::Result::Ok(
718                            ::aws_smithy_types::endpoint::Endpoint::builder()
719                                .url("https://cloudfront.cn-northwest-1.amazonaws.com.cn".to_string())
720                                .auth_scheme(
721                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
722                                        .put("signingRegion", "cn-northwest-1"),
723                                )
724                                .build(),
725                        ),
726                        7 => ::std::result::Result::Ok(
727                            ::aws_smithy_types::endpoint::Endpoint::builder()
728                                .url("https://cloudfront-fips.cn-northwest-1.amazonaws.com.cn".to_string())
729                                .auth_scheme(
730                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
731                                        .put("signingRegion", "cn-northwest-1"),
732                                )
733                                .build(),
734                        ),
735                        8 => {
736                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
737                            ::std::result::Result::Ok(
738                                ::aws_smithy_types::endpoint::Endpoint::builder()
739                                    .url({
740                                        let mut out = String::new();
741                                        out.push_str("https://cloudfront-fips.");
742                                        #[allow(clippy::needless_borrow)]
743                                        out.push_str(&partition_result.dual_stack_dns_suffix());
744                                        out
745                                    })
746                                    .auth_scheme(
747                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
748                                            .put("signingRegion", partition_result.implicit_global_region()),
749                                    )
750                                    .build(),
751                            )
752                        }
753                        9 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
754                            "FIPS and DualStack are enabled, but this partition does not support one or both".to_string(),
755                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
756                        10 => {
757                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
758                            ::std::result::Result::Ok(
759                                ::aws_smithy_types::endpoint::Endpoint::builder()
760                                    .url({
761                                        let mut out = String::new();
762                                        out.push_str("https://cloudfront-fips.");
763                                        #[allow(clippy::needless_borrow)]
764                                        out.push_str(&partition_result.dns_suffix());
765                                        out
766                                    })
767                                    .auth_scheme(
768                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
769                                            .put("signingRegion", partition_result.implicit_global_region()),
770                                    )
771                                    .build(),
772                            )
773                        }
774                        11 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
775                            "FIPS is enabled but this partition does not support FIPS".to_string(),
776                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
777                        12 => {
778                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
779                            ::std::result::Result::Ok(
780                                ::aws_smithy_types::endpoint::Endpoint::builder()
781                                    .url({
782                                        let mut out = String::new();
783                                        out.push_str("https://cloudfront.");
784                                        #[allow(clippy::needless_borrow)]
785                                        out.push_str(&partition_result.dual_stack_dns_suffix());
786                                        out
787                                    })
788                                    .auth_scheme(
789                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
790                                            .put("signingRegion", partition_result.implicit_global_region()),
791                                    )
792                                    .build(),
793                            )
794                        }
795                        13 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
796                            "DualStack is enabled but this partition does not support DualStack".to_string(),
797                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
798                        14 => {
799                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
800                            ::std::result::Result::Ok(
801                                ::aws_smithy_types::endpoint::Endpoint::builder()
802                                    .url({
803                                        let mut out = String::new();
804                                        out.push_str("https://cloudfront.");
805                                        #[allow(clippy::needless_borrow)]
806                                        out.push_str(&partition_result.dns_suffix());
807                                        out
808                                    })
809                                    .auth_scheme(
810                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
811                                            .put("signingRegion", partition_result.implicit_global_region()),
812                                    )
813                                    .build(),
814                            )
815                        }
816                        15 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
817                            "Invalid Configuration: Missing Region".to_string(),
818                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
819                        _ => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
820                            "No endpoint rule matched",
821                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
822                    };
823                }
824                1 | -1 => {
825                    return ::std::result::Result::Err(
826                        Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message("No endpoint rule matched"))
827                            as ::aws_smithy_runtime_api::box_error::BoxError,
828                    )
829                }
830                ref_val => {
831                    let is_complement = ref_val < 0;
832                    let node = &NODES[(ref_val.unsigned_abs() as usize) - 1];
833                    let condition_result = match node.condition_index {
834                        0 => endpoint.is_some(),
835                        1 => region.is_some(),
836                        2 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
837                            let partition_result = &mut context.partition_result;
838                            let partition_resolver = &self.partition_resolver;
839                            {
840                                *partition_result = partition_resolver
841                                    .resolve_partition(if let Some(param) = region { param } else { return false }, _diagnostic_collector)
842                                    .map(|inner| inner.into());
843                                partition_result.is_some()
844                            }
845                        })(&mut _diagnostic_collector),
846                        3 => (use_fips) == (&true),
847                        4 => (use_dual_stack) == (&true),
848                        5 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
849                            let partition_result = &context.partition_result;
850                            let partition_resolver = &self.partition_resolver;
851                            (if let Some(inner) = partition_result {
852                                inner.name()
853                            } else {
854                                return false;
855                            }) == ("aws")
856                        })(&mut _diagnostic_collector),
857                        6 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
858                            let partition_result = &context.partition_result;
859                            let partition_resolver = &self.partition_resolver;
860                            (if let Some(inner) = partition_result {
861                                inner.name()
862                            } else {
863                                return false;
864                            }) == ("aws-cn")
865                        })(&mut _diagnostic_collector),
866                        7 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
867                            let partition_result = &context.partition_result;
868                            let partition_resolver = &self.partition_resolver;
869                            (if let Some(inner) = partition_result {
870                                inner.supports_dual_stack()
871                            } else {
872                                return false;
873                            }) == (true)
874                        })(&mut _diagnostic_collector),
875                        8 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
876                            let partition_result = &context.partition_result;
877                            let partition_resolver = &self.partition_resolver;
878                            (if let Some(inner) = partition_result {
879                                inner.supports_fips()
880                            } else {
881                                return false;
882                            }) == (true)
883                        })(&mut _diagnostic_collector),
884                        _ => unreachable!("Invalid condition index"),
885                    };
886                    current_ref = if is_complement ^ condition_result { node.high_ref } else { node.low_ref };
887                }
888            }
889        }
890    }
891}
892
893impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
894    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
895        // Check single-entry cache (lock-free read via ArcSwap)
896        let cached = self.endpoint_cache.load();
897        if let Some((cached_params, cached_endpoint)) = cached.as_ref() {
898            if cached_params == params {
899                return ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(::std::result::Result::Ok(cached_endpoint.clone()));
900            }
901        }
902        drop(cached);
903        let result = self.resolve_endpoint(params);
904        if let ::std::result::Result::Ok(ref endpoint) = result {
905            self.endpoint_cache.store(::std::sync::Arc::new(Some((params.clone(), endpoint.clone()))));
906        }
907        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(result)
908    }
909}
910const NODES: [crate::endpoint_lib::bdd_interpreter::BddNode; 17] = [
911    crate::endpoint_lib::bdd_interpreter::BddNode {
912        condition_index: -1,
913        high_ref: 1,
914        low_ref: -1,
915    },
916    crate::endpoint_lib::bdd_interpreter::BddNode {
917        condition_index: 0,
918        high_ref: 16,
919        low_ref: 3,
920    },
921    crate::endpoint_lib::bdd_interpreter::BddNode {
922        condition_index: 1,
923        high_ref: 4,
924        low_ref: 100000015,
925    },
926    crate::endpoint_lib::bdd_interpreter::BddNode {
927        condition_index: 2,
928        high_ref: 5,
929        low_ref: 100000015,
930    },
931    crate::endpoint_lib::bdd_interpreter::BddNode {
932        condition_index: 3,
933        high_ref: 10,
934        low_ref: 6,
935    },
936    crate::endpoint_lib::bdd_interpreter::BddNode {
937        condition_index: 4,
938        high_ref: 8,
939        low_ref: 7,
940    },
941    crate::endpoint_lib::bdd_interpreter::BddNode {
942        condition_index: 6,
943        high_ref: 100000006,
944        low_ref: 100000014,
945    },
946    crate::endpoint_lib::bdd_interpreter::BddNode {
947        condition_index: 5,
948        high_ref: 100000004,
949        low_ref: 9,
950    },
951    crate::endpoint_lib::bdd_interpreter::BddNode {
952        condition_index: 7,
953        high_ref: 100000012,
954        low_ref: 100000013,
955    },
956    crate::endpoint_lib::bdd_interpreter::BddNode {
957        condition_index: 4,
958        high_ref: 13,
959        low_ref: 11,
960    },
961    crate::endpoint_lib::bdd_interpreter::BddNode {
962        condition_index: 6,
963        high_ref: 100000007,
964        low_ref: 12,
965    },
966    crate::endpoint_lib::bdd_interpreter::BddNode {
967        condition_index: 8,
968        high_ref: 100000010,
969        low_ref: 100000011,
970    },
971    crate::endpoint_lib::bdd_interpreter::BddNode {
972        condition_index: 5,
973        high_ref: 100000005,
974        low_ref: 14,
975    },
976    crate::endpoint_lib::bdd_interpreter::BddNode {
977        condition_index: 7,
978        high_ref: 15,
979        low_ref: 100000009,
980    },
981    crate::endpoint_lib::bdd_interpreter::BddNode {
982        condition_index: 8,
983        high_ref: 100000008,
984        low_ref: 100000009,
985    },
986    crate::endpoint_lib::bdd_interpreter::BddNode {
987        condition_index: 3,
988        high_ref: 100000001,
989        low_ref: 17,
990    },
991    crate::endpoint_lib::bdd_interpreter::BddNode {
992        condition_index: 4,
993        high_ref: 100000002,
994        low_ref: 100000003,
995    },
996];
997// These are all optional since they are set by conditions and will
998// all be unset when we start evaluation
999#[derive(Default)]
1000#[allow(unused_lifetimes)]
1001pub(crate) struct ConditionContext<'a> {
1002    pub(crate) partition_result: Option<crate::endpoint_lib::partition::Partition<'a>>,
1003    // Sometimes none of the members reference the lifetime, this makes it still valid
1004    phantom: std::marker::PhantomData<&'a ()>,
1005}
1006
1007#[non_exhaustive]
1008#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
1009/// Configuration parameters for resolving the correct endpoint
1010pub struct Params {
1011    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1012    pub(crate) use_dual_stack: bool,
1013    /// 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.
1014    pub(crate) use_fips: bool,
1015    /// Override the endpoint used to send this request
1016    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
1017    /// The AWS region used to dispatch the request.
1018    pub(crate) region: ::std::option::Option<::std::string::String>,
1019}
1020impl Params {
1021    /// Create a builder for [`Params`]
1022    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
1023        crate::config::endpoint::ParamsBuilder::default()
1024    }
1025    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1026    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
1027        Some(self.use_dual_stack)
1028    }
1029    /// 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.
1030    pub fn use_fips(&self) -> ::std::option::Option<bool> {
1031        Some(self.use_fips)
1032    }
1033    /// Override the endpoint used to send this request
1034    pub fn endpoint(&self) -> ::std::option::Option<&str> {
1035        self.endpoint.as_deref()
1036    }
1037    /// The AWS region used to dispatch the request.
1038    pub fn region(&self) -> ::std::option::Option<&str> {
1039        self.region.as_deref()
1040    }
1041}
1042
1043/// Builder for [`Params`]
1044#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
1045pub struct ParamsBuilder {
1046    use_dual_stack: ::std::option::Option<bool>,
1047    use_fips: ::std::option::Option<bool>,
1048    endpoint: ::std::option::Option<::std::string::String>,
1049    region: ::std::option::Option<::std::string::String>,
1050}
1051impl ParamsBuilder {
1052    /// Consume this builder, creating [`Params`].
1053    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
1054        if let Some(region) = &self.region {
1055            if !crate::endpoint_lib::host::is_valid_host_label(
1056                region.as_ref() as &str,
1057                true,
1058                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
1059            ) {
1060                return Err(crate::config::endpoint::InvalidParams::invalid_value(
1061                    "region",
1062                    "must be a valid host label",
1063                ));
1064            }
1065        };
1066        Ok(
1067            #[allow(clippy::unnecessary_lazy_evaluations)]
1068            crate::config::endpoint::Params {
1069                use_dual_stack: self
1070                    .use_dual_stack
1071                    .or_else(|| Some(false))
1072                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
1073                use_fips: self
1074                    .use_fips
1075                    .or_else(|| Some(false))
1076                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
1077                endpoint: self.endpoint,
1078                region: self.region,
1079            },
1080        )
1081    }
1082    /// Sets the value for use_dual_stack
1083    ///
1084    /// When unset, this parameter has a default value of `false`.
1085    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1086    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
1087        self.use_dual_stack = Some(value.into());
1088        self
1089    }
1090
1091    /// Sets the value for use_dual_stack
1092    ///
1093    /// When unset, this parameter has a default value of `false`.
1094    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1095    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
1096        self.use_dual_stack = param;
1097        self
1098    }
1099    /// Sets the value for use_fips
1100    ///
1101    /// When unset, this parameter has a default value of `false`.
1102    /// 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.
1103    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
1104        self.use_fips = Some(value.into());
1105        self
1106    }
1107
1108    /// Sets the value for use_fips
1109    ///
1110    /// When unset, this parameter has a default value of `false`.
1111    /// 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.
1112    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
1113        self.use_fips = param;
1114        self
1115    }
1116    /// Sets the value for endpoint
1117    ///
1118    /// Override the endpoint used to send this request
1119    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
1120        self.endpoint = Some(value.into());
1121        self
1122    }
1123
1124    /// Sets the value for endpoint
1125    ///
1126    /// Override the endpoint used to send this request
1127    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
1128        self.endpoint = param;
1129        self
1130    }
1131    /// Sets the value for region
1132    ///
1133    /// The AWS region used to dispatch the request.
1134    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
1135        self.region = Some(value.into());
1136        self
1137    }
1138
1139    /// Sets the value for region
1140    ///
1141    /// The AWS region used to dispatch the request.
1142    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
1143        self.region = param;
1144        self
1145    }
1146}
1147
1148/// An error that occurred during endpoint resolution
1149#[derive(Debug)]
1150pub struct InvalidParams {
1151    field: std::borrow::Cow<'static, str>,
1152    kind: InvalidParamsErrorKind,
1153}
1154
1155/// The kind of invalid parameter error
1156#[derive(Debug)]
1157enum InvalidParamsErrorKind {
1158    MissingField,
1159    InvalidValue { message: &'static str },
1160}
1161
1162impl InvalidParams {
1163    #[allow(dead_code)]
1164    fn missing(field: &'static str) -> Self {
1165        Self {
1166            field: field.into(),
1167            kind: InvalidParamsErrorKind::MissingField,
1168        }
1169    }
1170
1171    #[allow(dead_code)]
1172    fn invalid_value(field: &'static str, message: &'static str) -> Self {
1173        Self {
1174            field: field.into(),
1175            kind: InvalidParamsErrorKind::InvalidValue { message },
1176        }
1177    }
1178}
1179
1180impl std::fmt::Display for InvalidParams {
1181    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1182        match self.kind {
1183            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
1184            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
1185        }
1186    }
1187}
1188
1189impl std::error::Error for InvalidParams {}