1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | /// Orchestration and serialization glue logic for `NullAndEmptyHeadersClient`.
|
3 3 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
4 4 | #[non_exhaustive]
|
5 5 | pub struct NullAndEmptyHeadersClient;
|
6 6 | impl NullAndEmptyHeadersClient {
|
7 7 | /// Creates a new `NullAndEmptyHeadersClient`
|
8 8 | pub fn new() -> Self {
|
9 9 | Self
|
10 10 | }
|
11 + | /// The schema for this operation's input shape.
|
12 + | pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
|
13 + | crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput::SCHEMA;
|
14 + | /// The schema for this operation's output shape.
|
15 + | pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
|
16 + | crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientOutput::SCHEMA;
|
11 17 | pub(crate) async fn orchestrate(
|
12 18 | runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
13 19 | input: crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput,
|
14 20 | ) -> ::std::result::Result<
|
15 21 | crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientOutput,
|
16 22 | ::aws_smithy_runtime_api::client::result::SdkError<
|
17 23 | crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientError,
|
18 24 | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
19 25 | >,
|
20 26 | > {
|
133 139 | ::std::borrow::Cow::Owned(rcb)
|
134 140 | }
|
135 141 | }
|
136 142 |
|
137 143 | #[derive(Debug)]
|
138 144 | struct NullAndEmptyHeadersClientResponseDeserializer;
|
139 145 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for NullAndEmptyHeadersClientResponseDeserializer {
|
140 146 | fn deserialize_nonstreaming(
|
141 147 | &self,
|
142 148 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
149 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
143 150 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
144 151 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
152 + | #[allow(unused_mut)]
|
153 + | let mut force_error = false;
|
154 + |
|
155 + | if !success && status != 200 || force_error {
|
145 156 | let headers = response.headers();
|
146 157 | let body = response.body().bytes().expect("body loaded");
|
147 158 | #[allow(unused_mut)]
|
148 - | let mut force_error = false;
|
159 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
160 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
161 + | })?;
|
149 162 |
|
150 - | let parse_result = if !success && status != 200 || force_error {
|
151 - | crate::protocol_serde::shape_null_and_empty_headers_client::de_null_and_empty_headers_client_http_error(status, headers, body)
|
163 + | let generic = generic_builder.build();
|
164 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
165 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
|
166 + | crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientError::generic(generic),
|
167 + | ),
|
168 + | ))
|
152 169 | } else {
|
153 - | crate::protocol_serde::shape_null_and_empty_headers_client::de_null_and_empty_headers_client_http_response(status, headers, body)
|
154 - | };
|
155 - | crate::protocol_serde::type_erase_result(parse_result)
|
170 + | let protocol = _cfg
|
171 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
172 + | .expect("a SharedClientProtocol is required");
|
173 + | let mut deser = protocol
|
174 + | .deserialize_response(response, NullAndEmptyHeadersClient::OUTPUT_SCHEMA, _cfg)
|
175 + | .map_err(|e| {
|
176 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
177 + | })?;
|
178 + | let body = response.body().bytes().expect("body loaded");
|
179 + | let output = crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientOutput::deserialize_with_response(
|
180 + | &mut *deser,
|
181 + | response.headers(),
|
182 + | response.status().into(),
|
183 + | body,
|
184 + | )
|
185 + | .map_err(|e| {
|
186 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
187 + | })?;
|
188 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
189 + | }
|
156 190 | }
|
157 191 | }
|
158 192 | #[derive(Debug)]
|
159 193 | struct NullAndEmptyHeadersClientRequestSerializer;
|
160 194 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for NullAndEmptyHeadersClientRequestSerializer {
|
161 195 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
162 196 | fn serialize_input(
|
163 197 | &self,
|
164 198 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
165 199 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
166 200 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
167 201 | let input = input
|
168 202 | .downcast::<crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput>()
|
169 203 | .expect("correct type");
|
170 - | let _header_serialization_settings = _cfg
|
171 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
172 - | .cloned()
|
173 - | .unwrap_or_default();
|
174 - | let mut request_builder = {
|
175 - | #[allow(clippy::uninlined_format_args)]
|
176 - | fn uri_base(
|
177 - | _input: &crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput,
|
178 - | output: &mut ::std::string::String,
|
179 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
180 - | use ::std::fmt::Write as _;
|
181 - | ::std::write!(output, "/NullAndEmptyHeadersClient").expect("formatting should succeed");
|
182 - | ::std::result::Result::Ok(())
|
204 + | let protocol = _cfg
|
205 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
206 + | .expect("a SharedClientProtocol is required");
|
207 + | if protocol.supports_http_bindings() {
|
208 + | let mut request = protocol
|
209 + | .serialize_body(&input, NullAndEmptyHeadersClient::INPUT_SCHEMA, "", _cfg)
|
210 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
211 + | {
|
212 + | let mut uri = "/NullAndEmptyHeadersClient".to_string();
|
213 + | let mut query_params: Vec<(String, String)> = Vec::new();
|
214 + | if let Some(ref val) = input.a {
|
215 + | request.headers_mut().insert("X-A", val.to_string());
|
216 + | }
|
217 + | if let Some(ref val) = input.b {
|
218 + | request.headers_mut().insert("X-B", val.to_string());
|
219 + | }
|
220 + | if let Some(ref val) = input.c {
|
221 + | let header_val = val
|
222 + | .iter()
|
223 + | .map(|item| {
|
224 + | let s = item.to_string();
|
225 + | if s.contains(',') || s.contains('"') {
|
226 + | format!("\"{}\"", s.replace('\\', "\\\\").replace('"', "\\\""))
|
227 + | } else {
|
228 + | s
|
229 + | }
|
230 + | })
|
231 + | .collect::<Vec<_>>()
|
232 + | .join(", ");
|
233 + | request.headers_mut().insert("X-C", header_val);
|
234 + | }
|
235 + | if !query_params.is_empty() {
|
236 + | uri.push(if uri.contains('?') { '&' } else { '?' });
|
237 + | let pairs: Vec<String> = query_params
|
238 + | .iter()
|
239 + | .map(|(k, v)| {
|
240 + | format!(
|
241 + | "{}={}",
|
242 + | ::aws_smithy_schema::http_protocol::percent_encode(k),
|
243 + | ::aws_smithy_schema::http_protocol::percent_encode(v)
|
244 + | )
|
245 + | })
|
246 + | .collect();
|
247 + | uri.push_str(&pairs.join("&"));
|
248 + | }
|
249 + | request.set_uri(uri.as_str()).expect("valid URI");
|
183 250 | }
|
184 - | #[allow(clippy::unnecessary_wraps)]
|
185 - | fn update_http_builder(
|
186 - | input: &crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput,
|
187 - | builder: ::http_1x::request::Builder,
|
188 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
189 - | let mut uri = ::std::string::String::new();
|
190 - | uri_base(input, &mut uri)?;
|
191 - | let builder = crate::protocol_serde::shape_null_and_empty_headers_client::ser_null_and_empty_headers_client_headers(input, builder)?;
|
192 - | ::std::result::Result::Ok(builder.method("GET").uri(uri))
|
193 - | }
|
194 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
195 - | builder
|
196 - | };
|
197 - | let body = ::aws_smithy_types::body::SdkBody::from("");
|
198 251 |
|
199 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
252 + | return ::std::result::Result::Ok(request);
|
253 + | } else {
|
254 + | let mut request = protocol
|
255 + | .serialize_request(&input, NullAndEmptyHeadersClient::INPUT_SCHEMA, "", _cfg)
|
256 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
257 + |
|
258 + | return ::std::result::Result::Ok(request);
|
259 + | }
|
200 260 | }
|
201 261 | }
|
202 262 | #[derive(Debug)]
|
203 263 | struct NullAndEmptyHeadersClientEndpointParamsInterceptor;
|
204 264 |
|
205 265 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for NullAndEmptyHeadersClientEndpointParamsInterceptor {
|
206 266 | fn name(&self) -> &'static str {
|
207 267 | "NullAndEmptyHeadersClientEndpointParamsInterceptor"
|
208 268 | }
|
209 269 |
|