aws_sdk_lexmodelsv2/config/
endpoint.rs

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