aws_sdk_datasync/config/endpoint/
internals.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(
3    clippy::collapsible_if,
4    clippy::bool_comparison,
5    clippy::nonminimal_bool,
6    clippy::comparison_to_empty,
7    clippy::redundant_pattern_matching,
8    clippy::useless_asref
9)]
10pub(super) fn resolve_endpoint(
11    _params: &crate::config::endpoint::Params,
12    _diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector,
13    partition_resolver: &crate::endpoint_lib::partition::PartitionResolver,
14) -> ::aws_smithy_http::endpoint::Result {
15    #[allow(unused_variables)]
16    let region = &_params.region;
17    #[allow(unused_variables)]
18    let use_dual_stack = &_params.use_dual_stack;
19    #[allow(unused_variables)]
20    let use_fips = &_params.use_fips;
21    #[allow(unused_variables)]
22    let endpoint = &_params.endpoint;
23    #[allow(unused_variables)]
24    if let Some(endpoint) = endpoint {
25        if (*use_fips) == (true) {
26            return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
27                "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
28            ));
29        }
30        if (*use_dual_stack) == (true) {
31            return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
32                "Invalid Configuration: Dualstack and custom endpoint are not supported".to_string(),
33            ));
34        }
35        return Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build());
36    }
37    #[allow(unused_variables)]
38    if let Some(region) = region {
39        #[allow(unused_variables)]
40        if let Some(partition_result) = partition_resolver.resolve_partition(region.as_ref() as &str, _diagnostic_collector) {
41            if (*use_fips) == (true) {
42                if (*use_dual_stack) == (true) {
43                    if (true) == (partition_result.supports_fips()) {
44                        if (true) == (partition_result.supports_dual_stack()) {
45                            return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
46                                .url({
47                                    let mut out = String::new();
48                                    out.push_str("https://datasync-fips.");
49                                    #[allow(clippy::needless_borrow)]
50                                    out.push_str(&region.as_ref() as &str);
51                                    out.push('.');
52                                    #[allow(clippy::needless_borrow)]
53                                    out.push_str(&partition_result.dual_stack_dns_suffix());
54                                    out
55                                })
56                                .build());
57                        }
58                    }
59                    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
60                        "FIPS and DualStack are enabled, but this partition does not support one or both".to_string(),
61                    ));
62                }
63            }
64            if (*use_fips) == (true) {
65                if (partition_result.supports_fips()) == (true) {
66                    return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
67                        .url({
68                            let mut out = String::new();
69                            out.push_str("https://datasync-fips.");
70                            #[allow(clippy::needless_borrow)]
71                            out.push_str(&region.as_ref() as &str);
72                            out.push('.');
73                            #[allow(clippy::needless_borrow)]
74                            out.push_str(&partition_result.dns_suffix());
75                            out
76                        })
77                        .build());
78                }
79                return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
80                    "FIPS is enabled but this partition does not support FIPS".to_string(),
81                ));
82            }
83            if (*use_dual_stack) == (true) {
84                if (true) == (partition_result.supports_dual_stack()) {
85                    return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
86                        .url({
87                            let mut out = String::new();
88                            out.push_str("https://datasync.");
89                            #[allow(clippy::needless_borrow)]
90                            out.push_str(&region.as_ref() as &str);
91                            out.push('.');
92                            #[allow(clippy::needless_borrow)]
93                            out.push_str(&partition_result.dual_stack_dns_suffix());
94                            out
95                        })
96                        .build());
97                }
98                return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
99                    "DualStack is enabled but this partition does not support DualStack".to_string(),
100                ));
101            }
102            return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
103                .url({
104                    let mut out = String::new();
105                    out.push_str("https://datasync.");
106                    #[allow(clippy::needless_borrow)]
107                    out.push_str(&region.as_ref() as &str);
108                    out.push('.');
109                    #[allow(clippy::needless_borrow)]
110                    out.push_str(&partition_result.dns_suffix());
111                    out
112                })
113                .build());
114        }
115        #[allow(unreachable_code)]
116        return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(format!(
117            "No rules matched these parameters. This is a bug. {:?}",
118            _params
119        )));
120    }
121    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
122        "Invalid Configuration: Missing Region".to_string(),
123    ));
124}