Skip to main content

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