Skip to main content

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