139 143 |
|
140 144 | // If this is an error, defer to the non-streaming parser
|
141 145 | if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
|
142 146 | return ::std::option::Option::None;
|
143 147 | }
|
144 148 | ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
|
145 149 | crate::protocol_serde::shape_output_stream::de_output_stream_http_response(response),
|
146 150 | ))
|
147 151 | }
|
148 152 |
|
149 - | fn deserialize_nonstreaming(
|
153 + | fn deserialize_nonstreaming_with_config(
|
150 154 | &self,
|
151 155 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
156 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
152 157 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
153 158 | // For streaming operations, we only hit this case if its an error
|
154 159 | let body = response.body().bytes().expect("body loaded");
|
155 - | crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_output_stream::de_output_stream_http_error(
|
156 - | response.status().as_u16(),
|
157 - | response.headers(),
|
158 - | body,
|
160 + | let status = response.status().as_u16();
|
161 + | let headers = response.headers();
|
162 + | #[allow(unused_mut)]
|
163 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
164 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
165 + | })?;
|
166 + |
|
167 + | let generic = generic_builder.build();
|
168 + | let error_code = match generic.code() {
|
169 + | ::std::option::Option::Some(code) => code,
|
170 + | ::std::option::Option::None => {
|
171 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
172 + | ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::output_stream::OutputStreamError::unhandled(generic)),
|
173 + | ))
|
174 + | }
|
175 + | };
|
176 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
177 + | let protocol = _cfg
|
178 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
179 + | .expect("a SharedClientProtocol is required");
|
180 + | let err = match error_code {
|
181 + | "ServiceUnavailableError" => crate::operation::output_stream::OutputStreamError::ServiceUnavailableError({
|
182 + | let mut tmp = match protocol
|
183 + | .deserialize_response(response, crate::types::error::ServiceUnavailableError::SCHEMA, _cfg)
|
184 + | .and_then(|mut deser| {
|
185 + | crate::types::error::ServiceUnavailableError::deserialize_with_response(
|
186 + | &mut *deser,
|
187 + | response.headers(),
|
188 + | response.status().into(),
|
189 + | body,
|
190 + | )
|
191 + | }) {
|
192 + | ::std::result::Result::Ok(val) => val,
|
193 + | ::std::result::Result::Err(e) => {
|
194 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
195 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
196 + | ))
|
197 + | }
|
198 + | };
|
199 + | tmp.meta = generic;
|
200 + | if tmp.message.is_none() {
|
201 + | tmp.message = _error_message;
|
202 + | }
|
203 + | tmp
|
204 + | }),
|
205 + | "ErrorEvent" => crate::operation::output_stream::OutputStreamError::ErrorEvent({
|
206 + | let mut tmp = match protocol
|
207 + | .deserialize_response(response, crate::types::error::ErrorEvent::SCHEMA, _cfg)
|
208 + | .and_then(|mut deser| {
|
209 + | crate::types::error::ErrorEvent::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body)
|
210 + | }) {
|
211 + | ::std::result::Result::Ok(val) => val,
|
212 + | ::std::result::Result::Err(e) => {
|
213 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
214 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
215 + | ))
|
216 + | }
|
217 + | };
|
218 + | tmp.meta = generic;
|
219 + | if tmp.message.is_none() {
|
220 + | tmp.message = _error_message;
|
221 + | }
|
222 + | tmp
|
223 + | }),
|
224 + | _ => crate::operation::output_stream::OutputStreamError::generic(generic),
|
225 + | };
|
226 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
227 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
159 228 | ))
|
160 229 | }
|
161 230 | }
|
162 231 | #[derive(Debug)]
|
163 232 | struct OutputStreamRequestSerializer;
|
164 233 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for OutputStreamRequestSerializer {
|
165 234 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
166 235 | fn serialize_input(
|
167 236 | &self,
|
168 237 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
169 238 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
170 239 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
171 240 | let input = input
|
172 241 | .downcast::<crate::operation::output_stream::OutputStreamInput>()
|
173 242 | .expect("correct type");
|
174 - | let _header_serialization_settings = _cfg
|
175 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
176 - | .cloned()
|
177 - | .unwrap_or_default();
|
178 - | let mut request_builder = {
|
179 - | #[allow(clippy::uninlined_format_args)]
|
180 - | fn uri_base(
|
181 - | _input: &crate::operation::output_stream::OutputStreamInput,
|
182 - | output: &mut ::std::string::String,
|
183 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
184 - | use ::std::fmt::Write as _;
|
185 - | ::std::write!(output, "/OutputStream").expect("formatting should succeed");
|
186 - | ::std::result::Result::Ok(())
|
187 - | }
|
188 - | #[allow(clippy::unnecessary_wraps)]
|
189 - | fn update_http_builder(
|
190 - | input: &crate::operation::output_stream::OutputStreamInput,
|
191 - | builder: ::http_1x::request::Builder,
|
192 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
193 - | let mut uri = ::std::string::String::new();
|
194 - | uri_base(input, &mut uri)?;
|
195 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
196 - | }
|
197 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
198 - | builder
|
199 - | };
|
200 - | let body = ::aws_smithy_types::body::SdkBody::from("");
|
243 + | let protocol = _cfg
|
244 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
245 + | .expect("a SharedClientProtocol is required");
|
246 + | let mut request = protocol
|
247 + | .serialize_request(&input, OutputStream::INPUT_SCHEMA, "", _cfg)
|
248 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
201 249 |
|
202 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
250 + | return ::std::result::Result::Ok(request);
|
203 251 | }
|
204 252 | }
|
205 253 | #[derive(Debug)]
|
206 254 | struct OutputStreamEndpointParamsInterceptor;
|
207 255 |
|
208 256 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for OutputStreamEndpointParamsInterceptor {
|
209 257 | fn name(&self) -> &'static str {
|
210 258 | "OutputStreamEndpointParamsInterceptor"
|
211 259 | }
|
212 260 |
|