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