Skip to main content

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