aws_sdk_networkmanager/config/
endpoint.rs

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