aws_sdk_licensemanagerlinuxsubscriptions/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://license-manager-linux-subscriptions-fips.us-east-1.api.aws");
43        assert_eq!(
44            endpoint,
45            ::aws_smithy_types::endpoint::Endpoint::builder()
46                .url("https://license-manager-linux-subscriptions-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://license-manager-linux-subscriptions-fips.us-east-1.amazonaws.com");
63        assert_eq!(
64            endpoint,
65            ::aws_smithy_types::endpoint::Endpoint::builder()
66                .url("https://license-manager-linux-subscriptions-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://license-manager-linux-subscriptions.us-east-1.api.aws");
83        assert_eq!(
84            endpoint,
85            ::aws_smithy_types::endpoint::Endpoint::builder()
86                .url("https://license-manager-linux-subscriptions.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://license-manager-linux-subscriptions.us-east-1.amazonaws.com");
103        assert_eq!(
104            endpoint,
105            ::aws_smithy_types::endpoint::Endpoint::builder()
106                .url("https://license-manager-linux-subscriptions.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 =
123            endpoint.expect("Expected valid endpoint: https://license-manager-linux-subscriptions-fips.cn-north-1.api.amazonwebservices.com.cn");
124        assert_eq!(
125            endpoint,
126            ::aws_smithy_types::endpoint::Endpoint::builder()
127                .url("https://license-manager-linux-subscriptions-fips.cn-north-1.api.amazonwebservices.com.cn")
128                .build()
129        );
130    }
131
132    /// For region cn-north-1 with FIPS enabled and DualStack disabled
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(false)
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://license-manager-linux-subscriptions-fips.cn-north-1.amazonaws.com.cn");
144        assert_eq!(
145            endpoint,
146            ::aws_smithy_types::endpoint::Endpoint::builder()
147                .url("https://license-manager-linux-subscriptions-fips.cn-north-1.amazonaws.com.cn")
148                .build()
149        );
150    }
151
152    /// For region cn-north-1 with FIPS disabled and DualStack enabled
153    #[test]
154    fn test_7() {
155        let params = crate::config::endpoint::Params::builder()
156            .region("cn-north-1".to_string())
157            .use_fips(false)
158            .use_dual_stack(true)
159            .build()
160            .expect("invalid params");
161        let resolver = crate::config::endpoint::DefaultResolver::new();
162        let endpoint = resolver.resolve_endpoint(&params);
163        let endpoint =
164            endpoint.expect("Expected valid endpoint: https://license-manager-linux-subscriptions.cn-north-1.api.amazonwebservices.com.cn");
165        assert_eq!(
166            endpoint,
167            ::aws_smithy_types::endpoint::Endpoint::builder()
168                .url("https://license-manager-linux-subscriptions.cn-north-1.api.amazonwebservices.com.cn")
169                .build()
170        );
171    }
172
173    /// For region cn-north-1 with FIPS disabled and DualStack disabled
174    #[test]
175    fn test_8() {
176        let params = crate::config::endpoint::Params::builder()
177            .region("cn-north-1".to_string())
178            .use_fips(false)
179            .use_dual_stack(false)
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://license-manager-linux-subscriptions.cn-north-1.amazonaws.com.cn");
185        assert_eq!(
186            endpoint,
187            ::aws_smithy_types::endpoint::Endpoint::builder()
188                .url("https://license-manager-linux-subscriptions.cn-north-1.amazonaws.com.cn")
189                .build()
190        );
191    }
192
193    /// For region us-gov-east-1 with FIPS enabled and DualStack enabled
194    #[test]
195    fn test_9() {
196        let params = crate::config::endpoint::Params::builder()
197            .region("us-gov-east-1".to_string())
198            .use_fips(true)
199            .use_dual_stack(true)
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://license-manager-linux-subscriptions-fips.us-gov-east-1.api.aws");
205        assert_eq!(
206            endpoint,
207            ::aws_smithy_types::endpoint::Endpoint::builder()
208                .url("https://license-manager-linux-subscriptions-fips.us-gov-east-1.api.aws")
209                .build()
210        );
211    }
212
213    /// For region us-gov-east-1 with FIPS enabled and DualStack disabled
214    #[test]
215    fn test_10() {
216        let params = crate::config::endpoint::Params::builder()
217            .region("us-gov-east-1".to_string())
218            .use_fips(true)
219            .use_dual_stack(false)
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://license-manager-linux-subscriptions-fips.us-gov-east-1.amazonaws.com");
225        assert_eq!(
226            endpoint,
227            ::aws_smithy_types::endpoint::Endpoint::builder()
228                .url("https://license-manager-linux-subscriptions-fips.us-gov-east-1.amazonaws.com")
229                .build()
230        );
231    }
232
233    /// For region us-gov-east-1 with FIPS disabled and DualStack enabled
234    #[test]
235    fn test_11() {
236        let params = crate::config::endpoint::Params::builder()
237            .region("us-gov-east-1".to_string())
238            .use_fips(false)
239            .use_dual_stack(true)
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://license-manager-linux-subscriptions.us-gov-east-1.api.aws");
245        assert_eq!(
246            endpoint,
247            ::aws_smithy_types::endpoint::Endpoint::builder()
248                .url("https://license-manager-linux-subscriptions.us-gov-east-1.api.aws")
249                .build()
250        );
251    }
252
253    /// For region us-gov-east-1 with FIPS disabled and DualStack disabled
254    #[test]
255    fn test_12() {
256        let params = crate::config::endpoint::Params::builder()
257            .region("us-gov-east-1".to_string())
258            .use_fips(false)
259            .use_dual_stack(false)
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://license-manager-linux-subscriptions.us-gov-east-1.amazonaws.com");
265        assert_eq!(
266            endpoint,
267            ::aws_smithy_types::endpoint::Endpoint::builder()
268                .url("https://license-manager-linux-subscriptions.us-gov-east-1.amazonaws.com")
269                .build()
270        );
271    }
272
273    /// For region us-iso-east-1 with FIPS enabled and DualStack disabled
274    #[test]
275    fn test_13() {
276        let params = crate::config::endpoint::Params::builder()
277            .region("us-iso-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://license-manager-linux-subscriptions-fips.us-iso-east-1.c2s.ic.gov");
285        assert_eq!(
286            endpoint,
287            ::aws_smithy_types::endpoint::Endpoint::builder()
288                .url("https://license-manager-linux-subscriptions-fips.us-iso-east-1.c2s.ic.gov")
289                .build()
290        );
291    }
292
293    /// For region us-iso-east-1 with FIPS disabled and DualStack disabled
294    #[test]
295    fn test_14() {
296        let params = crate::config::endpoint::Params::builder()
297            .region("us-iso-east-1".to_string())
298            .use_fips(false)
299            .use_dual_stack(false)
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://license-manager-linux-subscriptions.us-iso-east-1.c2s.ic.gov");
305        assert_eq!(
306            endpoint,
307            ::aws_smithy_types::endpoint::Endpoint::builder()
308                .url("https://license-manager-linux-subscriptions.us-iso-east-1.c2s.ic.gov")
309                .build()
310        );
311    }
312
313    /// For region us-isob-east-1 with FIPS enabled and DualStack disabled
314    #[test]
315    fn test_15() {
316        let params = crate::config::endpoint::Params::builder()
317            .region("us-isob-east-1".to_string())
318            .use_fips(true)
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://license-manager-linux-subscriptions-fips.us-isob-east-1.sc2s.sgov.gov");
325        assert_eq!(
326            endpoint,
327            ::aws_smithy_types::endpoint::Endpoint::builder()
328                .url("https://license-manager-linux-subscriptions-fips.us-isob-east-1.sc2s.sgov.gov")
329                .build()
330        );
331    }
332
333    /// For region us-isob-east-1 with FIPS disabled and DualStack disabled
334    #[test]
335    fn test_16() {
336        let params = crate::config::endpoint::Params::builder()
337            .region("us-isob-east-1".to_string())
338            .use_fips(false)
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://license-manager-linux-subscriptions.us-isob-east-1.sc2s.sgov.gov");
345        assert_eq!(
346            endpoint,
347            ::aws_smithy_types::endpoint::Endpoint::builder()
348                .url("https://license-manager-linux-subscriptions.us-isob-east-1.sc2s.sgov.gov")
349                .build()
350        );
351    }
352
353    /// For custom endpoint with region set and fips disabled and dualstack disabled
354    #[test]
355    fn test_17() {
356        let params = crate::config::endpoint::Params::builder()
357            .region("us-east-1".to_string())
358            .use_fips(false)
359            .use_dual_stack(false)
360            .endpoint("https://example.com".to_string())
361            .build()
362            .expect("invalid params");
363        let resolver = crate::config::endpoint::DefaultResolver::new();
364        let endpoint = resolver.resolve_endpoint(&params);
365        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
366        assert_eq!(
367            endpoint,
368            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
369        );
370    }
371
372    /// For custom endpoint with region not set and fips disabled and dualstack disabled
373    #[test]
374    fn test_18() {
375        let params = crate::config::endpoint::Params::builder()
376            .use_fips(false)
377            .use_dual_stack(false)
378            .endpoint("https://example.com".to_string())
379            .build()
380            .expect("invalid params");
381        let resolver = crate::config::endpoint::DefaultResolver::new();
382        let endpoint = resolver.resolve_endpoint(&params);
383        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
384        assert_eq!(
385            endpoint,
386            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
387        );
388    }
389
390    /// For custom endpoint with fips enabled and dualstack disabled
391    #[test]
392    fn test_19() {
393        let params = crate::config::endpoint::Params::builder()
394            .region("us-east-1".to_string())
395            .use_fips(true)
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 error = endpoint.expect_err("expected error: Invalid Configuration: FIPS and custom endpoint are not supported [For custom endpoint with fips enabled and dualstack disabled]");
403        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
404    }
405
406    /// For custom endpoint with fips disabled and dualstack enabled
407    #[test]
408    fn test_20() {
409        let params = crate::config::endpoint::Params::builder()
410            .region("us-east-1".to_string())
411            .use_fips(false)
412            .use_dual_stack(true)
413            .endpoint("https://example.com".to_string())
414            .build()
415            .expect("invalid params");
416        let resolver = crate::config::endpoint::DefaultResolver::new();
417        let endpoint = resolver.resolve_endpoint(&params);
418        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]");
419        assert_eq!(
420            format!("{}", error),
421            "Invalid Configuration: Dualstack and custom endpoint are not supported"
422        )
423    }
424
425    /// Missing region
426    #[test]
427    fn test_21() {
428        let params = crate::config::endpoint::Params::builder().build().expect("invalid params");
429        let resolver = crate::config::endpoint::DefaultResolver::new();
430        let endpoint = resolver.resolve_endpoint(&params);
431        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [Missing region]");
432        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
433    }
434}
435
436/// Endpoint resolver trait specific to AWS License Manager Linux Subscriptions
437pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
438    /// Resolve an endpoint with the given parameters
439    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;
440
441    /// Convert this service-specific resolver into a `SharedEndpointResolver`
442    ///
443    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
444    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
445    where
446        Self: Sized + 'static,
447    {
448        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
449    }
450}
451
452#[derive(Debug)]
453struct DowncastParams<T>(T);
454impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
455where
456    T: ResolveEndpoint,
457{
458    fn resolve_endpoint<'a>(
459        &'a self,
460        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
461    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
462        let ep = match params.get::<crate::config::endpoint::Params>() {
463            Some(params) => self.0.resolve_endpoint(params),
464            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
465        };
466        ep
467    }
468}
469
470/// The default endpoint resolver
471#[derive(Debug, Default)]
472pub struct DefaultResolver {
473    partition_resolver: crate::endpoint_lib::partition::PartitionResolver,
474}
475
476impl DefaultResolver {
477    /// Create a new endpoint resolver with default settings
478    pub fn new() -> Self {
479        Self {
480            partition_resolver: crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER.clone(),
481        }
482    }
483
484    fn resolve_endpoint(
485        &self,
486        params: &crate::config::endpoint::Params,
487    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
488        let mut diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
489        Ok(
490            crate::config::endpoint::internals::resolve_endpoint(params, &mut diagnostic_collector, &self.partition_resolver)
491                .map_err(|err| err.with_source(diagnostic_collector.take_last_error()))?,
492        )
493    }
494}
495
496impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
497    fn resolve_endpoint(&self, params: &crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'_> {
498        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(self.resolve_endpoint(params))
499    }
500}
501
502#[non_exhaustive]
503#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
504/// Configuration parameters for resolving the correct endpoint
505pub struct Params {
506    /// The AWS region used to dispatch the request.
507    pub(crate) region: ::std::option::Option<::std::string::String>,
508    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
509    pub(crate) use_dual_stack: bool,
510    /// 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.
511    pub(crate) use_fips: bool,
512    /// Override the endpoint used to send this request
513    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
514}
515impl Params {
516    /// Create a builder for [`Params`]
517    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
518        crate::config::endpoint::ParamsBuilder::default()
519    }
520    /// The AWS region used to dispatch the request.
521    pub fn region(&self) -> ::std::option::Option<&str> {
522        self.region.as_deref()
523    }
524    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
525    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
526        Some(self.use_dual_stack)
527    }
528    /// 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.
529    pub fn use_fips(&self) -> ::std::option::Option<bool> {
530        Some(self.use_fips)
531    }
532    /// Override the endpoint used to send this request
533    pub fn endpoint(&self) -> ::std::option::Option<&str> {
534        self.endpoint.as_deref()
535    }
536}
537
538/// Builder for [`Params`]
539#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
540pub struct ParamsBuilder {
541    region: ::std::option::Option<::std::string::String>,
542    use_dual_stack: ::std::option::Option<bool>,
543    use_fips: ::std::option::Option<bool>,
544    endpoint: ::std::option::Option<::std::string::String>,
545}
546impl ParamsBuilder {
547    /// Consume this builder, creating [`Params`].
548    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
549        if let Some(region) = &self.region {
550            if !crate::endpoint_lib::host::is_valid_host_label(
551                region.as_ref() as &str,
552                true,
553                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
554            ) {
555                return Err(crate::config::endpoint::InvalidParams::invalid_value(
556                    "region",
557                    "must be a valid host label",
558                ));
559            }
560        };
561        Ok(
562            #[allow(clippy::unnecessary_lazy_evaluations)]
563            crate::config::endpoint::Params {
564                region: self.region,
565                use_dual_stack: self
566                    .use_dual_stack
567                    .or_else(|| Some(false))
568                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
569                use_fips: self
570                    .use_fips
571                    .or_else(|| Some(false))
572                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
573                endpoint: self.endpoint,
574            },
575        )
576    }
577    /// Sets the value for region
578    ///
579    /// The AWS region used to dispatch the request.
580    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
581        self.region = Some(value.into());
582        self
583    }
584
585    /// Sets the value for region
586    ///
587    /// The AWS region used to dispatch the request.
588    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
589        self.region = param;
590        self
591    }
592    /// Sets the value for use_dual_stack
593    ///
594    /// When unset, this parameter has a default value of `false`.
595    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
596    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
597        self.use_dual_stack = Some(value.into());
598        self
599    }
600
601    /// Sets the value for use_dual_stack
602    ///
603    /// When unset, this parameter has a default value of `false`.
604    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
605    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
606        self.use_dual_stack = param;
607        self
608    }
609    /// Sets the value for use_fips
610    ///
611    /// When unset, this parameter has a default value of `false`.
612    /// 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.
613    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
614        self.use_fips = Some(value.into());
615        self
616    }
617
618    /// Sets the value for use_fips
619    ///
620    /// When unset, this parameter has a default value of `false`.
621    /// 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.
622    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
623        self.use_fips = param;
624        self
625    }
626    /// Sets the value for endpoint
627    ///
628    /// Override the endpoint used to send this request
629    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
630        self.endpoint = Some(value.into());
631        self
632    }
633
634    /// Sets the value for endpoint
635    ///
636    /// Override the endpoint used to send this request
637    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
638        self.endpoint = param;
639        self
640    }
641}
642
643/// An error that occurred during endpoint resolution
644#[derive(Debug)]
645pub struct InvalidParams {
646    field: std::borrow::Cow<'static, str>,
647    kind: InvalidParamsErrorKind,
648}
649
650/// The kind of invalid parameter error
651#[derive(Debug)]
652enum InvalidParamsErrorKind {
653    MissingField,
654    InvalidValue { message: &'static str },
655}
656
657impl InvalidParams {
658    #[allow(dead_code)]
659    fn missing(field: &'static str) -> Self {
660        Self {
661            field: field.into(),
662            kind: InvalidParamsErrorKind::MissingField,
663        }
664    }
665
666    #[allow(dead_code)]
667    fn invalid_value(field: &'static str, message: &'static str) -> Self {
668        Self {
669            field: field.into(),
670            kind: InvalidParamsErrorKind::InvalidValue { message },
671        }
672    }
673}
674
675impl std::fmt::Display for InvalidParams {
676    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
677        match self.kind {
678            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
679            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
680        }
681    }
682}
683
684impl std::error::Error for InvalidParams {}
685
686mod internals;