Skip to main content

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