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