aws_sdk_geomaps/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
10impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOverrideFeatureTrackerInterceptor {
11    fn name(&self) -> &'static str {
12        "EndpointOverrideFeatureTrackerInterceptor"
13    }
14
15    fn read_before_execution(
16        &self,
17        _context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_>,
18        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
19    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
20        if cfg.load::<::aws_types::endpoint_config::EndpointUrl>().is_some() {
21            cfg.interceptor_state()
22                .store_append(::aws_runtime::sdk_feature::AwsSdkFeature::EndpointOverride);
23        }
24        ::std::result::Result::Ok(())
25    }
26}
27
28#[cfg(test)]
29mod test {
30
31    /// For custom endpoint with region not set and fips disabled
32    #[test]
33    fn test_1() {
34        let params = crate::config::endpoint::Params::builder()
35            .endpoint("https://example.com".to_string())
36            .use_fips(false)
37            .build()
38            .expect("invalid params");
39        let resolver = crate::config::endpoint::DefaultResolver::new();
40        let endpoint = resolver.resolve_endpoint(&params);
41        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
42        assert_eq!(
43            endpoint,
44            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
45        );
46    }
47
48    /// For custom endpoint with fips enabled
49    #[test]
50    fn test_2() {
51        let params = crate::config::endpoint::Params::builder()
52            .endpoint("https://example.com".to_string())
53            .use_fips(true)
54            .build()
55            .expect("invalid params");
56        let resolver = crate::config::endpoint::DefaultResolver::new();
57        let endpoint = resolver.resolve_endpoint(&params);
58        let error = endpoint
59            .expect_err("expected error: Invalid Configuration: FIPS and custom endpoint are not supported [For custom endpoint with fips enabled]");
60        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
61    }
62
63    /// For custom endpoint with fips disabled and dualstack enabled
64    #[test]
65    fn test_3() {
66        let params = crate::config::endpoint::Params::builder()
67            .endpoint("https://example.com".to_string())
68            .use_fips(false)
69            .use_dual_stack(true)
70            .build()
71            .expect("invalid params");
72        let resolver = crate::config::endpoint::DefaultResolver::new();
73        let endpoint = resolver.resolve_endpoint(&params);
74        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]");
75        assert_eq!(
76            format!("{}", error),
77            "Invalid Configuration: Dualstack and custom endpoint are not supported"
78        )
79    }
80
81    /// For region us-east-1 with FIPS enabled and DualStack enabled
82    #[test]
83    fn test_4() {
84        let params = crate::config::endpoint::Params::builder()
85            .region("us-east-1".to_string())
86            .use_fips(true)
87            .use_dual_stack(true)
88            .build()
89            .expect("invalid params");
90        let resolver = crate::config::endpoint::DefaultResolver::new();
91        let endpoint = resolver.resolve_endpoint(&params);
92        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo-fips.us-east-1.api.aws/v2");
93        assert_eq!(
94            endpoint,
95            ::aws_smithy_types::endpoint::Endpoint::builder()
96                .url("https://maps.geo-fips.us-east-1.api.aws/v2")
97                .build()
98        );
99    }
100
101    /// For region us-east-1 with FIPS enabled and DualStack disabled
102    #[test]
103    fn test_5() {
104        let params = crate::config::endpoint::Params::builder()
105            .region("us-east-1".to_string())
106            .use_fips(true)
107            .use_dual_stack(false)
108            .build()
109            .expect("invalid params");
110        let resolver = crate::config::endpoint::DefaultResolver::new();
111        let endpoint = resolver.resolve_endpoint(&params);
112        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo-fips.us-east-1.amazonaws.com/v2");
113        assert_eq!(
114            endpoint,
115            ::aws_smithy_types::endpoint::Endpoint::builder()
116                .url("https://maps.geo-fips.us-east-1.amazonaws.com/v2")
117                .build()
118        );
119    }
120
121    /// For region us-east-1 with FIPS disabled and DualStack enabled
122    #[test]
123    fn test_6() {
124        let params = crate::config::endpoint::Params::builder()
125            .region("us-east-1".to_string())
126            .use_fips(false)
127            .use_dual_stack(true)
128            .build()
129            .expect("invalid params");
130        let resolver = crate::config::endpoint::DefaultResolver::new();
131        let endpoint = resolver.resolve_endpoint(&params);
132        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo.us-east-1.api.aws/v2");
133        assert_eq!(
134            endpoint,
135            ::aws_smithy_types::endpoint::Endpoint::builder()
136                .url("https://maps.geo.us-east-1.api.aws/v2")
137                .build()
138        );
139    }
140
141    /// For region us-east-1 with FIPS disabled and DualStack disabled
142    #[test]
143    fn test_7() {
144        let params = crate::config::endpoint::Params::builder()
145            .region("us-east-1".to_string())
146            .use_fips(false)
147            .use_dual_stack(false)
148            .build()
149            .expect("invalid params");
150        let resolver = crate::config::endpoint::DefaultResolver::new();
151        let endpoint = resolver.resolve_endpoint(&params);
152        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo.us-east-1.amazonaws.com/v2");
153        assert_eq!(
154            endpoint,
155            ::aws_smithy_types::endpoint::Endpoint::builder()
156                .url("https://maps.geo.us-east-1.amazonaws.com/v2")
157                .build()
158        );
159    }
160
161    /// For region cn-northwest-1 with FIPS enabled and DualStack enabled
162    #[test]
163    fn test_8() {
164        let params = crate::config::endpoint::Params::builder()
165            .region("cn-northwest-1".to_string())
166            .use_fips(true)
167            .use_dual_stack(true)
168            .build()
169            .expect("invalid params");
170        let resolver = crate::config::endpoint::DefaultResolver::new();
171        let endpoint = resolver.resolve_endpoint(&params);
172        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.cn-northwest-1.api.amazonwebservices.com.cn");
173        assert_eq!(
174            endpoint,
175            ::aws_smithy_types::endpoint::Endpoint::builder()
176                .url("https://geo-maps-fips.cn-northwest-1.api.amazonwebservices.com.cn")
177                .build()
178        );
179    }
180
181    /// For region cn-northwest-1 with FIPS enabled and DualStack disabled
182    #[test]
183    fn test_9() {
184        let params = crate::config::endpoint::Params::builder()
185            .region("cn-northwest-1".to_string())
186            .use_fips(true)
187            .use_dual_stack(false)
188            .build()
189            .expect("invalid params");
190        let resolver = crate::config::endpoint::DefaultResolver::new();
191        let endpoint = resolver.resolve_endpoint(&params);
192        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.cn-northwest-1.amazonaws.com.cn");
193        assert_eq!(
194            endpoint,
195            ::aws_smithy_types::endpoint::Endpoint::builder()
196                .url("https://geo-maps-fips.cn-northwest-1.amazonaws.com.cn")
197                .build()
198        );
199    }
200
201    /// For region cn-northwest-1 with FIPS disabled and DualStack enabled
202    #[test]
203    fn test_10() {
204        let params = crate::config::endpoint::Params::builder()
205            .region("cn-northwest-1".to_string())
206            .use_fips(false)
207            .use_dual_stack(true)
208            .build()
209            .expect("invalid params");
210        let resolver = crate::config::endpoint::DefaultResolver::new();
211        let endpoint = resolver.resolve_endpoint(&params);
212        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.cn-northwest-1.api.amazonwebservices.com.cn");
213        assert_eq!(
214            endpoint,
215            ::aws_smithy_types::endpoint::Endpoint::builder()
216                .url("https://geo-maps.cn-northwest-1.api.amazonwebservices.com.cn")
217                .build()
218        );
219    }
220
221    /// For region cn-northwest-1 with FIPS disabled and DualStack disabled
222    #[test]
223    fn test_11() {
224        let params = crate::config::endpoint::Params::builder()
225            .region("cn-northwest-1".to_string())
226            .use_fips(false)
227            .use_dual_stack(false)
228            .build()
229            .expect("invalid params");
230        let resolver = crate::config::endpoint::DefaultResolver::new();
231        let endpoint = resolver.resolve_endpoint(&params);
232        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.cn-northwest-1.amazonaws.com.cn");
233        assert_eq!(
234            endpoint,
235            ::aws_smithy_types::endpoint::Endpoint::builder()
236                .url("https://geo-maps.cn-northwest-1.amazonaws.com.cn")
237                .build()
238        );
239    }
240
241    /// For region us-gov-west-1 with FIPS enabled and DualStack enabled
242    #[test]
243    fn test_12() {
244        let params = crate::config::endpoint::Params::builder()
245            .region("us-gov-west-1".to_string())
246            .use_fips(true)
247            .use_dual_stack(true)
248            .build()
249            .expect("invalid params");
250        let resolver = crate::config::endpoint::DefaultResolver::new();
251        let endpoint = resolver.resolve_endpoint(&params);
252        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo-fips.us-gov-west-1.api.aws/v2");
253        assert_eq!(
254            endpoint,
255            ::aws_smithy_types::endpoint::Endpoint::builder()
256                .url("https://maps.geo-fips.us-gov-west-1.api.aws/v2")
257                .build()
258        );
259    }
260
261    /// For region us-gov-west-1 with FIPS enabled and DualStack disabled
262    #[test]
263    fn test_13() {
264        let params = crate::config::endpoint::Params::builder()
265            .region("us-gov-west-1".to_string())
266            .use_fips(true)
267            .use_dual_stack(false)
268            .build()
269            .expect("invalid params");
270        let resolver = crate::config::endpoint::DefaultResolver::new();
271        let endpoint = resolver.resolve_endpoint(&params);
272        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo-fips.us-gov-west-1.amazonaws.com/v2");
273        assert_eq!(
274            endpoint,
275            ::aws_smithy_types::endpoint::Endpoint::builder()
276                .url("https://maps.geo-fips.us-gov-west-1.amazonaws.com/v2")
277                .build()
278        );
279    }
280
281    /// For region us-gov-west-1 with FIPS disabled and DualStack enabled
282    #[test]
283    fn test_14() {
284        let params = crate::config::endpoint::Params::builder()
285            .region("us-gov-west-1".to_string())
286            .use_fips(false)
287            .use_dual_stack(true)
288            .build()
289            .expect("invalid params");
290        let resolver = crate::config::endpoint::DefaultResolver::new();
291        let endpoint = resolver.resolve_endpoint(&params);
292        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo.us-gov-west-1.api.aws/v2");
293        assert_eq!(
294            endpoint,
295            ::aws_smithy_types::endpoint::Endpoint::builder()
296                .url("https://maps.geo.us-gov-west-1.api.aws/v2")
297                .build()
298        );
299    }
300
301    /// For region us-gov-west-1 with FIPS disabled and DualStack disabled
302    #[test]
303    fn test_15() {
304        let params = crate::config::endpoint::Params::builder()
305            .region("us-gov-west-1".to_string())
306            .use_fips(false)
307            .use_dual_stack(false)
308            .build()
309            .expect("invalid params");
310        let resolver = crate::config::endpoint::DefaultResolver::new();
311        let endpoint = resolver.resolve_endpoint(&params);
312        let endpoint = endpoint.expect("Expected valid endpoint: https://maps.geo.us-gov-west-1.amazonaws.com/v2");
313        assert_eq!(
314            endpoint,
315            ::aws_smithy_types::endpoint::Endpoint::builder()
316                .url("https://maps.geo.us-gov-west-1.amazonaws.com/v2")
317                .build()
318        );
319    }
320
321    /// For region us-iso-east-1 with FIPS enabled and DualStack disabled
322    #[test]
323    fn test_16() {
324        let params = crate::config::endpoint::Params::builder()
325            .region("us-iso-east-1".to_string())
326            .use_fips(true)
327            .use_dual_stack(false)
328            .build()
329            .expect("invalid params");
330        let resolver = crate::config::endpoint::DefaultResolver::new();
331        let endpoint = resolver.resolve_endpoint(&params);
332        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.us-iso-east-1.c2s.ic.gov");
333        assert_eq!(
334            endpoint,
335            ::aws_smithy_types::endpoint::Endpoint::builder()
336                .url("https://geo-maps-fips.us-iso-east-1.c2s.ic.gov")
337                .build()
338        );
339    }
340
341    /// For region us-iso-east-1 with FIPS disabled and DualStack disabled
342    #[test]
343    fn test_17() {
344        let params = crate::config::endpoint::Params::builder()
345            .region("us-iso-east-1".to_string())
346            .use_fips(false)
347            .use_dual_stack(false)
348            .build()
349            .expect("invalid params");
350        let resolver = crate::config::endpoint::DefaultResolver::new();
351        let endpoint = resolver.resolve_endpoint(&params);
352        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.us-iso-east-1.c2s.ic.gov");
353        assert_eq!(
354            endpoint,
355            ::aws_smithy_types::endpoint::Endpoint::builder()
356                .url("https://geo-maps.us-iso-east-1.c2s.ic.gov")
357                .build()
358        );
359    }
360
361    /// For region us-isob-east-1 with FIPS enabled and DualStack disabled
362    #[test]
363    fn test_18() {
364        let params = crate::config::endpoint::Params::builder()
365            .region("us-isob-east-1".to_string())
366            .use_fips(true)
367            .use_dual_stack(false)
368            .build()
369            .expect("invalid params");
370        let resolver = crate::config::endpoint::DefaultResolver::new();
371        let endpoint = resolver.resolve_endpoint(&params);
372        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.us-isob-east-1.sc2s.sgov.gov");
373        assert_eq!(
374            endpoint,
375            ::aws_smithy_types::endpoint::Endpoint::builder()
376                .url("https://geo-maps-fips.us-isob-east-1.sc2s.sgov.gov")
377                .build()
378        );
379    }
380
381    /// For region us-isob-east-1 with FIPS disabled and DualStack disabled
382    #[test]
383    fn test_19() {
384        let params = crate::config::endpoint::Params::builder()
385            .region("us-isob-east-1".to_string())
386            .use_fips(false)
387            .use_dual_stack(false)
388            .build()
389            .expect("invalid params");
390        let resolver = crate::config::endpoint::DefaultResolver::new();
391        let endpoint = resolver.resolve_endpoint(&params);
392        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.us-isob-east-1.sc2s.sgov.gov");
393        assert_eq!(
394            endpoint,
395            ::aws_smithy_types::endpoint::Endpoint::builder()
396                .url("https://geo-maps.us-isob-east-1.sc2s.sgov.gov")
397                .build()
398        );
399    }
400
401    /// For region eu-isoe-west-1 with FIPS enabled and DualStack disabled
402    #[test]
403    fn test_20() {
404        let params = crate::config::endpoint::Params::builder()
405            .region("eu-isoe-west-1".to_string())
406            .use_fips(true)
407            .use_dual_stack(false)
408            .build()
409            .expect("invalid params");
410        let resolver = crate::config::endpoint::DefaultResolver::new();
411        let endpoint = resolver.resolve_endpoint(&params);
412        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.eu-isoe-west-1.cloud.adc-e.uk");
413        assert_eq!(
414            endpoint,
415            ::aws_smithy_types::endpoint::Endpoint::builder()
416                .url("https://geo-maps-fips.eu-isoe-west-1.cloud.adc-e.uk")
417                .build()
418        );
419    }
420
421    /// For region eu-isoe-west-1 with FIPS disabled and DualStack disabled
422    #[test]
423    fn test_21() {
424        let params = crate::config::endpoint::Params::builder()
425            .region("eu-isoe-west-1".to_string())
426            .use_fips(false)
427            .use_dual_stack(false)
428            .build()
429            .expect("invalid params");
430        let resolver = crate::config::endpoint::DefaultResolver::new();
431        let endpoint = resolver.resolve_endpoint(&params);
432        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.eu-isoe-west-1.cloud.adc-e.uk");
433        assert_eq!(
434            endpoint,
435            ::aws_smithy_types::endpoint::Endpoint::builder()
436                .url("https://geo-maps.eu-isoe-west-1.cloud.adc-e.uk")
437                .build()
438        );
439    }
440
441    /// For region us-isof-south-1 with FIPS enabled and DualStack disabled
442    #[test]
443    fn test_22() {
444        let params = crate::config::endpoint::Params::builder()
445            .region("us-isof-south-1".to_string())
446            .use_fips(true)
447            .use_dual_stack(false)
448            .build()
449            .expect("invalid params");
450        let resolver = crate::config::endpoint::DefaultResolver::new();
451        let endpoint = resolver.resolve_endpoint(&params);
452        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.us-isof-south-1.csp.hci.ic.gov");
453        assert_eq!(
454            endpoint,
455            ::aws_smithy_types::endpoint::Endpoint::builder()
456                .url("https://geo-maps-fips.us-isof-south-1.csp.hci.ic.gov")
457                .build()
458        );
459    }
460
461    /// For region us-isof-south-1 with FIPS disabled and DualStack disabled
462    #[test]
463    fn test_23() {
464        let params = crate::config::endpoint::Params::builder()
465            .region("us-isof-south-1".to_string())
466            .use_fips(false)
467            .use_dual_stack(false)
468            .build()
469            .expect("invalid params");
470        let resolver = crate::config::endpoint::DefaultResolver::new();
471        let endpoint = resolver.resolve_endpoint(&params);
472        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.us-isof-south-1.csp.hci.ic.gov");
473        assert_eq!(
474            endpoint,
475            ::aws_smithy_types::endpoint::Endpoint::builder()
476                .url("https://geo-maps.us-isof-south-1.csp.hci.ic.gov")
477                .build()
478        );
479    }
480
481    /// For region eusc-de-east-1 with FIPS enabled and DualStack disabled
482    #[test]
483    fn test_24() {
484        let params = crate::config::endpoint::Params::builder()
485            .region("eusc-de-east-1".to_string())
486            .use_fips(true)
487            .use_dual_stack(false)
488            .build()
489            .expect("invalid params");
490        let resolver = crate::config::endpoint::DefaultResolver::new();
491        let endpoint = resolver.resolve_endpoint(&params);
492        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps-fips.eusc-de-east-1.amazonaws.eu");
493        assert_eq!(
494            endpoint,
495            ::aws_smithy_types::endpoint::Endpoint::builder()
496                .url("https://geo-maps-fips.eusc-de-east-1.amazonaws.eu")
497                .build()
498        );
499    }
500
501    /// For region eusc-de-east-1 with FIPS disabled and DualStack disabled
502    #[test]
503    fn test_25() {
504        let params = crate::config::endpoint::Params::builder()
505            .region("eusc-de-east-1".to_string())
506            .use_fips(false)
507            .use_dual_stack(false)
508            .build()
509            .expect("invalid params");
510        let resolver = crate::config::endpoint::DefaultResolver::new();
511        let endpoint = resolver.resolve_endpoint(&params);
512        let endpoint = endpoint.expect("Expected valid endpoint: https://geo-maps.eusc-de-east-1.amazonaws.eu");
513        assert_eq!(
514            endpoint,
515            ::aws_smithy_types::endpoint::Endpoint::builder()
516                .url("https://geo-maps.eusc-de-east-1.amazonaws.eu")
517                .build()
518        );
519    }
520
521    /// Missing region
522    #[test]
523    fn test_26() {
524        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
525        let resolver = crate::config::endpoint::DefaultResolver::new();
526        let endpoint = resolver.resolve_endpoint(&params);
527        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
528        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
529    }
530}
531
532/// Endpoint resolver trait specific to Amazon Location Service Maps V2
533pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
534    /// Resolve an endpoint with the given parameters
535    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
536
537    /// Convert this service-specific resolver into a `SharedEndpointResolver`
538    ///
539    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
540    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
541    where
542        Self: Sized + 'static,
543    {
544        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
545    }
546}
547
548#[derive(Debug)]
549struct DowncastParams<T>(T);
550impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
551where
552    T: ResolveEndpoint,
553{
554    fn resolve_endpoint<'a>(
555        &'a self,
556        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
557    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
558        let ep = match params.get::<crate::config::endpoint::Params>() {
559            Some(params) => self.0.resolve_endpoint(params),
560            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
561        };
562        ep
563    }
564}
565
566/// The default endpoint resolver
567#[derive(Debug, Default)]
568pub struct DefaultResolver {
569    partition_resolver: crate::endpoint_lib::partition::PartitionResolver,
570}
571
572impl DefaultResolver {
573    /// Create a new endpoint resolver with default settings
574    pub fn new() -> Self {
575        Self {
576            partition_resolver: crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER.clone(),
577        }
578    }
579
580    fn resolve_endpoint(
581        &self,
582        params: &crate::config::endpoint::Params,
583    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
584        let mut diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
585        Ok(
586            crate::config::endpoint::internals::resolve_endpoint(params, &mut diagnostic_collector, &self.partition_resolver)
587                .map_err(|err| err.with_source(diagnostic_collector.take_last_error()))?,
588        )
589    }
590}
591
592impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
593    fn resolve_endpoint(&self, params: &crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'_> {
594        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(self.resolve_endpoint(params))
595    }
596}
597
598#[non_exhaustive]
599#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
600/// Configuration parameters for resolving the correct endpoint
601pub struct Params {
602    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
603    pub(crate) use_dual_stack: bool,
604    /// 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.
605    pub(crate) use_fips: bool,
606    /// Override the endpoint used to send this request
607    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
608    /// The AWS region used to dispatch the request.
609    pub(crate) region: ::std::option::Option<::std::string::String>,
610}
611impl Params {
612    /// Create a builder for [`Params`]
613    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
614        crate::config::endpoint::ParamsBuilder::default()
615    }
616    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
617    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
618        Some(self.use_dual_stack)
619    }
620    /// 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.
621    pub fn use_fips(&self) -> ::std::option::Option<bool> {
622        Some(self.use_fips)
623    }
624    /// Override the endpoint used to send this request
625    pub fn endpoint(&self) -> ::std::option::Option<&str> {
626        self.endpoint.as_deref()
627    }
628    /// The AWS region used to dispatch the request.
629    pub fn region(&self) -> ::std::option::Option<&str> {
630        self.region.as_deref()
631    }
632}
633
634/// Builder for [`Params`]
635#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
636pub struct ParamsBuilder {
637    use_dual_stack: ::std::option::Option<bool>,
638    use_fips: ::std::option::Option<bool>,
639    endpoint: ::std::option::Option<::std::string::String>,
640    region: ::std::option::Option<::std::string::String>,
641}
642impl ParamsBuilder {
643    /// Consume this builder, creating [`Params`].
644    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
645        if let Some(region) = &self.region {
646            if !crate::endpoint_lib::host::is_valid_host_label(
647                region.as_ref() as &str,
648                true,
649                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
650            ) {
651                return Err(crate::config::endpoint::InvalidParams::invalid_value(
652                    "region",
653                    "must be a valid host label",
654                ));
655            }
656        };
657        Ok(
658            #[allow(clippy::unnecessary_lazy_evaluations)]
659            crate::config::endpoint::Params {
660                use_dual_stack: self
661                    .use_dual_stack
662                    .or_else(|| Some(false))
663                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
664                use_fips: self
665                    .use_fips
666                    .or_else(|| Some(false))
667                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
668                endpoint: self.endpoint,
669                region: self.region,
670            },
671        )
672    }
673    /// Sets the value for use_dual_stack
674    ///
675    /// When unset, this parameter has a default value of `false`.
676    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
677    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
678        self.use_dual_stack = Some(value.into());
679        self
680    }
681
682    /// Sets the value for use_dual_stack
683    ///
684    /// When unset, this parameter has a default value of `false`.
685    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
686    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
687        self.use_dual_stack = param;
688        self
689    }
690    /// Sets the value for use_fips
691    ///
692    /// When unset, this parameter has a default value of `false`.
693    /// 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.
694    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
695        self.use_fips = Some(value.into());
696        self
697    }
698
699    /// Sets the value for use_fips
700    ///
701    /// When unset, this parameter has a default value of `false`.
702    /// 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.
703    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
704        self.use_fips = param;
705        self
706    }
707    /// Sets the value for endpoint
708    ///
709    /// Override the endpoint used to send this request
710    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
711        self.endpoint = Some(value.into());
712        self
713    }
714
715    /// Sets the value for endpoint
716    ///
717    /// Override the endpoint used to send this request
718    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
719        self.endpoint = param;
720        self
721    }
722    /// Sets the value for region
723    ///
724    /// The AWS region used to dispatch the request.
725    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
726        self.region = Some(value.into());
727        self
728    }
729
730    /// Sets the value for region
731    ///
732    /// The AWS region used to dispatch the request.
733    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
734        self.region = param;
735        self
736    }
737}
738
739/// An error that occurred during endpoint resolution
740#[derive(Debug)]
741pub struct InvalidParams {
742    field: std::borrow::Cow<'static, str>,
743    kind: InvalidParamsErrorKind,
744}
745
746/// The kind of invalid parameter error
747#[derive(Debug)]
748enum InvalidParamsErrorKind {
749    MissingField,
750    InvalidValue { message: &'static str },
751}
752
753impl InvalidParams {
754    #[allow(dead_code)]
755    fn missing(field: &'static str) -> Self {
756        Self {
757            field: field.into(),
758            kind: InvalidParamsErrorKind::MissingField,
759        }
760    }
761
762    #[allow(dead_code)]
763    fn invalid_value(field: &'static str, message: &'static str) -> Self {
764        Self {
765            field: field.into(),
766            kind: InvalidParamsErrorKind::InvalidValue { message },
767        }
768    }
769}
770
771impl std::fmt::Display for InvalidParams {
772    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
773        match self.kind {
774            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
775            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
776        }
777    }
778}
779
780impl std::error::Error for InvalidParams {}
781
782mod internals;