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