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        clippy::single_char_add_str
603    )]
604    fn resolve_endpoint<'a>(
605        &'a self,
606        params: &'a crate::config::endpoint::Params,
607    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
608        let mut _diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
609        #[allow(unused_mut)]
610        let mut context = ConditionContext::default();
611
612        // Param bindings
613        let region = &params.region;
614        let use_dual_stack = &params.use_dual_stack;
615        let use_fips = &params.use_fips;
616        let endpoint = &params.endpoint;
617
618        let mut current_ref: i32 = 2;
619        loop {
620            match current_ref {
621                ref_val if ref_val >= 100_000_000 => {
622                    return match (ref_val - 100_000_000) as usize {
623                        0 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
624                            "No endpoint rule matched",
625                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
626                        1 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
627                            "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
628                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
629                        2 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
630                            "Invalid Configuration: Dualstack and custom endpoint are not supported".to_string(),
631                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
632                        3 => {
633                            let endpoint = params.endpoint.as_deref().unwrap_or_default();
634                            ::std::result::Result::Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build())
635                        }
636                        4 => {
637                            let region = params.region.as_deref().unwrap_or_default();
638                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
639                            ::std::result::Result::Ok(
640                                ::aws_smithy_types::endpoint::Endpoint::builder()
641                                    .url({
642                                        let mut out = String::new();
643                                        out.push_str("https://iotthingsgraph-fips.");
644                                        #[allow(clippy::needless_borrow)]
645                                        out.push_str(&region.as_ref());
646                                        out.push_str(".");
647                                        #[allow(clippy::needless_borrow)]
648                                        out.push_str(&partition_result.dual_stack_dns_suffix());
649                                        out
650                                    })
651                                    .build(),
652                            )
653                        }
654                        5 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
655                            "FIPS and DualStack are enabled, but this partition does not support one or both".to_string(),
656                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
657                        6 => {
658                            let region = params.region.as_deref().unwrap_or_default();
659                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
660                            ::std::result::Result::Ok(
661                                ::aws_smithy_types::endpoint::Endpoint::builder()
662                                    .url({
663                                        let mut out = String::new();
664                                        out.push_str("https://iotthingsgraph-fips.");
665                                        #[allow(clippy::needless_borrow)]
666                                        out.push_str(&region.as_ref());
667                                        out.push_str(".");
668                                        #[allow(clippy::needless_borrow)]
669                                        out.push_str(&partition_result.dns_suffix());
670                                        out
671                                    })
672                                    .build(),
673                            )
674                        }
675                        7 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
676                            "FIPS is enabled but this partition does not support FIPS".to_string(),
677                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
678                        8 => {
679                            let region = params.region.as_deref().unwrap_or_default();
680                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
681                            ::std::result::Result::Ok(
682                                ::aws_smithy_types::endpoint::Endpoint::builder()
683                                    .url({
684                                        let mut out = String::new();
685                                        out.push_str("https://iotthingsgraph.");
686                                        #[allow(clippy::needless_borrow)]
687                                        out.push_str(&region.as_ref());
688                                        out.push_str(".");
689                                        #[allow(clippy::needless_borrow)]
690                                        out.push_str(&partition_result.dual_stack_dns_suffix());
691                                        out
692                                    })
693                                    .build(),
694                            )
695                        }
696                        9 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
697                            "DualStack is enabled but this partition does not support DualStack".to_string(),
698                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
699                        10 => {
700                            let region = params.region.as_deref().unwrap_or_default();
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://iotthingsgraph.");
706                                        #[allow(clippy::needless_borrow)]
707                                        out.push_str(&region.as_ref());
708                                        out.push_str(".amazonaws.com");
709                                        out
710                                    })
711                                    .build(),
712                            )
713                        }
714                        11 => {
715                            let region = params.region.as_deref().unwrap_or_default();
716                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
717                            ::std::result::Result::Ok(
718                                ::aws_smithy_types::endpoint::Endpoint::builder()
719                                    .url({
720                                        let mut out = String::new();
721                                        out.push_str("https://iotthingsgraph.");
722                                        #[allow(clippy::needless_borrow)]
723                                        out.push_str(&region.as_ref());
724                                        out.push_str(".");
725                                        #[allow(clippy::needless_borrow)]
726                                        out.push_str(&partition_result.dns_suffix());
727                                        out
728                                    })
729                                    .build(),
730                            )
731                        }
732                        12 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
733                            "Invalid Configuration: Missing Region".to_string(),
734                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
735                        _ => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
736                            "No endpoint rule matched",
737                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
738                    };
739                }
740                1 | -1 => {
741                    return ::std::result::Result::Err(
742                        Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message("No endpoint rule matched"))
743                            as ::aws_smithy_runtime_api::box_error::BoxError,
744                    )
745                }
746                ref_val => {
747                    let is_complement = ref_val < 0;
748                    let node = &NODES[(ref_val.unsigned_abs() as usize) - 1];
749                    let condition_result = match node.condition_index {
750                        0 => endpoint.is_some(),
751                        1 => region.is_some(),
752                        2 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
753                            let partition_result = &mut context.partition_result;
754                            let partition_resolver = &self.partition_resolver;
755                            {
756                                *partition_result = partition_resolver
757                                    .resolve_partition(if let Some(param) = region { param } else { return false }, _diagnostic_collector)
758                                    .map(|inner| inner.into());
759                                partition_result.is_some()
760                            }
761                        })(&mut _diagnostic_collector),
762                        3 => (use_fips) == (&true),
763                        4 => (use_dual_stack) == (&true),
764                        5 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
765                            let partition_result = &context.partition_result;
766                            let partition_resolver = &self.partition_resolver;
767                            (if let Some(inner) = partition_result {
768                                inner.supports_dual_stack()
769                            } else {
770                                return false;
771                            }) == (true)
772                        })(&mut _diagnostic_collector),
773                        6 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
774                            let partition_result = &context.partition_result;
775                            let partition_resolver = &self.partition_resolver;
776                            (if let Some(inner) = partition_result {
777                                inner.supports_fips()
778                            } else {
779                                return false;
780                            }) == (true)
781                        })(&mut _diagnostic_collector),
782                        7 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
783                            let partition_result = &context.partition_result;
784                            let partition_resolver = &self.partition_resolver;
785                            (if let Some(inner) = partition_result {
786                                inner.name()
787                            } else {
788                                return false;
789                            }) == ("aws")
790                        })(&mut _diagnostic_collector),
791                        _ => unreachable!("Invalid condition index"),
792                    };
793                    current_ref = if is_complement ^ condition_result { node.high_ref } else { node.low_ref };
794                }
795            }
796        }
797    }
798}
799
800impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
801    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
802        // Check single-entry cache (lock-free read via ArcSwap)
803        let cached = self.endpoint_cache.load();
804        if let Some((cached_params, cached_endpoint)) = cached.as_ref() {
805            if cached_params == params {
806                return ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(::std::result::Result::Ok(cached_endpoint.clone()));
807            }
808        }
809        drop(cached);
810        let result = self.resolve_endpoint(params);
811        if let ::std::result::Result::Ok(ref endpoint) = result {
812            self.endpoint_cache.store(::std::sync::Arc::new(Some((params.clone(), endpoint.clone()))));
813        }
814        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(result)
815    }
816}
817const NODES: [crate::endpoint_lib::bdd_interpreter::BddNode; 14] = [
818    crate::endpoint_lib::bdd_interpreter::BddNode {
819        condition_index: -1,
820        high_ref: 1,
821        low_ref: -1,
822    },
823    crate::endpoint_lib::bdd_interpreter::BddNode {
824        condition_index: 0,
825        high_ref: 13,
826        low_ref: 3,
827    },
828    crate::endpoint_lib::bdd_interpreter::BddNode {
829        condition_index: 1,
830        high_ref: 4,
831        low_ref: 100000012,
832    },
833    crate::endpoint_lib::bdd_interpreter::BddNode {
834        condition_index: 2,
835        high_ref: 5,
836        low_ref: 100000012,
837    },
838    crate::endpoint_lib::bdd_interpreter::BddNode {
839        condition_index: 3,
840        high_ref: 9,
841        low_ref: 6,
842    },
843    crate::endpoint_lib::bdd_interpreter::BddNode {
844        condition_index: 4,
845        high_ref: 8,
846        low_ref: 7,
847    },
848    crate::endpoint_lib::bdd_interpreter::BddNode {
849        condition_index: 7,
850        high_ref: 100000010,
851        low_ref: 100000011,
852    },
853    crate::endpoint_lib::bdd_interpreter::BddNode {
854        condition_index: 5,
855        high_ref: 100000008,
856        low_ref: 100000009,
857    },
858    crate::endpoint_lib::bdd_interpreter::BddNode {
859        condition_index: 4,
860        high_ref: 11,
861        low_ref: 10,
862    },
863    crate::endpoint_lib::bdd_interpreter::BddNode {
864        condition_index: 6,
865        high_ref: 100000006,
866        low_ref: 100000007,
867    },
868    crate::endpoint_lib::bdd_interpreter::BddNode {
869        condition_index: 5,
870        high_ref: 12,
871        low_ref: 100000005,
872    },
873    crate::endpoint_lib::bdd_interpreter::BddNode {
874        condition_index: 6,
875        high_ref: 100000004,
876        low_ref: 100000005,
877    },
878    crate::endpoint_lib::bdd_interpreter::BddNode {
879        condition_index: 3,
880        high_ref: 100000001,
881        low_ref: 14,
882    },
883    crate::endpoint_lib::bdd_interpreter::BddNode {
884        condition_index: 4,
885        high_ref: 100000002,
886        low_ref: 100000003,
887    },
888];
889// These are all optional since they are set by conditions and will
890// all be unset when we start evaluation
891#[derive(Default)]
892#[allow(unused_lifetimes)]
893pub(crate) struct ConditionContext<'a> {
894    pub(crate) partition_result: Option<crate::endpoint_lib::partition::Partition<'a>>,
895    // Sometimes none of the members reference the lifetime, this makes it still valid
896    phantom: std::marker::PhantomData<&'a ()>,
897}
898
899#[non_exhaustive]
900#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
901/// Configuration parameters for resolving the correct endpoint
902pub struct Params {
903    /// The AWS region used to dispatch the request.
904    pub(crate) region: ::std::option::Option<::std::string::String>,
905    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
906    pub(crate) use_dual_stack: bool,
907    /// 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.
908    pub(crate) use_fips: bool,
909    /// Override the endpoint used to send this request
910    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
911}
912impl Params {
913    /// Create a builder for [`Params`]
914    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
915        crate::config::endpoint::ParamsBuilder::default()
916    }
917    /// The AWS region used to dispatch the request.
918    pub fn region(&self) -> ::std::option::Option<&str> {
919        self.region.as_deref()
920    }
921    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
922    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
923        Some(self.use_dual_stack)
924    }
925    /// 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.
926    pub fn use_fips(&self) -> ::std::option::Option<bool> {
927        Some(self.use_fips)
928    }
929    /// Override the endpoint used to send this request
930    pub fn endpoint(&self) -> ::std::option::Option<&str> {
931        self.endpoint.as_deref()
932    }
933}
934
935/// Builder for [`Params`]
936#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
937pub struct ParamsBuilder {
938    region: ::std::option::Option<::std::string::String>,
939    use_dual_stack: ::std::option::Option<bool>,
940    use_fips: ::std::option::Option<bool>,
941    endpoint: ::std::option::Option<::std::string::String>,
942}
943impl ParamsBuilder {
944    /// Consume this builder, creating [`Params`].
945    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
946        if let Some(region) = &self.region {
947            if !crate::endpoint_lib::host::is_valid_host_label(
948                region.as_ref() as &str,
949                true,
950                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
951            ) {
952                return Err(crate::config::endpoint::InvalidParams::invalid_value(
953                    "region",
954                    "must be a valid host label",
955                ));
956            }
957        };
958        Ok(
959            #[allow(clippy::unnecessary_lazy_evaluations)]
960            crate::config::endpoint::Params {
961                region: self.region,
962                use_dual_stack: self
963                    .use_dual_stack
964                    .or_else(|| Some(false))
965                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
966                use_fips: self
967                    .use_fips
968                    .or_else(|| Some(false))
969                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
970                endpoint: self.endpoint,
971            },
972        )
973    }
974    /// Sets the value for region
975    ///
976    /// The AWS region used to dispatch the request.
977    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
978        self.region = Some(value.into());
979        self
980    }
981
982    /// Sets the value for region
983    ///
984    /// The AWS region used to dispatch the request.
985    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
986        self.region = param;
987        self
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 use_dual_stack(mut self, value: impl Into<bool>) -> Self {
994        self.use_dual_stack = Some(value.into());
995        self
996    }
997
998    /// Sets the value for use_dual_stack
999    ///
1000    /// When unset, this parameter has a default value of `false`.
1001    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1002    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
1003        self.use_dual_stack = param;
1004        self
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 use_fips(mut self, value: impl Into<bool>) -> Self {
1011        self.use_fips = Some(value.into());
1012        self
1013    }
1014
1015    /// Sets the value for use_fips
1016    ///
1017    /// When unset, this parameter has a default value of `false`.
1018    /// 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.
1019    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
1020        self.use_fips = param;
1021        self
1022    }
1023    /// Sets the value for endpoint
1024    ///
1025    /// Override the endpoint used to send this request
1026    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
1027        self.endpoint = Some(value.into());
1028        self
1029    }
1030
1031    /// Sets the value for endpoint
1032    ///
1033    /// Override the endpoint used to send this request
1034    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
1035        self.endpoint = param;
1036        self
1037    }
1038}
1039
1040/// An error that occurred during endpoint resolution
1041#[derive(Debug)]
1042pub struct InvalidParams {
1043    field: std::borrow::Cow<'static, str>,
1044    kind: InvalidParamsErrorKind,
1045}
1046
1047/// The kind of invalid parameter error
1048#[derive(Debug)]
1049enum InvalidParamsErrorKind {
1050    MissingField,
1051    InvalidValue { message: &'static str },
1052}
1053
1054impl InvalidParams {
1055    #[allow(dead_code)]
1056    fn missing(field: &'static str) -> Self {
1057        Self {
1058            field: field.into(),
1059            kind: InvalidParamsErrorKind::MissingField,
1060        }
1061    }
1062
1063    #[allow(dead_code)]
1064    fn invalid_value(field: &'static str, message: &'static str) -> Self {
1065        Self {
1066            field: field.into(),
1067            kind: InvalidParamsErrorKind::InvalidValue { message },
1068        }
1069    }
1070}
1071
1072impl std::fmt::Display for InvalidParams {
1073    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1074        match self.kind {
1075            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
1076            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
1077        }
1078    }
1079}
1080
1081impl std::error::Error for InvalidParams {}