Skip to main content

aws_sdk_machinelearning/config/
endpoint.rs

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