Skip to main content

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