Skip to main content

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