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_capture_pokemon::de_capture_pokemon_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_capture_pokemon::de_capture_pokemon_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::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,
|
256 + | response.headers(),
|
257 + | response.status().into(),
|
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 - | let input_1 = &_input.region;
|
186 - | let input_1 = input_1
|
187 - | .as_ref()
|
188 - | .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("region", "cannot be empty or unset"))?;
|
189 - | let region = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
|
190 - | if region.is_empty() {
|
191 - | return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
|
192 - | "region",
|
193 - | "cannot be empty or unset",
|
194 - | ));
|
195 - | }
|
196 - | ::std::write!(output, "/capture-pokemon-event/{region}", region = region).expect("formatting should succeed");
|
197 - | ::std::result::Result::Ok(())
|
198 - | }
|
199 - | #[allow(clippy::unnecessary_wraps)]
|
200 - | fn update_http_builder(
|
201 - | input: &crate::operation::capture_pokemon::CapturePokemonInput,
|
202 - | builder: ::http_1x::request::Builder,
|
203 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
204 - | let mut uri = ::std::string::String::new();
|
205 - | uri_base(input, &mut uri)?;
|
206 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
207 - | }
|
208 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
209 - | builder =
|
210 - | _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
|
211 - | builder
|
212 - | };
|
213 - | 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({
|
214 324 | let error_marshaller = crate::event_stream_serde::AttemptCapturingPokemonEventErrorMarshaller::new();
|
215 325 | let marshaller = crate::event_stream_serde::AttemptCapturingPokemonEventMarshaller::new();
|
216 326 | let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
|
217 327 | _cfg.interceptor_state().store_put(signer_sender);
|
218 328 | ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.events.into_body_stream(
|
219 329 | marshaller,
|
220 330 | error_marshaller,
|
221 331 | signer,
|
222 332 | )))
|
223 333 | });
|
224 - | if let Some(content_length) = body.content_length() {
|
225 - | let content_length = content_length.to_string();
|
226 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
227 - | }
|
228 - | ::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/vnd.amazon.eventstream");
|
338 + |
|
339 + | return ::std::result::Result::Ok(request);
|
229 340 | }
|
230 341 | }
|
231 342 | #[derive(Debug)]
|
232 343 | struct CapturePokemonEndpointParamsInterceptor;
|
233 344 |
|
234 345 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CapturePokemonEndpointParamsInterceptor {
|
235 346 | fn name(&self) -> &'static str {
|
236 347 | "CapturePokemonEndpointParamsInterceptor"
|
237 348 | }
|
238 349 |
|