Skip to main content

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