Skip to main content

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