aws_sdk_amplify/config/
endpoint.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use ::aws_smithy_runtime_api::client::endpoint::EndpointFuture;
3pub use ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver;
4pub use ::aws_smithy_types::endpoint::Endpoint;
5
6/// Interceptor that tracks endpoint override business metric.
7#[derive(Debug, Default)]
8pub(crate) struct EndpointOverrideFeatureTrackerInterceptor;
9
10impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOverrideFeatureTrackerInterceptor {
11    fn name(&self) -> &'static str {
12        "EndpointOverrideFeatureTrackerInterceptor"
13    }
14
15    fn read_before_execution(
16        &self,
17        _context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_>,
18        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
19    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
20        if cfg.load::<::aws_types::endpoint_config::EndpointUrl>().is_some() {
21            cfg.interceptor_state()
22                .store_append(::aws_runtime::sdk_feature::AwsSdkFeature::EndpointOverride);
23        }
24        ::std::result::Result::Ok(())
25    }
26}
27
28#[cfg(test)]
29mod test {
30
31    /// For region ap-east-1 with FIPS disabled and DualStack disabled
32    #[test]
33    fn test_1() {
34        let params = crate::config::endpoint::Params::builder()
35            .region("ap-east-1".to_string())
36            .use_fips(false)
37            .use_dual_stack(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://amplify.ap-east-1.amazonaws.com");
43        assert_eq!(
44            endpoint,
45            ::aws_smithy_types::endpoint::Endpoint::builder()
46                .url("https://amplify.ap-east-1.amazonaws.com")
47                .build()
48        );
49    }
50
51    /// For region ap-northeast-1 with FIPS disabled and DualStack disabled
52    #[test]
53    fn test_2() {
54        let params = crate::config::endpoint::Params::builder()
55            .region("ap-northeast-1".to_string())
56            .use_fips(false)
57            .use_dual_stack(false)
58            .build()
59            .expect("invalid params");
60        let resolver = crate::config::endpoint::DefaultResolver::new();
61        let endpoint = resolver.resolve_endpoint(&params);
62        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.ap-northeast-1.amazonaws.com");
63        assert_eq!(
64            endpoint,
65            ::aws_smithy_types::endpoint::Endpoint::builder()
66                .url("https://amplify.ap-northeast-1.amazonaws.com")
67                .build()
68        );
69    }
70
71    /// For region ap-northeast-2 with FIPS disabled and DualStack disabled
72    #[test]
73    fn test_3() {
74        let params = crate::config::endpoint::Params::builder()
75            .region("ap-northeast-2".to_string())
76            .use_fips(false)
77            .use_dual_stack(false)
78            .build()
79            .expect("invalid params");
80        let resolver = crate::config::endpoint::DefaultResolver::new();
81        let endpoint = resolver.resolve_endpoint(&params);
82        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.ap-northeast-2.amazonaws.com");
83        assert_eq!(
84            endpoint,
85            ::aws_smithy_types::endpoint::Endpoint::builder()
86                .url("https://amplify.ap-northeast-2.amazonaws.com")
87                .build()
88        );
89    }
90
91    /// For region ap-south-1 with FIPS disabled and DualStack disabled
92    #[test]
93    fn test_4() {
94        let params = crate::config::endpoint::Params::builder()
95            .region("ap-south-1".to_string())
96            .use_fips(false)
97            .use_dual_stack(false)
98            .build()
99            .expect("invalid params");
100        let resolver = crate::config::endpoint::DefaultResolver::new();
101        let endpoint = resolver.resolve_endpoint(&params);
102        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.ap-south-1.amazonaws.com");
103        assert_eq!(
104            endpoint,
105            ::aws_smithy_types::endpoint::Endpoint::builder()
106                .url("https://amplify.ap-south-1.amazonaws.com")
107                .build()
108        );
109    }
110
111    /// For region ap-southeast-1 with FIPS disabled and DualStack disabled
112    #[test]
113    fn test_5() {
114        let params = crate::config::endpoint::Params::builder()
115            .region("ap-southeast-1".to_string())
116            .use_fips(false)
117            .use_dual_stack(false)
118            .build()
119            .expect("invalid params");
120        let resolver = crate::config::endpoint::DefaultResolver::new();
121        let endpoint = resolver.resolve_endpoint(&params);
122        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.ap-southeast-1.amazonaws.com");
123        assert_eq!(
124            endpoint,
125            ::aws_smithy_types::endpoint::Endpoint::builder()
126                .url("https://amplify.ap-southeast-1.amazonaws.com")
127                .build()
128        );
129    }
130
131    /// For region ap-southeast-2 with FIPS disabled and DualStack disabled
132    #[test]
133    fn test_6() {
134        let params = crate::config::endpoint::Params::builder()
135            .region("ap-southeast-2".to_string())
136            .use_fips(false)
137            .use_dual_stack(false)
138            .build()
139            .expect("invalid params");
140        let resolver = crate::config::endpoint::DefaultResolver::new();
141        let endpoint = resolver.resolve_endpoint(&params);
142        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.ap-southeast-2.amazonaws.com");
143        assert_eq!(
144            endpoint,
145            ::aws_smithy_types::endpoint::Endpoint::builder()
146                .url("https://amplify.ap-southeast-2.amazonaws.com")
147                .build()
148        );
149    }
150
151    /// For region ca-central-1 with FIPS disabled and DualStack disabled
152    #[test]
153    fn test_7() {
154        let params = crate::config::endpoint::Params::builder()
155            .region("ca-central-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://amplify.ca-central-1.amazonaws.com");
163        assert_eq!(
164            endpoint,
165            ::aws_smithy_types::endpoint::Endpoint::builder()
166                .url("https://amplify.ca-central-1.amazonaws.com")
167                .build()
168        );
169    }
170
171    /// For region eu-central-1 with FIPS disabled and DualStack disabled
172    #[test]
173    fn test_8() {
174        let params = crate::config::endpoint::Params::builder()
175            .region("eu-central-1".to_string())
176            .use_fips(false)
177            .use_dual_stack(false)
178            .build()
179            .expect("invalid params");
180        let resolver = crate::config::endpoint::DefaultResolver::new();
181        let endpoint = resolver.resolve_endpoint(&params);
182        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-central-1.amazonaws.com");
183        assert_eq!(
184            endpoint,
185            ::aws_smithy_types::endpoint::Endpoint::builder()
186                .url("https://amplify.eu-central-1.amazonaws.com")
187                .build()
188        );
189    }
190
191    /// For region eu-north-1 with FIPS disabled and DualStack disabled
192    #[test]
193    fn test_9() {
194        let params = crate::config::endpoint::Params::builder()
195            .region("eu-north-1".to_string())
196            .use_fips(false)
197            .use_dual_stack(false)
198            .build()
199            .expect("invalid params");
200        let resolver = crate::config::endpoint::DefaultResolver::new();
201        let endpoint = resolver.resolve_endpoint(&params);
202        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-north-1.amazonaws.com");
203        assert_eq!(
204            endpoint,
205            ::aws_smithy_types::endpoint::Endpoint::builder()
206                .url("https://amplify.eu-north-1.amazonaws.com")
207                .build()
208        );
209    }
210
211    /// For region eu-south-1 with FIPS disabled and DualStack disabled
212    #[test]
213    fn test_10() {
214        let params = crate::config::endpoint::Params::builder()
215            .region("eu-south-1".to_string())
216            .use_fips(false)
217            .use_dual_stack(false)
218            .build()
219            .expect("invalid params");
220        let resolver = crate::config::endpoint::DefaultResolver::new();
221        let endpoint = resolver.resolve_endpoint(&params);
222        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-south-1.amazonaws.com");
223        assert_eq!(
224            endpoint,
225            ::aws_smithy_types::endpoint::Endpoint::builder()
226                .url("https://amplify.eu-south-1.amazonaws.com")
227                .build()
228        );
229    }
230
231    /// For region eu-west-1 with FIPS disabled and DualStack disabled
232    #[test]
233    fn test_11() {
234        let params = crate::config::endpoint::Params::builder()
235            .region("eu-west-1".to_string())
236            .use_fips(false)
237            .use_dual_stack(false)
238            .build()
239            .expect("invalid params");
240        let resolver = crate::config::endpoint::DefaultResolver::new();
241        let endpoint = resolver.resolve_endpoint(&params);
242        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-west-1.amazonaws.com");
243        assert_eq!(
244            endpoint,
245            ::aws_smithy_types::endpoint::Endpoint::builder()
246                .url("https://amplify.eu-west-1.amazonaws.com")
247                .build()
248        );
249    }
250
251    /// For region eu-west-2 with FIPS disabled and DualStack disabled
252    #[test]
253    fn test_12() {
254        let params = crate::config::endpoint::Params::builder()
255            .region("eu-west-2".to_string())
256            .use_fips(false)
257            .use_dual_stack(false)
258            .build()
259            .expect("invalid params");
260        let resolver = crate::config::endpoint::DefaultResolver::new();
261        let endpoint = resolver.resolve_endpoint(&params);
262        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-west-2.amazonaws.com");
263        assert_eq!(
264            endpoint,
265            ::aws_smithy_types::endpoint::Endpoint::builder()
266                .url("https://amplify.eu-west-2.amazonaws.com")
267                .build()
268        );
269    }
270
271    /// For region eu-west-3 with FIPS disabled and DualStack disabled
272    #[test]
273    fn test_13() {
274        let params = crate::config::endpoint::Params::builder()
275            .region("eu-west-3".to_string())
276            .use_fips(false)
277            .use_dual_stack(false)
278            .build()
279            .expect("invalid params");
280        let resolver = crate::config::endpoint::DefaultResolver::new();
281        let endpoint = resolver.resolve_endpoint(&params);
282        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.eu-west-3.amazonaws.com");
283        assert_eq!(
284            endpoint,
285            ::aws_smithy_types::endpoint::Endpoint::builder()
286                .url("https://amplify.eu-west-3.amazonaws.com")
287                .build()
288        );
289    }
290
291    /// For region me-south-1 with FIPS disabled and DualStack disabled
292    #[test]
293    fn test_14() {
294        let params = crate::config::endpoint::Params::builder()
295            .region("me-south-1".to_string())
296            .use_fips(false)
297            .use_dual_stack(false)
298            .build()
299            .expect("invalid params");
300        let resolver = crate::config::endpoint::DefaultResolver::new();
301        let endpoint = resolver.resolve_endpoint(&params);
302        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.me-south-1.amazonaws.com");
303        assert_eq!(
304            endpoint,
305            ::aws_smithy_types::endpoint::Endpoint::builder()
306                .url("https://amplify.me-south-1.amazonaws.com")
307                .build()
308        );
309    }
310
311    /// For region sa-east-1 with FIPS disabled and DualStack disabled
312    #[test]
313    fn test_15() {
314        let params = crate::config::endpoint::Params::builder()
315            .region("sa-east-1".to_string())
316            .use_fips(false)
317            .use_dual_stack(false)
318            .build()
319            .expect("invalid params");
320        let resolver = crate::config::endpoint::DefaultResolver::new();
321        let endpoint = resolver.resolve_endpoint(&params);
322        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.sa-east-1.amazonaws.com");
323        assert_eq!(
324            endpoint,
325            ::aws_smithy_types::endpoint::Endpoint::builder()
326                .url("https://amplify.sa-east-1.amazonaws.com")
327                .build()
328        );
329    }
330
331    /// For region us-east-1 with FIPS disabled and DualStack disabled
332    #[test]
333    fn test_16() {
334        let params = crate::config::endpoint::Params::builder()
335            .region("us-east-1".to_string())
336            .use_fips(false)
337            .use_dual_stack(false)
338            .build()
339            .expect("invalid params");
340        let resolver = crate::config::endpoint::DefaultResolver::new();
341        let endpoint = resolver.resolve_endpoint(&params);
342        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-east-1.amazonaws.com");
343        assert_eq!(
344            endpoint,
345            ::aws_smithy_types::endpoint::Endpoint::builder()
346                .url("https://amplify.us-east-1.amazonaws.com")
347                .build()
348        );
349    }
350
351    /// For region us-east-2 with FIPS disabled and DualStack disabled
352    #[test]
353    fn test_17() {
354        let params = crate::config::endpoint::Params::builder()
355            .region("us-east-2".to_string())
356            .use_fips(false)
357            .use_dual_stack(false)
358            .build()
359            .expect("invalid params");
360        let resolver = crate::config::endpoint::DefaultResolver::new();
361        let endpoint = resolver.resolve_endpoint(&params);
362        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-east-2.amazonaws.com");
363        assert_eq!(
364            endpoint,
365            ::aws_smithy_types::endpoint::Endpoint::builder()
366                .url("https://amplify.us-east-2.amazonaws.com")
367                .build()
368        );
369    }
370
371    /// For region us-west-1 with FIPS disabled and DualStack disabled
372    #[test]
373    fn test_18() {
374        let params = crate::config::endpoint::Params::builder()
375            .region("us-west-1".to_string())
376            .use_fips(false)
377            .use_dual_stack(false)
378            .build()
379            .expect("invalid params");
380        let resolver = crate::config::endpoint::DefaultResolver::new();
381        let endpoint = resolver.resolve_endpoint(&params);
382        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-west-1.amazonaws.com");
383        assert_eq!(
384            endpoint,
385            ::aws_smithy_types::endpoint::Endpoint::builder()
386                .url("https://amplify.us-west-1.amazonaws.com")
387                .build()
388        );
389    }
390
391    /// For region us-west-2 with FIPS disabled and DualStack disabled
392    #[test]
393    fn test_19() {
394        let params = crate::config::endpoint::Params::builder()
395            .region("us-west-2".to_string())
396            .use_fips(false)
397            .use_dual_stack(false)
398            .build()
399            .expect("invalid params");
400        let resolver = crate::config::endpoint::DefaultResolver::new();
401        let endpoint = resolver.resolve_endpoint(&params);
402        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-west-2.amazonaws.com");
403        assert_eq!(
404            endpoint,
405            ::aws_smithy_types::endpoint::Endpoint::builder()
406                .url("https://amplify.us-west-2.amazonaws.com")
407                .build()
408        );
409    }
410
411    /// For region us-east-1 with FIPS enabled and DualStack enabled
412    #[test]
413    fn test_20() {
414        let params = crate::config::endpoint::Params::builder()
415            .region("us-east-1".to_string())
416            .use_fips(true)
417            .use_dual_stack(true)
418            .build()
419            .expect("invalid params");
420        let resolver = crate::config::endpoint::DefaultResolver::new();
421        let endpoint = resolver.resolve_endpoint(&params);
422        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-east-1.api.aws");
423        assert_eq!(
424            endpoint,
425            ::aws_smithy_types::endpoint::Endpoint::builder()
426                .url("https://amplify-fips.us-east-1.api.aws")
427                .build()
428        );
429    }
430
431    /// For region us-east-1 with FIPS enabled and DualStack disabled
432    #[test]
433    fn test_21() {
434        let params = crate::config::endpoint::Params::builder()
435            .region("us-east-1".to_string())
436            .use_fips(true)
437            .use_dual_stack(false)
438            .build()
439            .expect("invalid params");
440        let resolver = crate::config::endpoint::DefaultResolver::new();
441        let endpoint = resolver.resolve_endpoint(&params);
442        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-east-1.amazonaws.com");
443        assert_eq!(
444            endpoint,
445            ::aws_smithy_types::endpoint::Endpoint::builder()
446                .url("https://amplify-fips.us-east-1.amazonaws.com")
447                .build()
448        );
449    }
450
451    /// For region us-east-1 with FIPS disabled and DualStack enabled
452    #[test]
453    fn test_22() {
454        let params = crate::config::endpoint::Params::builder()
455            .region("us-east-1".to_string())
456            .use_fips(false)
457            .use_dual_stack(true)
458            .build()
459            .expect("invalid params");
460        let resolver = crate::config::endpoint::DefaultResolver::new();
461        let endpoint = resolver.resolve_endpoint(&params);
462        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-east-1.api.aws");
463        assert_eq!(
464            endpoint,
465            ::aws_smithy_types::endpoint::Endpoint::builder()
466                .url("https://amplify.us-east-1.api.aws")
467                .build()
468        );
469    }
470
471    /// For region cn-north-1 with FIPS enabled and DualStack enabled
472    #[test]
473    fn test_23() {
474        let params = crate::config::endpoint::Params::builder()
475            .region("cn-north-1".to_string())
476            .use_fips(true)
477            .use_dual_stack(true)
478            .build()
479            .expect("invalid params");
480        let resolver = crate::config::endpoint::DefaultResolver::new();
481        let endpoint = resolver.resolve_endpoint(&params);
482        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.cn-north-1.api.amazonwebservices.com.cn");
483        assert_eq!(
484            endpoint,
485            ::aws_smithy_types::endpoint::Endpoint::builder()
486                .url("https://amplify-fips.cn-north-1.api.amazonwebservices.com.cn")
487                .build()
488        );
489    }
490
491    /// For region cn-north-1 with FIPS enabled and DualStack disabled
492    #[test]
493    fn test_24() {
494        let params = crate::config::endpoint::Params::builder()
495            .region("cn-north-1".to_string())
496            .use_fips(true)
497            .use_dual_stack(false)
498            .build()
499            .expect("invalid params");
500        let resolver = crate::config::endpoint::DefaultResolver::new();
501        let endpoint = resolver.resolve_endpoint(&params);
502        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.cn-north-1.amazonaws.com.cn");
503        assert_eq!(
504            endpoint,
505            ::aws_smithy_types::endpoint::Endpoint::builder()
506                .url("https://amplify-fips.cn-north-1.amazonaws.com.cn")
507                .build()
508        );
509    }
510
511    /// For region cn-north-1 with FIPS disabled and DualStack enabled
512    #[test]
513    fn test_25() {
514        let params = crate::config::endpoint::Params::builder()
515            .region("cn-north-1".to_string())
516            .use_fips(false)
517            .use_dual_stack(true)
518            .build()
519            .expect("invalid params");
520        let resolver = crate::config::endpoint::DefaultResolver::new();
521        let endpoint = resolver.resolve_endpoint(&params);
522        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.cn-north-1.api.amazonwebservices.com.cn");
523        assert_eq!(
524            endpoint,
525            ::aws_smithy_types::endpoint::Endpoint::builder()
526                .url("https://amplify.cn-north-1.api.amazonwebservices.com.cn")
527                .build()
528        );
529    }
530
531    /// For region cn-north-1 with FIPS disabled and DualStack disabled
532    #[test]
533    fn test_26() {
534        let params = crate::config::endpoint::Params::builder()
535            .region("cn-north-1".to_string())
536            .use_fips(false)
537            .use_dual_stack(false)
538            .build()
539            .expect("invalid params");
540        let resolver = crate::config::endpoint::DefaultResolver::new();
541        let endpoint = resolver.resolve_endpoint(&params);
542        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.cn-north-1.amazonaws.com.cn");
543        assert_eq!(
544            endpoint,
545            ::aws_smithy_types::endpoint::Endpoint::builder()
546                .url("https://amplify.cn-north-1.amazonaws.com.cn")
547                .build()
548        );
549    }
550
551    /// For region us-gov-east-1 with FIPS enabled and DualStack enabled
552    #[test]
553    fn test_27() {
554        let params = crate::config::endpoint::Params::builder()
555            .region("us-gov-east-1".to_string())
556            .use_fips(true)
557            .use_dual_stack(true)
558            .build()
559            .expect("invalid params");
560        let resolver = crate::config::endpoint::DefaultResolver::new();
561        let endpoint = resolver.resolve_endpoint(&params);
562        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-gov-east-1.api.aws");
563        assert_eq!(
564            endpoint,
565            ::aws_smithy_types::endpoint::Endpoint::builder()
566                .url("https://amplify-fips.us-gov-east-1.api.aws")
567                .build()
568        );
569    }
570
571    /// For region us-gov-east-1 with FIPS enabled and DualStack disabled
572    #[test]
573    fn test_28() {
574        let params = crate::config::endpoint::Params::builder()
575            .region("us-gov-east-1".to_string())
576            .use_fips(true)
577            .use_dual_stack(false)
578            .build()
579            .expect("invalid params");
580        let resolver = crate::config::endpoint::DefaultResolver::new();
581        let endpoint = resolver.resolve_endpoint(&params);
582        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-gov-east-1.amazonaws.com");
583        assert_eq!(
584            endpoint,
585            ::aws_smithy_types::endpoint::Endpoint::builder()
586                .url("https://amplify-fips.us-gov-east-1.amazonaws.com")
587                .build()
588        );
589    }
590
591    /// For region us-gov-east-1 with FIPS disabled and DualStack enabled
592    #[test]
593    fn test_29() {
594        let params = crate::config::endpoint::Params::builder()
595            .region("us-gov-east-1".to_string())
596            .use_fips(false)
597            .use_dual_stack(true)
598            .build()
599            .expect("invalid params");
600        let resolver = crate::config::endpoint::DefaultResolver::new();
601        let endpoint = resolver.resolve_endpoint(&params);
602        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-gov-east-1.api.aws");
603        assert_eq!(
604            endpoint,
605            ::aws_smithy_types::endpoint::Endpoint::builder()
606                .url("https://amplify.us-gov-east-1.api.aws")
607                .build()
608        );
609    }
610
611    /// For region us-gov-east-1 with FIPS disabled and DualStack disabled
612    #[test]
613    fn test_30() {
614        let params = crate::config::endpoint::Params::builder()
615            .region("us-gov-east-1".to_string())
616            .use_fips(false)
617            .use_dual_stack(false)
618            .build()
619            .expect("invalid params");
620        let resolver = crate::config::endpoint::DefaultResolver::new();
621        let endpoint = resolver.resolve_endpoint(&params);
622        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-gov-east-1.amazonaws.com");
623        assert_eq!(
624            endpoint,
625            ::aws_smithy_types::endpoint::Endpoint::builder()
626                .url("https://amplify.us-gov-east-1.amazonaws.com")
627                .build()
628        );
629    }
630
631    /// For region us-iso-east-1 with FIPS enabled and DualStack disabled
632    #[test]
633    fn test_31() {
634        let params = crate::config::endpoint::Params::builder()
635            .region("us-iso-east-1".to_string())
636            .use_fips(true)
637            .use_dual_stack(false)
638            .build()
639            .expect("invalid params");
640        let resolver = crate::config::endpoint::DefaultResolver::new();
641        let endpoint = resolver.resolve_endpoint(&params);
642        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-iso-east-1.c2s.ic.gov");
643        assert_eq!(
644            endpoint,
645            ::aws_smithy_types::endpoint::Endpoint::builder()
646                .url("https://amplify-fips.us-iso-east-1.c2s.ic.gov")
647                .build()
648        );
649    }
650
651    /// For region us-iso-east-1 with FIPS disabled and DualStack disabled
652    #[test]
653    fn test_32() {
654        let params = crate::config::endpoint::Params::builder()
655            .region("us-iso-east-1".to_string())
656            .use_fips(false)
657            .use_dual_stack(false)
658            .build()
659            .expect("invalid params");
660        let resolver = crate::config::endpoint::DefaultResolver::new();
661        let endpoint = resolver.resolve_endpoint(&params);
662        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-iso-east-1.c2s.ic.gov");
663        assert_eq!(
664            endpoint,
665            ::aws_smithy_types::endpoint::Endpoint::builder()
666                .url("https://amplify.us-iso-east-1.c2s.ic.gov")
667                .build()
668        );
669    }
670
671    /// For region us-isob-east-1 with FIPS enabled and DualStack disabled
672    #[test]
673    fn test_33() {
674        let params = crate::config::endpoint::Params::builder()
675            .region("us-isob-east-1".to_string())
676            .use_fips(true)
677            .use_dual_stack(false)
678            .build()
679            .expect("invalid params");
680        let resolver = crate::config::endpoint::DefaultResolver::new();
681        let endpoint = resolver.resolve_endpoint(&params);
682        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify-fips.us-isob-east-1.sc2s.sgov.gov");
683        assert_eq!(
684            endpoint,
685            ::aws_smithy_types::endpoint::Endpoint::builder()
686                .url("https://amplify-fips.us-isob-east-1.sc2s.sgov.gov")
687                .build()
688        );
689    }
690
691    /// For region us-isob-east-1 with FIPS disabled and DualStack disabled
692    #[test]
693    fn test_34() {
694        let params = crate::config::endpoint::Params::builder()
695            .region("us-isob-east-1".to_string())
696            .use_fips(false)
697            .use_dual_stack(false)
698            .build()
699            .expect("invalid params");
700        let resolver = crate::config::endpoint::DefaultResolver::new();
701        let endpoint = resolver.resolve_endpoint(&params);
702        let endpoint = endpoint.expect("Expected valid endpoint: https://amplify.us-isob-east-1.sc2s.sgov.gov");
703        assert_eq!(
704            endpoint,
705            ::aws_smithy_types::endpoint::Endpoint::builder()
706                .url("https://amplify.us-isob-east-1.sc2s.sgov.gov")
707                .build()
708        );
709    }
710
711    /// For custom endpoint with region set and fips disabled and dualstack disabled
712    #[test]
713    fn test_35() {
714        let params = crate::config::endpoint::Params::builder()
715            .region("us-east-1".to_string())
716            .use_fips(false)
717            .use_dual_stack(false)
718            .endpoint("https://example.com".to_string())
719            .build()
720            .expect("invalid params");
721        let resolver = crate::config::endpoint::DefaultResolver::new();
722        let endpoint = resolver.resolve_endpoint(&params);
723        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
724        assert_eq!(
725            endpoint,
726            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
727        );
728    }
729
730    /// For custom endpoint with region not set and fips disabled and dualstack disabled
731    #[test]
732    fn test_36() {
733        let params = crate::config::endpoint::Params::builder()
734            .use_fips(false)
735            .use_dual_stack(false)
736            .endpoint("https://example.com".to_string())
737            .build()
738            .expect("invalid params");
739        let resolver = crate::config::endpoint::DefaultResolver::new();
740        let endpoint = resolver.resolve_endpoint(&params);
741        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
742        assert_eq!(
743            endpoint,
744            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
745        );
746    }
747
748    /// For custom endpoint with fips enabled and dualstack disabled
749    #[test]
750    fn test_37() {
751        let params = crate::config::endpoint::Params::builder()
752            .region("us-east-1".to_string())
753            .use_fips(true)
754            .use_dual_stack(false)
755            .endpoint("https://example.com".to_string())
756            .build()
757            .expect("invalid params");
758        let resolver = crate::config::endpoint::DefaultResolver::new();
759        let endpoint = resolver.resolve_endpoint(&params);
760        let error = endpoint.expect_err("expected error: Invalid Configuration: FIPS and custom endpoint are not supported [For custom endpoint with fips enabled and dualstack disabled]");
761        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
762    }
763
764    /// For custom endpoint with fips disabled and dualstack enabled
765    #[test]
766    fn test_38() {
767        let params = crate::config::endpoint::Params::builder()
768            .region("us-east-1".to_string())
769            .use_fips(false)
770            .use_dual_stack(true)
771            .endpoint("https://example.com".to_string())
772            .build()
773            .expect("invalid params");
774        let resolver = crate::config::endpoint::DefaultResolver::new();
775        let endpoint = resolver.resolve_endpoint(&params);
776        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]");
777        assert_eq!(
778            format!("{}", error),
779            "Invalid Configuration: Dualstack and custom endpoint are not supported"
780        )
781    }
782
783    /// Missing region
784    #[test]
785    fn test_39() {
786        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
787        let resolver = crate::config::endpoint::DefaultResolver::new();
788        let endpoint = resolver.resolve_endpoint(&params);
789        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
790        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
791    }
792}
793
794/// Endpoint resolver trait specific to AWS Amplify
795pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
796    /// Resolve an endpoint with the given parameters
797    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
798
799    /// Convert this service-specific resolver into a `SharedEndpointResolver`
800    ///
801    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
802    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
803    where
804        Self: Sized + 'static,
805    {
806        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
807    }
808}
809
810#[derive(Debug)]
811struct DowncastParams<T>(T);
812impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
813where
814    T: ResolveEndpoint,
815{
816    fn resolve_endpoint<'a>(
817        &'a self,
818        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
819    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
820        let ep = match params.get::<crate::config::endpoint::Params>() {
821            Some(params) => self.0.resolve_endpoint(params),
822            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
823        };
824        ep
825    }
826}
827
828/// The default endpoint resolver
829#[derive(Debug, Default)]
830pub struct DefaultResolver {
831    partition_resolver: crate::endpoint_lib::partition::PartitionResolver,
832}
833
834impl DefaultResolver {
835    /// Create a new endpoint resolver with default settings
836    pub fn new() -> Self {
837        Self {
838            partition_resolver: crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER.clone(),
839        }
840    }
841
842    fn resolve_endpoint(
843        &self,
844        params: &crate::config::endpoint::Params,
845    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
846        let mut diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
847        Ok(
848            crate::config::endpoint::internals::resolve_endpoint(params, &mut diagnostic_collector, &self.partition_resolver)
849                .map_err(|err| err.with_source(diagnostic_collector.take_last_error()))?,
850        )
851    }
852}
853
854impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
855    fn resolve_endpoint(&self, params: &crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'_> {
856        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(self.resolve_endpoint(params))
857    }
858}
859
860#[non_exhaustive]
861#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
862/// Configuration parameters for resolving the correct endpoint
863pub struct Params {
864    /// The AWS region used to dispatch the request.
865    pub(crate) region: ::std::option::Option<::std::string::String>,
866    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
867    pub(crate) use_dual_stack: bool,
868    /// 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.
869    pub(crate) use_fips: bool,
870    /// Override the endpoint used to send this request
871    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
872}
873impl Params {
874    /// Create a builder for [`Params`]
875    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
876        crate::config::endpoint::ParamsBuilder::default()
877    }
878    /// The AWS region used to dispatch the request.
879    pub fn region(&self) -> ::std::option::Option<&str> {
880        self.region.as_deref()
881    }
882    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
883    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
884        Some(self.use_dual_stack)
885    }
886    /// 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.
887    pub fn use_fips(&self) -> ::std::option::Option<bool> {
888        Some(self.use_fips)
889    }
890    /// Override the endpoint used to send this request
891    pub fn endpoint(&self) -> ::std::option::Option<&str> {
892        self.endpoint.as_deref()
893    }
894}
895
896/// Builder for [`Params`]
897#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
898pub struct ParamsBuilder {
899    region: ::std::option::Option<::std::string::String>,
900    use_dual_stack: ::std::option::Option<bool>,
901    use_fips: ::std::option::Option<bool>,
902    endpoint: ::std::option::Option<::std::string::String>,
903}
904impl ParamsBuilder {
905    /// Consume this builder, creating [`Params`].
906    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
907        if let Some(region) = &self.region {
908            if !crate::endpoint_lib::host::is_valid_host_label(
909                region.as_ref() as &str,
910                true,
911                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
912            ) {
913                return Err(crate::config::endpoint::InvalidParams::invalid_value(
914                    "region",
915                    "must be a valid host label",
916                ));
917            }
918        };
919        Ok(
920            #[allow(clippy::unnecessary_lazy_evaluations)]
921            crate::config::endpoint::Params {
922                region: self.region,
923                use_dual_stack: self
924                    .use_dual_stack
925                    .or_else(|| Some(false))
926                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
927                use_fips: self
928                    .use_fips
929                    .or_else(|| Some(false))
930                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
931                endpoint: self.endpoint,
932            },
933        )
934    }
935    /// Sets the value for region
936    ///
937    /// The AWS region used to dispatch the request.
938    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
939        self.region = Some(value.into());
940        self
941    }
942
943    /// Sets the value for region
944    ///
945    /// The AWS region used to dispatch the request.
946    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
947        self.region = param;
948        self
949    }
950    /// Sets the value for use_dual_stack
951    ///
952    /// When unset, this parameter has a default value of `false`.
953    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
954    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
955        self.use_dual_stack = Some(value.into());
956        self
957    }
958
959    /// Sets the value for use_dual_stack
960    ///
961    /// When unset, this parameter has a default value of `false`.
962    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
963    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
964        self.use_dual_stack = param;
965        self
966    }
967    /// Sets the value for use_fips
968    ///
969    /// When unset, this parameter has a default value of `false`.
970    /// 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.
971    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
972        self.use_fips = Some(value.into());
973        self
974    }
975
976    /// Sets the value for use_fips
977    ///
978    /// When unset, this parameter has a default value of `false`.
979    /// 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.
980    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
981        self.use_fips = param;
982        self
983    }
984    /// Sets the value for endpoint
985    ///
986    /// Override the endpoint used to send this request
987    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
988        self.endpoint = Some(value.into());
989        self
990    }
991
992    /// Sets the value for endpoint
993    ///
994    /// Override the endpoint used to send this request
995    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
996        self.endpoint = param;
997        self
998    }
999}
1000
1001/// An error that occurred during endpoint resolution
1002#[derive(Debug)]
1003pub struct InvalidParams {
1004    field: std::borrow::Cow<'static, str>,
1005    kind: InvalidParamsErrorKind,
1006}
1007
1008/// The kind of invalid parameter error
1009#[derive(Debug)]
1010enum InvalidParamsErrorKind {
1011    MissingField,
1012    InvalidValue { message: &'static str },
1013}
1014
1015impl InvalidParams {
1016    #[allow(dead_code)]
1017    fn missing(field: &'static str) -> Self {
1018        Self {
1019            field: field.into(),
1020            kind: InvalidParamsErrorKind::MissingField,
1021        }
1022    }
1023
1024    #[allow(dead_code)]
1025    fn invalid_value(field: &'static str, message: &'static str) -> Self {
1026        Self {
1027            field: field.into(),
1028            kind: InvalidParamsErrorKind::InvalidValue { message },
1029        }
1030    }
1031}
1032
1033impl std::fmt::Display for InvalidParams {
1034    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1035        match self.kind {
1036            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
1037            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
1038        }
1039    }
1040}
1041
1042impl std::error::Error for InvalidParams {}
1043
1044mod internals;