Skip to main content

aws_sdk_entityresolution/config/
endpoint.rs

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