132 138 | ::std::borrow::Cow::Owned(rcb)
|
133 139 | }
|
134 140 | }
|
135 141 |
|
136 142 | #[derive(Debug)]
|
137 143 | struct DuplexStreamWithDistinctStreamsResponseDeserializer;
|
138 144 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for DuplexStreamWithDistinctStreamsResponseDeserializer {
|
139 145 | fn deserialize_nonstreaming(
|
140 146 | &self,
|
141 147 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
148 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
142 149 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
143 150 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
144 - | let headers = response.headers();
|
145 - | let body = response.body().bytes().expect("body loaded");
|
146 151 | #[allow(unused_mut)]
|
147 152 | let mut force_error = false;
|
148 153 |
|
149 - | let parse_result = if !success && status != 200 || force_error {
|
150 - | crate::protocol_serde::shape_duplex_stream_with_distinct_streams::de_duplex_stream_with_distinct_streams_http_error(status, headers, body)
|
154 + | if !success && status != 200 || force_error {
|
155 + | let headers = response.headers();
|
156 + | let body = response.body().bytes().expect("body loaded");
|
157 + | #[allow(unused_mut)]
|
158 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
159 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
160 + | })?;
|
161 + |
|
162 + | let generic = generic_builder.build();
|
163 + | let error_code = match generic.code() {
|
164 + | ::std::option::Option::Some(code) => code,
|
165 + | ::std::option::Option::None => {
|
166 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
167 + | ::aws_smithy_runtime_api::box_error::BoxError::from(
|
168 + | crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::unhandled(generic),
|
169 + | ),
|
170 + | ))
|
171 + | }
|
172 + | };
|
173 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
174 + | let protocol = _cfg
|
175 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
176 + | .expect("a SharedClientProtocol is required");
|
177 + | let err = match error_code {
|
178 + | "ErrorEvent" => crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::ErrorEvent({
|
179 + | let mut tmp = match protocol
|
180 + | .deserialize_response(response, crate::types::error::ErrorEvent::SCHEMA, _cfg)
|
181 + | .and_then(|mut deser| {
|
182 + | crate::types::error::ErrorEvent::deserialize_with_response(
|
183 + | &mut *deser,
|
184 + | response.headers(),
|
185 + | response.status().into(),
|
186 + | body,
|
187 + | )
|
188 + | }) {
|
189 + | ::std::result::Result::Ok(val) => val,
|
190 + | ::std::result::Result::Err(e) => {
|
191 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
192 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
193 + | ))
|
194 + | }
|
195 + | };
|
196 + | tmp.meta = generic;
|
197 + | if tmp.message.is_none() {
|
198 + | tmp.message = _error_message;
|
199 + | }
|
200 + | tmp
|
201 + | }),
|
202 + | _ => crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::generic(generic),
|
203 + | };
|
204 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
205 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
206 + | ))
|
151 207 | } else {
|
152 - | crate::protocol_serde::shape_duplex_stream_with_distinct_streams::de_duplex_stream_with_distinct_streams_http_response(
|
153 - | status, headers, body,
|
208 + | let protocol = _cfg
|
209 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
210 + | .expect("a SharedClientProtocol is required");
|
211 + | let mut deser = protocol
|
212 + | .deserialize_response(response, DuplexStreamWithDistinctStreams::OUTPUT_SCHEMA, _cfg)
|
213 + | .map_err(|e| {
|
214 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
215 + | })?;
|
216 + | let body = response.body().bytes().expect("body loaded");
|
217 + | let output = crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput::deserialize_with_response(
|
218 + | &mut *deser,
|
219 + | response.headers(),
|
220 + | response.status().into(),
|
221 + | body,
|
154 222 | )
|
155 - | };
|
156 - | crate::protocol_serde::type_erase_result(parse_result)
|
223 + | .map_err(|e| {
|
224 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
225 + | })?;
|
226 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
227 + | }
|
157 228 | }
|
158 229 | }
|
159 230 | #[derive(Debug)]
|
160 231 | struct DuplexStreamWithDistinctStreamsRequestSerializer;
|
161 232 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DuplexStreamWithDistinctStreamsRequestSerializer {
|
162 233 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
163 234 | fn serialize_input(
|
164 235 | &self,
|
165 236 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
166 237 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
167 238 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
168 239 | let input = input
|
169 240 | .downcast::<crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput>()
|
170 241 | .expect("correct type");
|
171 - | let _header_serialization_settings = _cfg
|
172 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
173 - | .cloned()
|
174 - | .unwrap_or_default();
|
175 - | let mut request_builder = {
|
176 - | #[allow(clippy::uninlined_format_args)]
|
177 - | fn uri_base(
|
178 - | _input: &crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput,
|
179 - | output: &mut ::std::string::String,
|
180 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
181 - | use ::std::fmt::Write as _;
|
182 - | ::std::write!(output, "/DuplexStreamWithDistinctStreams").expect("formatting should succeed");
|
183 - | ::std::result::Result::Ok(())
|
184 - | }
|
185 - | #[allow(clippy::unnecessary_wraps)]
|
186 - | fn update_http_builder(
|
187 - | input: &crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput,
|
188 - | builder: ::http_1x::request::Builder,
|
189 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
190 - | let mut uri = ::std::string::String::new();
|
191 - | uri_base(input, &mut uri)?;
|
192 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
193 - | }
|
194 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
195 - | builder =
|
196 - | _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
|
197 - | builder
|
198 - | };
|
199 - | let body = ::aws_smithy_types::body::SdkBody::from({
|
242 + | let protocol = _cfg
|
243 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
244 + | .expect("a SharedClientProtocol is required");
|
245 + | let mut request = protocol
|
246 + | .serialize_request(&input, DuplexStreamWithDistinctStreams::INPUT_SCHEMA, "", _cfg)
|
247 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
248 + | *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
|
200 249 | let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
|
201 250 | let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
|
202 251 | let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
|
203 252 | _cfg.interceptor_state().store_put(signer_sender);
|
204 253 | ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.stream.into_body_stream(
|
205 254 | marshaller,
|
206 255 | error_marshaller,
|
207 256 | signer,
|
208 257 | )))
|
209 258 | });
|
210 - | if let Some(content_length) = body.content_length() {
|
211 - | let content_length = content_length.to_string();
|
212 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
213 - | }
|
214 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
259 + | // The protocol may have set Content-Length based on the initial empty body.
|
260 + | // Remove it since the event stream body has unknown length.
|
261 + | request.headers_mut().remove("Content-Length");
|
262 + | request.headers_mut().insert("Content-Type", "application/vnd.amazon.eventstream");
|
263 + |
|
264 + | return ::std::result::Result::Ok(request);
|
215 265 | }
|
216 266 | }
|
217 267 | #[derive(Debug)]
|
218 268 | struct DuplexStreamWithDistinctStreamsEndpointParamsInterceptor;
|
219 269 |
|
220 270 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DuplexStreamWithDistinctStreamsEndpointParamsInterceptor {
|
221 271 | fn name(&self) -> &'static str {
|
222 272 | "DuplexStreamWithDistinctStreamsEndpointParamsInterceptor"
|
223 273 | }
|
224 274 |
|