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        clippy::single_char_add_str
667    )]
668    fn resolve_endpoint<'a>(
669        &'a self,
670        params: &'a crate::config::endpoint::Params,
671    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
672        let mut _diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
673        #[allow(unused_mut)]
674        let mut context = ConditionContext::default();
675
676        // Param bindings
677        let use_dual_stack = &params.use_dual_stack;
678        let use_fips = &params.use_fips;
679        let endpoint = &params.endpoint;
680        let region = &params.region;
681
682        let mut current_ref: i32 = 2;
683        loop {
684            match current_ref {
685                ref_val if ref_val >= 100_000_000 => {
686                    return match (ref_val - 100_000_000) as usize {
687                        0 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
688                            "No endpoint rule matched",
689                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
690                        1 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
691                            "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
692                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
693                        2 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
694                            "Invalid Configuration: Dualstack and custom endpoint are not supported".to_string(),
695                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
696                        3 => {
697                            let endpoint = params.endpoint.as_deref().unwrap_or_default();
698                            ::std::result::Result::Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build())
699                        }
700                        4 => ::std::result::Result::Ok(
701                            ::aws_smithy_types::endpoint::Endpoint::builder()
702                                .url("https://cloudfront.global.api.aws".to_string())
703                                .auth_scheme(
704                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
705                                        .put("signingRegion", "us-east-1"),
706                                )
707                                .build(),
708                        ),
709                        5 => ::std::result::Result::Ok(
710                            ::aws_smithy_types::endpoint::Endpoint::builder()
711                                .url("https://cloudfront-fips.global.api.aws".to_string())
712                                .auth_scheme(
713                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
714                                        .put("signingRegion", "us-east-1"),
715                                )
716                                .build(),
717                        ),
718                        6 => ::std::result::Result::Ok(
719                            ::aws_smithy_types::endpoint::Endpoint::builder()
720                                .url("https://cloudfront.cn-northwest-1.amazonaws.com.cn".to_string())
721                                .auth_scheme(
722                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
723                                        .put("signingRegion", "cn-northwest-1"),
724                                )
725                                .build(),
726                        ),
727                        7 => ::std::result::Result::Ok(
728                            ::aws_smithy_types::endpoint::Endpoint::builder()
729                                .url("https://cloudfront-fips.cn-northwest-1.amazonaws.com.cn".to_string())
730                                .auth_scheme(
731                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
732                                        .put("signingRegion", "cn-northwest-1"),
733                                )
734                                .build(),
735                        ),
736                        8 => {
737                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
738                            ::std::result::Result::Ok(
739                                ::aws_smithy_types::endpoint::Endpoint::builder()
740                                    .url({
741                                        let mut out = String::new();
742                                        out.push_str("https://cloudfront-fips.");
743                                        #[allow(clippy::needless_borrow)]
744                                        out.push_str(&partition_result.dual_stack_dns_suffix());
745                                        out
746                                    })
747                                    .auth_scheme(
748                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
749                                            .put("signingRegion", partition_result.implicit_global_region()),
750                                    )
751                                    .build(),
752                            )
753                        }
754                        9 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
755                            "FIPS and DualStack are enabled, but this partition does not support one or both".to_string(),
756                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
757                        10 => {
758                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
759                            ::std::result::Result::Ok(
760                                ::aws_smithy_types::endpoint::Endpoint::builder()
761                                    .url({
762                                        let mut out = String::new();
763                                        out.push_str("https://cloudfront-fips.");
764                                        #[allow(clippy::needless_borrow)]
765                                        out.push_str(&partition_result.dns_suffix());
766                                        out
767                                    })
768                                    .auth_scheme(
769                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
770                                            .put("signingRegion", partition_result.implicit_global_region()),
771                                    )
772                                    .build(),
773                            )
774                        }
775                        11 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
776                            "FIPS is enabled but this partition does not support FIPS".to_string(),
777                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
778                        12 => {
779                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
780                            ::std::result::Result::Ok(
781                                ::aws_smithy_types::endpoint::Endpoint::builder()
782                                    .url({
783                                        let mut out = String::new();
784                                        out.push_str("https://cloudfront.");
785                                        #[allow(clippy::needless_borrow)]
786                                        out.push_str(&partition_result.dual_stack_dns_suffix());
787                                        out
788                                    })
789                                    .auth_scheme(
790                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
791                                            .put("signingRegion", partition_result.implicit_global_region()),
792                                    )
793                                    .build(),
794                            )
795                        }
796                        13 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
797                            "DualStack is enabled but this partition does not support DualStack".to_string(),
798                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
799                        14 => {
800                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
801                            ::std::result::Result::Ok(
802                                ::aws_smithy_types::endpoint::Endpoint::builder()
803                                    .url({
804                                        let mut out = String::new();
805                                        out.push_str("https://cloudfront.");
806                                        #[allow(clippy::needless_borrow)]
807                                        out.push_str(&partition_result.dns_suffix());
808                                        out
809                                    })
810                                    .auth_scheme(
811                                        ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 1)
812                                            .put("signingRegion", partition_result.implicit_global_region()),
813                                    )
814                                    .build(),
815                            )
816                        }
817                        15 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
818                            "Invalid Configuration: Missing Region".to_string(),
819                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
820                        _ => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
821                            "No endpoint rule matched",
822                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
823                    };
824                }
825                1 | -1 => {
826                    return ::std::result::Result::Err(
827                        Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message("No endpoint rule matched"))
828                            as ::aws_smithy_runtime_api::box_error::BoxError,
829                    )
830                }
831                ref_val => {
832                    let is_complement = ref_val < 0;
833                    let node = &NODES[(ref_val.unsigned_abs() as usize) - 1];
834                    let condition_result = match node.condition_index {
835                        0 => endpoint.is_some(),
836                        1 => region.is_some(),
837                        2 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
838                            let partition_result = &mut context.partition_result;
839                            let partition_resolver = &self.partition_resolver;
840                            {
841                                *partition_result = partition_resolver
842                                    .resolve_partition(if let Some(param) = region { param } else { return false }, _diagnostic_collector)
843                                    .map(|inner| inner.into());
844                                partition_result.is_some()
845                            }
846                        })(&mut _diagnostic_collector),
847                        3 => (use_fips) == (&true),
848                        4 => (use_dual_stack) == (&true),
849                        5 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
850                            let partition_result = &context.partition_result;
851                            let partition_resolver = &self.partition_resolver;
852                            (if let Some(inner) = partition_result {
853                                inner.name()
854                            } else {
855                                return false;
856                            }) == ("aws")
857                        })(&mut _diagnostic_collector),
858                        6 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
859                            let partition_result = &context.partition_result;
860                            let partition_resolver = &self.partition_resolver;
861                            (if let Some(inner) = partition_result {
862                                inner.name()
863                            } else {
864                                return false;
865                            }) == ("aws-cn")
866                        })(&mut _diagnostic_collector),
867                        7 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
868                            let partition_result = &context.partition_result;
869                            let partition_resolver = &self.partition_resolver;
870                            (if let Some(inner) = partition_result {
871                                inner.supports_dual_stack()
872                            } else {
873                                return false;
874                            }) == (true)
875                        })(&mut _diagnostic_collector),
876                        8 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
877                            let partition_result = &context.partition_result;
878                            let partition_resolver = &self.partition_resolver;
879                            (if let Some(inner) = partition_result {
880                                inner.supports_fips()
881                            } else {
882                                return false;
883                            }) == (true)
884                        })(&mut _diagnostic_collector),
885                        _ => unreachable!("Invalid condition index"),
886                    };
887                    current_ref = if is_complement ^ condition_result { node.high_ref } else { node.low_ref };
888                }
889            }
890        }
891    }
892}
893
894impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
895    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
896        // Check single-entry cache (lock-free read via ArcSwap)
897        let cached = self.endpoint_cache.load();
898        if let Some((cached_params, cached_endpoint)) = cached.as_ref() {
899            if cached_params == params {
900                return ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(::std::result::Result::Ok(cached_endpoint.clone()));
901            }
902        }
903        drop(cached);
904        let result = self.resolve_endpoint(params);
905        if let ::std::result::Result::Ok(ref endpoint) = result {
906            self.endpoint_cache.store(::std::sync::Arc::new(Some((params.clone(), endpoint.clone()))));
907        }
908        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(result)
909    }
910}
911const NODES: [crate::endpoint_lib::bdd_interpreter::BddNode; 17] = [
912    crate::endpoint_lib::bdd_interpreter::BddNode {
913        condition_index: -1,
914        high_ref: 1,
915        low_ref: -1,
916    },
917    crate::endpoint_lib::bdd_interpreter::BddNode {
918        condition_index: 0,
919        high_ref: 16,
920        low_ref: 3,
921    },
922    crate::endpoint_lib::bdd_interpreter::BddNode {
923        condition_index: 1,
924        high_ref: 4,
925        low_ref: 100000015,
926    },
927    crate::endpoint_lib::bdd_interpreter::BddNode {
928        condition_index: 2,
929        high_ref: 5,
930        low_ref: 100000015,
931    },
932    crate::endpoint_lib::bdd_interpreter::BddNode {
933        condition_index: 3,
934        high_ref: 10,
935        low_ref: 6,
936    },
937    crate::endpoint_lib::bdd_interpreter::BddNode {
938        condition_index: 4,
939        high_ref: 8,
940        low_ref: 7,
941    },
942    crate::endpoint_lib::bdd_interpreter::BddNode {
943        condition_index: 6,
944        high_ref: 100000006,
945        low_ref: 100000014,
946    },
947    crate::endpoint_lib::bdd_interpreter::BddNode {
948        condition_index: 5,
949        high_ref: 100000004,
950        low_ref: 9,
951    },
952    crate::endpoint_lib::bdd_interpreter::BddNode {
953        condition_index: 7,
954        high_ref: 100000012,
955        low_ref: 100000013,
956    },
957    crate::endpoint_lib::bdd_interpreter::BddNode {
958        condition_index: 4,
959        high_ref: 13,
960        low_ref: 11,
961    },
962    crate::endpoint_lib::bdd_interpreter::BddNode {
963        condition_index: 6,
964        high_ref: 100000007,
965        low_ref: 12,
966    },
967    crate::endpoint_lib::bdd_interpreter::BddNode {
968        condition_index: 8,
969        high_ref: 100000010,
970        low_ref: 100000011,
971    },
972    crate::endpoint_lib::bdd_interpreter::BddNode {
973        condition_index: 5,
974        high_ref: 100000005,
975        low_ref: 14,
976    },
977    crate::endpoint_lib::bdd_interpreter::BddNode {
978        condition_index: 7,
979        high_ref: 15,
980        low_ref: 100000009,
981    },
982    crate::endpoint_lib::bdd_interpreter::BddNode {
983        condition_index: 8,
984        high_ref: 100000008,
985        low_ref: 100000009,
986    },
987    crate::endpoint_lib::bdd_interpreter::BddNode {
988        condition_index: 3,
989        high_ref: 100000001,
990        low_ref: 17,
991    },
992    crate::endpoint_lib::bdd_interpreter::BddNode {
993        condition_index: 4,
994        high_ref: 100000002,
995        low_ref: 100000003,
996    },
997];
998// These are all optional since they are set by conditions and will
999// all be unset when we start evaluation
1000#[derive(Default)]
1001#[allow(unused_lifetimes)]
1002pub(crate) struct ConditionContext<'a> {
1003    pub(crate) partition_result: Option<crate::endpoint_lib::partition::Partition<'a>>,
1004    // Sometimes none of the members reference the lifetime, this makes it still valid
1005    phantom: std::marker::PhantomData<&'a ()>,
1006}
1007
1008#[non_exhaustive]
1009#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
1010/// Configuration parameters for resolving the correct endpoint
1011pub struct Params {
1012    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1013    pub(crate) use_dual_stack: bool,
1014    /// 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.
1015    pub(crate) use_fips: bool,
1016    /// Override the endpoint used to send this request
1017    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
1018    /// The AWS region used to dispatch the request.
1019    pub(crate) region: ::std::option::Option<::std::string::String>,
1020}
1021impl Params {
1022    /// Create a builder for [`Params`]
1023    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
1024        crate::config::endpoint::ParamsBuilder::default()
1025    }
1026    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1027    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
1028        Some(self.use_dual_stack)
1029    }
1030    /// 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.
1031    pub fn use_fips(&self) -> ::std::option::Option<bool> {
1032        Some(self.use_fips)
1033    }
1034    /// Override the endpoint used to send this request
1035    pub fn endpoint(&self) -> ::std::option::Option<&str> {
1036        self.endpoint.as_deref()
1037    }
1038    /// The AWS region used to dispatch the request.
1039    pub fn region(&self) -> ::std::option::Option<&str> {
1040        self.region.as_deref()
1041    }
1042}
1043
1044/// Builder for [`Params`]
1045#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
1046pub struct ParamsBuilder {
1047    use_dual_stack: ::std::option::Option<bool>,
1048    use_fips: ::std::option::Option<bool>,
1049    endpoint: ::std::option::Option<::std::string::String>,
1050    region: ::std::option::Option<::std::string::String>,
1051}
1052impl ParamsBuilder {
1053    /// Consume this builder, creating [`Params`].
1054    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
1055        if let Some(region) = &self.region {
1056            if !crate::endpoint_lib::host::is_valid_host_label(
1057                region.as_ref() as &str,
1058                true,
1059                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
1060            ) {
1061                return Err(crate::config::endpoint::InvalidParams::invalid_value(
1062                    "region",
1063                    "must be a valid host label",
1064                ));
1065            }
1066        };
1067        Ok(
1068            #[allow(clippy::unnecessary_lazy_evaluations)]
1069            crate::config::endpoint::Params {
1070                use_dual_stack: self
1071                    .use_dual_stack
1072                    .or_else(|| Some(false))
1073                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
1074                use_fips: self
1075                    .use_fips
1076                    .or_else(|| Some(false))
1077                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
1078                endpoint: self.endpoint,
1079                region: self.region,
1080            },
1081        )
1082    }
1083    /// Sets the value for use_dual_stack
1084    ///
1085    /// When unset, this parameter has a default value of `false`.
1086    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1087    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
1088        self.use_dual_stack = Some(value.into());
1089        self
1090    }
1091
1092    /// Sets the value for use_dual_stack
1093    ///
1094    /// When unset, this parameter has a default value of `false`.
1095    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1096    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
1097        self.use_dual_stack = param;
1098        self
1099    }
1100    /// Sets the value for use_fips
1101    ///
1102    /// When unset, this parameter has a default value of `false`.
1103    /// 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.
1104    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
1105        self.use_fips = Some(value.into());
1106        self
1107    }
1108
1109    /// Sets the value for use_fips
1110    ///
1111    /// When unset, this parameter has a default value of `false`.
1112    /// 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.
1113    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
1114        self.use_fips = param;
1115        self
1116    }
1117    /// Sets the value for endpoint
1118    ///
1119    /// Override the endpoint used to send this request
1120    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
1121        self.endpoint = Some(value.into());
1122        self
1123    }
1124
1125    /// Sets the value for endpoint
1126    ///
1127    /// Override the endpoint used to send this request
1128    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
1129        self.endpoint = param;
1130        self
1131    }
1132    /// Sets the value for region
1133    ///
1134    /// The AWS region used to dispatch the request.
1135    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
1136        self.region = Some(value.into());
1137        self
1138    }
1139
1140    /// Sets the value for region
1141    ///
1142    /// The AWS region used to dispatch the request.
1143    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
1144        self.region = param;
1145        self
1146    }
1147}
1148
1149/// An error that occurred during endpoint resolution
1150#[derive(Debug)]
1151pub struct InvalidParams {
1152    field: std::borrow::Cow<'static, str>,
1153    kind: InvalidParamsErrorKind,
1154}
1155
1156/// The kind of invalid parameter error
1157#[derive(Debug)]
1158enum InvalidParamsErrorKind {
1159    MissingField,
1160    InvalidValue { message: &'static str },
1161}
1162
1163impl InvalidParams {
1164    #[allow(dead_code)]
1165    fn missing(field: &'static str) -> Self {
1166        Self {
1167            field: field.into(),
1168            kind: InvalidParamsErrorKind::MissingField,
1169        }
1170    }
1171
1172    #[allow(dead_code)]
1173    fn invalid_value(field: &'static str, message: &'static str) -> Self {
1174        Self {
1175            field: field.into(),
1176            kind: InvalidParamsErrorKind::InvalidValue { message },
1177        }
1178    }
1179}
1180
1181impl std::fmt::Display for InvalidParams {
1182    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1183        match self.kind {
1184            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
1185            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
1186        }
1187    }
1188}
1189
1190impl std::error::Error for InvalidParams {}