aws_sdk_cloudwatch/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 use_dual_stack = &_params.use_dual_stack;
17    #[allow(unused_variables)]
18    let use_fips = &_params.use_fips;
19    #[allow(unused_variables)]
20    let endpoint = &_params.endpoint;
21    #[allow(unused_variables)]
22    let region = &_params.region;
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 (partition_result.name()) == ("aws-us-gov") {
42                if (*use_fips) == (true) {
43                    if (*use_dual_stack) == (false) {
44                        return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
45                            .url({
46                                let mut out = String::new();
47                                out.push_str("https://monitoring.");
48                                #[allow(clippy::needless_borrow)]
49                                out.push_str(&region.as_ref() as &str);
50                                out.push('.');
51                                #[allow(clippy::needless_borrow)]
52                                out.push_str(&partition_result.dns_suffix());
53                                out
54                            })
55                            .build());
56                    }
57                }
58            }
59            if (partition_result.name()) == ("aws-us-gov") {
60                if (*use_fips) == (true) {
61                    if (*use_dual_stack) == (true) {
62                        return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
63                            .url({
64                                let mut out = String::new();
65                                out.push_str("https://monitoring.");
66                                #[allow(clippy::needless_borrow)]
67                                out.push_str(&region.as_ref() as &str);
68                                out.push('.');
69                                #[allow(clippy::needless_borrow)]
70                                out.push_str(&partition_result.dual_stack_dns_suffix());
71                                out
72                            })
73                            .build());
74                    }
75                }
76            }
77            if (*use_fips) == (true) {
78                if (*use_dual_stack) == (true) {
79                    if (true) == (partition_result.supports_fips()) {
80                        if (true) == (partition_result.supports_dual_stack()) {
81                            return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
82                                .url({
83                                    let mut out = String::new();
84                                    out.push_str("https://monitoring-fips.");
85                                    #[allow(clippy::needless_borrow)]
86                                    out.push_str(&region.as_ref() as &str);
87                                    out.push('.');
88                                    #[allow(clippy::needless_borrow)]
89                                    out.push_str(&partition_result.dual_stack_dns_suffix());
90                                    out
91                                })
92                                .build());
93                        }
94                    }
95                    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
96                        "FIPS and DualStack are enabled, but this partition does not support one or both".to_string(),
97                    ));
98                }
99            }
100            if (*use_fips) == (true) {
101                if (*use_dual_stack) == (false) {
102                    if (partition_result.supports_fips()) == (true) {
103                        return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
104                            .url({
105                                let mut out = String::new();
106                                out.push_str("https://monitoring-fips.");
107                                #[allow(clippy::needless_borrow)]
108                                out.push_str(&region.as_ref() as &str);
109                                out.push('.');
110                                #[allow(clippy::needless_borrow)]
111                                out.push_str(&partition_result.dns_suffix());
112                                out
113                            })
114                            .build());
115                    }
116                    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
117                        "FIPS is enabled but this partition does not support FIPS".to_string(),
118                    ));
119                }
120            }
121            if (*use_fips) == (false) {
122                if (*use_dual_stack) == (true) {
123                    if (true) == (partition_result.supports_dual_stack()) {
124                        return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
125                            .url({
126                                let mut out = String::new();
127                                out.push_str("https://monitoring.");
128                                #[allow(clippy::needless_borrow)]
129                                out.push_str(&region.as_ref() as &str);
130                                out.push('.');
131                                #[allow(clippy::needless_borrow)]
132                                out.push_str(&partition_result.dual_stack_dns_suffix());
133                                out
134                            })
135                            .build());
136                    }
137                    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
138                        "DualStack is enabled but this partition does not support DualStack".to_string(),
139                    ));
140                }
141            }
142            return Ok(::aws_smithy_types::endpoint::Endpoint::builder()
143                .url({
144                    let mut out = String::new();
145                    out.push_str("https://monitoring.");
146                    #[allow(clippy::needless_borrow)]
147                    out.push_str(&region.as_ref() as &str);
148                    out.push('.');
149                    #[allow(clippy::needless_borrow)]
150                    out.push_str(&partition_result.dns_suffix());
151                    out
152                })
153                .build());
154        }
155        #[allow(unreachable_code)]
156        return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(format!(
157            "No rules matched these parameters. This is a bug. {_params:?}"
158        )));
159    }
160    return Err(::aws_smithy_http::endpoint::ResolveEndpointError::message(
161        "Invalid Configuration: Missing Region".to_string(),
162    ));
163}