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_capture_pokemon::de_capture_pokemon_http_response(response),
|
146 150 | ))
|
147 151 | }
|
148 152 |
|
149 153 | fn deserialize_nonstreaming(
|
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_capture_pokemon::de_capture_pokemon_http_error(
|
156 - | response.status().as_u16(),
|
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::capture_pokemon::CapturePokemonError::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 + | "UnsupportedRegionError" => crate::operation::capture_pokemon::CapturePokemonError::UnsupportedRegionError({
|
182 + | let mut tmp = match protocol
|
183 + | .deserialize_response(response, crate::types::error::UnsupportedRegionError::SCHEMA, _cfg)
|
184 + | .and_then(|mut deser| {
|
185 + | crate::types::error::UnsupportedRegionError::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 + | "ThrottlingError" => crate::operation::capture_pokemon::CapturePokemonError::ThrottlingError({
|
206 + | let mut tmp = match protocol
|
207 + | .deserialize_response(response, crate::types::error::ThrottlingError::SCHEMA, _cfg)
|
208 + | .and_then(|mut deser| {
|
209 + | crate::types::error::ThrottlingError::deserialize_with_response(
|
210 + | &mut *deser,
|
211 + | response.headers(),
|
212 + | response.status().into(),
|
213 + | body,
|
214 + | )
|
215 + | }) {
|
216 + | ::std::result::Result::Ok(val) => val,
|
217 + | ::std::result::Result::Err(e) => {
|
218 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
219 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
220 + | ))
|
221 + | }
|
222 + | };
|
223 + | tmp.meta = generic;
|
224 + | if tmp.message.is_none() {
|
225 + | tmp.message = _error_message;
|
226 + | }
|
227 + | tmp
|
228 + | }),
|
229 + | "ValidationException" => crate::operation::capture_pokemon::CapturePokemonError::ValidationError({
|
230 + | let mut tmp = match protocol
|
231 + | .deserialize_response(response, crate::types::error::ValidationError::SCHEMA, _cfg)
|
232 + | .and_then(|mut deser| {
|
233 + | crate::types::error::ValidationError::deserialize_with_response(
|
234 + | &mut *deser,
|
235 + | response.headers(),
|
236 + | response.status().into(),
|
237 + | body,
|
238 + | )
|
239 + | }) {
|
240 + | ::std::result::Result::Ok(val) => val,
|
241 + | ::std::result::Result::Err(e) => {
|
242 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
243 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
244 + | ))
|
245 + | }
|
246 + | };
|
247 + | tmp.meta = generic;
|
248 + | tmp
|
249 + | }),
|
250 + | "MasterBallUnsuccessful" => crate::operation::capture_pokemon::CapturePokemonError::MasterBallUnsuccessful({
|
251 + | let mut tmp = match protocol
|
252 + | .deserialize_response(response, crate::types::error::MasterBallUnsuccessful::SCHEMA, _cfg)
|
253 + | .and_then(|mut deser| {
|
254 + | crate::types::error::MasterBallUnsuccessful::deserialize_with_response(
|
255 + | &mut *deser,
|
157 256 | response.headers(),
|
257 + | response.status().into(),
|
158 258 | body,
|
259 + | )
|
260 + | }) {
|
261 + | ::std::result::Result::Ok(val) => val,
|
262 + | ::std::result::Result::Err(e) => {
|
263 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
264 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
265 + | ))
|
266 + | }
|
267 + | };
|
268 + | tmp.meta = generic;
|
269 + | if tmp.message.is_none() {
|
270 + | tmp.message = _error_message;
|
271 + | }
|
272 + | tmp
|
273 + | }),
|
274 + | "InvalidPokeballError" => crate::operation::capture_pokemon::CapturePokemonError::InvalidPokeballError({
|
275 + | let mut tmp = match protocol
|
276 + | .deserialize_response(response, crate::types::error::InvalidPokeballError::SCHEMA, _cfg)
|
277 + | .and_then(|mut deser| {
|
278 + | crate::types::error::InvalidPokeballError::deserialize_with_response(
|
279 + | &mut *deser,
|
280 + | response.headers(),
|
281 + | response.status().into(),
|
282 + | body,
|
283 + | )
|
284 + | }) {
|
285 + | ::std::result::Result::Ok(val) => val,
|
286 + | ::std::result::Result::Err(e) => {
|
287 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
288 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
289 + | ))
|
290 + | }
|
291 + | };
|
292 + | tmp.meta = generic;
|
293 + | if tmp.message.is_none() {
|
294 + | tmp.message = _error_message;
|
295 + | }
|
296 + | tmp
|
297 + | }),
|
298 + | _ => crate::operation::capture_pokemon::CapturePokemonError::generic(generic),
|
299 + | };
|
300 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
301 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
159 302 | ))
|
160 303 | }
|
161 304 | }
|
162 305 | #[derive(Debug)]
|
163 306 | struct CapturePokemonRequestSerializer;
|
164 307 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CapturePokemonRequestSerializer {
|
165 308 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
166 309 | fn serialize_input(
|
167 310 | &self,
|
168 311 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
169 312 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
170 313 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
171 314 | let input = input
|
172 315 | .downcast::<crate::operation::capture_pokemon::CapturePokemonInput>()
|
173 316 | .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::capture_pokemon::CapturePokemonInput,
|
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, "/").expect("formatting should succeed");
|
186 - | ::std::result::Result::Ok(())
|
187 - | }
|
188 - | #[allow(clippy::unnecessary_wraps)]
|
189 - | fn update_http_builder(
|
190 - | input: &crate::operation::capture_pokemon::CapturePokemonInput,
|
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 = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.0");
|
199 - | builder = _header_serialization_settings.set_default_header(
|
200 - | builder,
|
201 - | ::http_1x::header::HeaderName::from_static("x-amz-target"),
|
202 - | "PokemonService.CapturePokemon",
|
203 - | );
|
204 - | builder
|
205 - | };
|
206 - | let body = ::aws_smithy_types::body::SdkBody::from({
|
317 + | let protocol = _cfg
|
318 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
319 + | .expect("a SharedClientProtocol is required");
|
320 + | let mut request = protocol
|
321 + | .serialize_request(&input, CapturePokemon::INPUT_SCHEMA, "", _cfg)
|
322 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
323 + | *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
|
207 324 | let error_marshaller = crate::event_stream_serde::AttemptCapturingPokemonEventErrorMarshaller::new();
|
208 325 | let marshaller = crate::event_stream_serde::AttemptCapturingPokemonEventMarshaller::new();
|
209 326 | let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
|
210 327 | _cfg.interceptor_state().store_put(signer_sender);
|
211 328 | ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.events.into_body_stream(
|
212 329 | marshaller,
|
213 330 | error_marshaller,
|
214 331 | signer,
|
215 332 | )))
|
216 333 | });
|
217 - | if let Some(content_length) = body.content_length() {
|
218 - | let content_length = content_length.to_string();
|
219 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
220 - | }
|
221 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
334 + | // The protocol may have set Content-Length based on the initial empty body.
|
335 + | // Remove it since the event stream body has unknown length.
|
336 + | request.headers_mut().remove("Content-Length");
|
337 + | request.headers_mut().insert("Content-Type", "application/x-amz-json-1.0");
|
338 + |
|
339 + | return ::std::result::Result::Ok(request);
|
222 340 | }
|
223 341 | }
|
224 342 | #[derive(Debug)]
|
225 343 | struct CapturePokemonEndpointParamsInterceptor;
|
226 344 |
|
227 345 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CapturePokemonEndpointParamsInterceptor {
|
228 346 | fn name(&self) -> &'static str {
|
229 347 | "CapturePokemonEndpointParamsInterceptor"
|
230 348 | }
|
231 349 |
|