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 disabled
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(false)
426            .build()
427            .expect("invalid params");
428        let resolver = crate::config::endpoint::DefaultResolver::new();
429        let endpoint = resolver.resolve_endpoint(&params);
430        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager-fips.us-iso-east-1.c2s.ic.gov");
431        assert_eq!(
432            endpoint,
433            ::aws_smithy_types::endpoint::Endpoint::builder()
434                .url("https://networkmanager-fips.us-iso-east-1.c2s.ic.gov")
435                .property(
436                    "authSchemes",
437                    vec![{
438                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
439                        out.insert("name".to_string(), "sigv4".to_string().into());
440                        out.insert("signingRegion".to_string(), "us-iso-east-1".to_string().into());
441                        out
442                    }
443                    .into()]
444                )
445                .build()
446        );
447    }
448
449    /// For region us-iso-east-1 with FIPS disabled and DualStack disabled
450    #[test]
451    fn test_17() {
452        let params = crate::config::endpoint::Params::builder()
453            .region("us-iso-east-1".to_string())
454            .use_fips(false)
455            .use_dual_stack(false)
456            .build()
457            .expect("invalid params");
458        let resolver = crate::config::endpoint::DefaultResolver::new();
459        let endpoint = resolver.resolve_endpoint(&params);
460        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager.us-iso-east-1.c2s.ic.gov");
461        assert_eq!(
462            endpoint,
463            ::aws_smithy_types::endpoint::Endpoint::builder()
464                .url("https://networkmanager.us-iso-east-1.c2s.ic.gov")
465                .property(
466                    "authSchemes",
467                    vec![{
468                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
469                        out.insert("name".to_string(), "sigv4".to_string().into());
470                        out.insert("signingRegion".to_string(), "us-iso-east-1".to_string().into());
471                        out
472                    }
473                    .into()]
474                )
475                .build()
476        );
477    }
478
479    /// For region us-isob-east-1 with FIPS enabled and DualStack disabled
480    #[test]
481    fn test_18() {
482        let params = crate::config::endpoint::Params::builder()
483            .region("us-isob-east-1".to_string())
484            .use_fips(true)
485            .use_dual_stack(false)
486            .build()
487            .expect("invalid params");
488        let resolver = crate::config::endpoint::DefaultResolver::new();
489        let endpoint = resolver.resolve_endpoint(&params);
490        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager-fips.us-isob-east-1.sc2s.sgov.gov");
491        assert_eq!(
492            endpoint,
493            ::aws_smithy_types::endpoint::Endpoint::builder()
494                .url("https://networkmanager-fips.us-isob-east-1.sc2s.sgov.gov")
495                .property(
496                    "authSchemes",
497                    vec![{
498                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
499                        out.insert("name".to_string(), "sigv4".to_string().into());
500                        out.insert("signingRegion".to_string(), "us-isob-east-1".to_string().into());
501                        out
502                    }
503                    .into()]
504                )
505                .build()
506        );
507    }
508
509    /// For region us-isob-east-1 with FIPS disabled and DualStack disabled
510    #[test]
511    fn test_19() {
512        let params = crate::config::endpoint::Params::builder()
513            .region("us-isob-east-1".to_string())
514            .use_fips(false)
515            .use_dual_stack(false)
516            .build()
517            .expect("invalid params");
518        let resolver = crate::config::endpoint::DefaultResolver::new();
519        let endpoint = resolver.resolve_endpoint(&params);
520        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager.us-isob-east-1.sc2s.sgov.gov");
521        assert_eq!(
522            endpoint,
523            ::aws_smithy_types::endpoint::Endpoint::builder()
524                .url("https://networkmanager.us-isob-east-1.sc2s.sgov.gov")
525                .property(
526                    "authSchemes",
527                    vec![{
528                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
529                        out.insert("name".to_string(), "sigv4".to_string().into());
530                        out.insert("signingRegion".to_string(), "us-isob-east-1".to_string().into());
531                        out
532                    }
533                    .into()]
534                )
535                .build()
536        );
537    }
538
539    /// For region eu-isoe-west-1 with FIPS enabled and DualStack disabled
540    #[test]
541    fn test_20() {
542        let params = crate::config::endpoint::Params::builder()
543            .region("eu-isoe-west-1".to_string())
544            .use_fips(true)
545            .use_dual_stack(false)
546            .build()
547            .expect("invalid params");
548        let resolver = crate::config::endpoint::DefaultResolver::new();
549        let endpoint = resolver.resolve_endpoint(&params);
550        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager-fips.eu-isoe-west-1.cloud.adc-e.uk");
551        assert_eq!(
552            endpoint,
553            ::aws_smithy_types::endpoint::Endpoint::builder()
554                .url("https://networkmanager-fips.eu-isoe-west-1.cloud.adc-e.uk")
555                .property(
556                    "authSchemes",
557                    vec![{
558                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
559                        out.insert("name".to_string(), "sigv4".to_string().into());
560                        out.insert("signingRegion".to_string(), "eu-isoe-west-1".to_string().into());
561                        out
562                    }
563                    .into()]
564                )
565                .build()
566        );
567    }
568
569    /// For region eu-isoe-west-1 with FIPS disabled and DualStack disabled
570    #[test]
571    fn test_21() {
572        let params = crate::config::endpoint::Params::builder()
573            .region("eu-isoe-west-1".to_string())
574            .use_fips(false)
575            .use_dual_stack(false)
576            .build()
577            .expect("invalid params");
578        let resolver = crate::config::endpoint::DefaultResolver::new();
579        let endpoint = resolver.resolve_endpoint(&params);
580        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager.eu-isoe-west-1.cloud.adc-e.uk");
581        assert_eq!(
582            endpoint,
583            ::aws_smithy_types::endpoint::Endpoint::builder()
584                .url("https://networkmanager.eu-isoe-west-1.cloud.adc-e.uk")
585                .property(
586                    "authSchemes",
587                    vec![{
588                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
589                        out.insert("name".to_string(), "sigv4".to_string().into());
590                        out.insert("signingRegion".to_string(), "eu-isoe-west-1".to_string().into());
591                        out
592                    }
593                    .into()]
594                )
595                .build()
596        );
597    }
598
599    /// For region us-isof-south-1 with FIPS enabled and DualStack disabled
600    #[test]
601    fn test_22() {
602        let params = crate::config::endpoint::Params::builder()
603            .region("us-isof-south-1".to_string())
604            .use_fips(true)
605            .use_dual_stack(false)
606            .build()
607            .expect("invalid params");
608        let resolver = crate::config::endpoint::DefaultResolver::new();
609        let endpoint = resolver.resolve_endpoint(&params);
610        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager-fips.us-isof-south-1.csp.hci.ic.gov");
611        assert_eq!(
612            endpoint,
613            ::aws_smithy_types::endpoint::Endpoint::builder()
614                .url("https://networkmanager-fips.us-isof-south-1.csp.hci.ic.gov")
615                .property(
616                    "authSchemes",
617                    vec![{
618                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
619                        out.insert("name".to_string(), "sigv4".to_string().into());
620                        out.insert("signingRegion".to_string(), "us-isof-south-1".to_string().into());
621                        out
622                    }
623                    .into()]
624                )
625                .build()
626        );
627    }
628
629    /// For region us-isof-south-1 with FIPS disabled and DualStack disabled
630    #[test]
631    fn test_23() {
632        let params = crate::config::endpoint::Params::builder()
633            .region("us-isof-south-1".to_string())
634            .use_fips(false)
635            .use_dual_stack(false)
636            .build()
637            .expect("invalid params");
638        let resolver = crate::config::endpoint::DefaultResolver::new();
639        let endpoint = resolver.resolve_endpoint(&params);
640        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager.us-isof-south-1.csp.hci.ic.gov");
641        assert_eq!(
642            endpoint,
643            ::aws_smithy_types::endpoint::Endpoint::builder()
644                .url("https://networkmanager.us-isof-south-1.csp.hci.ic.gov")
645                .property(
646                    "authSchemes",
647                    vec![{
648                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
649                        out.insert("name".to_string(), "sigv4".to_string().into());
650                        out.insert("signingRegion".to_string(), "us-isof-south-1".to_string().into());
651                        out
652                    }
653                    .into()]
654                )
655                .build()
656        );
657    }
658
659    /// For region eusc-de-east-1 with FIPS enabled and DualStack disabled
660    #[test]
661    fn test_24() {
662        let params = crate::config::endpoint::Params::builder()
663            .region("eusc-de-east-1".to_string())
664            .use_fips(true)
665            .use_dual_stack(false)
666            .build()
667            .expect("invalid params");
668        let resolver = crate::config::endpoint::DefaultResolver::new();
669        let endpoint = resolver.resolve_endpoint(&params);
670        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager-fips.eusc-de-east-1.amazonaws.eu");
671        assert_eq!(
672            endpoint,
673            ::aws_smithy_types::endpoint::Endpoint::builder()
674                .url("https://networkmanager-fips.eusc-de-east-1.amazonaws.eu")
675                .property(
676                    "authSchemes",
677                    vec![{
678                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
679                        out.insert("name".to_string(), "sigv4".to_string().into());
680                        out.insert("signingRegion".to_string(), "eusc-de-east-1".to_string().into());
681                        out
682                    }
683                    .into()]
684                )
685                .build()
686        );
687    }
688
689    /// For region eusc-de-east-1 with FIPS disabled and DualStack disabled
690    #[test]
691    fn test_25() {
692        let params = crate::config::endpoint::Params::builder()
693            .region("eusc-de-east-1".to_string())
694            .use_fips(false)
695            .use_dual_stack(false)
696            .build()
697            .expect("invalid params");
698        let resolver = crate::config::endpoint::DefaultResolver::new();
699        let endpoint = resolver.resolve_endpoint(&params);
700        let endpoint = endpoint.expect("Expected valid endpoint: https://networkmanager.eusc-de-east-1.amazonaws.eu");
701        assert_eq!(
702            endpoint,
703            ::aws_smithy_types::endpoint::Endpoint::builder()
704                .url("https://networkmanager.eusc-de-east-1.amazonaws.eu")
705                .property(
706                    "authSchemes",
707                    vec![{
708                        let mut out = ::std::collections::HashMap::<String, ::aws_smithy_types::Document>::new();
709                        out.insert("name".to_string(), "sigv4".to_string().into());
710                        out.insert("signingRegion".to_string(), "eusc-de-east-1".to_string().into());
711                        out
712                    }
713                    .into()]
714                )
715                .build()
716        );
717    }
718
719    /// Missing region
720    #[test]
721    fn test_26() {
722        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
723        let resolver = crate::config::endpoint::DefaultResolver::new();
724        let endpoint = resolver.resolve_endpoint(&params);
725        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
726        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
727    }
728}
729
730/// Endpoint resolver trait specific to AWS Network Manager
731pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
732    /// Resolve an endpoint with the given parameters
733    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
734
735    /// Convert this service-specific resolver into a `SharedEndpointResolver`
736    ///
737    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
738    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
739    where
740        Self: Sized + 'static,
741    {
742        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
743    }
744}
745
746#[derive(Debug)]
747struct DowncastParams<T>(T);
748impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
749where
750    T: ResolveEndpoint,
751{
752    fn resolve_endpoint<'a>(
753        &'a self,
754        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
755    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
756        let ep = match params.get::<crate::config::endpoint::Params>() {
757            Some(params) => self.0.resolve_endpoint(params),
758            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
759        };
760        ep
761    }
762}
763
764/// The default endpoint resolver
765#[derive(Debug, Default)]
766pub struct DefaultResolver {
767    partition_resolver: crate::endpoint_lib::partition::PartitionResolver,
768}
769
770impl DefaultResolver {
771    /// Create a new endpoint resolver with default settings
772    pub fn new() -> Self {
773        Self {
774            partition_resolver: crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER.clone(),
775        }
776    }
777
778    fn resolve_endpoint(
779        &self,
780        params: &crate::config::endpoint::Params,
781    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
782        let mut diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
783        Ok(
784            crate::config::endpoint::internals::resolve_endpoint(params, &mut diagnostic_collector, &self.partition_resolver)
785                .map_err(|err| err.with_source(diagnostic_collector.take_last_error()))?,
786        )
787    }
788}
789
790impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
791    fn resolve_endpoint(&self, params: &crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'_> {
792        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(self.resolve_endpoint(params))
793    }
794}
795
796#[non_exhaustive]
797#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
798/// Configuration parameters for resolving the correct endpoint
799pub struct Params {
800    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
801    pub(crate) use_dual_stack: bool,
802    /// 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.
803    pub(crate) use_fips: bool,
804    /// Override the endpoint used to send this request
805    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
806    /// The AWS region used to dispatch the request.
807    pub(crate) region: ::std::option::Option<::std::string::String>,
808}
809impl Params {
810    /// Create a builder for [`Params`]
811    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
812        crate::config::endpoint::ParamsBuilder::default()
813    }
814    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
815    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
816        Some(self.use_dual_stack)
817    }
818    /// 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.
819    pub fn use_fips(&self) -> ::std::option::Option<bool> {
820        Some(self.use_fips)
821    }
822    /// Override the endpoint used to send this request
823    pub fn endpoint(&self) -> ::std::option::Option<&str> {
824        self.endpoint.as_deref()
825    }
826    /// The AWS region used to dispatch the request.
827    pub fn region(&self) -> ::std::option::Option<&str> {
828        self.region.as_deref()
829    }
830}
831
832/// Builder for [`Params`]
833#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
834pub struct ParamsBuilder {
835    use_dual_stack: ::std::option::Option<bool>,
836    use_fips: ::std::option::Option<bool>,
837    endpoint: ::std::option::Option<::std::string::String>,
838    region: ::std::option::Option<::std::string::String>,
839}
840impl ParamsBuilder {
841    /// Consume this builder, creating [`Params`].
842    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
843        Ok(
844            #[allow(clippy::unnecessary_lazy_evaluations)]
845            crate::config::endpoint::Params {
846                use_dual_stack: self
847                    .use_dual_stack
848                    .or_else(|| Some(false))
849                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
850                use_fips: self
851                    .use_fips
852                    .or_else(|| Some(false))
853                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
854                endpoint: self.endpoint,
855                region: self.region,
856            },
857        )
858    }
859    /// Sets the value for use_dual_stack
860    ///
861    /// When unset, this parameter has a default value of `false`.
862    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
863    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
864        self.use_dual_stack = Some(value.into());
865        self
866    }
867
868    /// Sets the value for use_dual_stack
869    ///
870    /// When unset, this parameter has a default value of `false`.
871    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
872    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
873        self.use_dual_stack = param;
874        self
875    }
876    /// Sets the value for use_fips
877    ///
878    /// When unset, this parameter has a default value of `false`.
879    /// 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.
880    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
881        self.use_fips = Some(value.into());
882        self
883    }
884
885    /// Sets the value for use_fips
886    ///
887    /// When unset, this parameter has a default value of `false`.
888    /// 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.
889    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
890        self.use_fips = param;
891        self
892    }
893    /// Sets the value for endpoint
894    ///
895    /// Override the endpoint used to send this request
896    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
897        self.endpoint = Some(value.into());
898        self
899    }
900
901    /// Sets the value for endpoint
902    ///
903    /// Override the endpoint used to send this request
904    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
905        self.endpoint = param;
906        self
907    }
908    /// Sets the value for region
909    ///
910    /// The AWS region used to dispatch the request.
911    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
912        self.region = Some(value.into());
913        self
914    }
915
916    /// Sets the value for region
917    ///
918    /// The AWS region used to dispatch the request.
919    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
920        self.region = param;
921        self
922    }
923}
924
925/// An error that occurred during endpoint resolution
926#[derive(Debug)]
927pub struct InvalidParams {
928    field: std::borrow::Cow<'static, str>,
929}
930
931impl InvalidParams {
932    #[allow(dead_code)]
933    fn missing(field: &'static str) -> Self {
934        Self { field: field.into() }
935    }
936}
937
938impl std::fmt::Display for InvalidParams {
939    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
940        write!(f, "a required field was missing: `{}`", self.field)
941    }
942}
943
944impl std::error::Error for InvalidParams {}
945
946mod internals;