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