Skip to main content

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