aws_sdk_waf/protocol_serde/
shape_get_regex_match_set.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_regex_match_set_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::get_regex_match_set::GetRegexMatchSetOutput, crate::operation::get_regex_match_set::GetRegexMatchSetError>
8{
9 #[allow(unused_mut)]
10 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11 .map_err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled)?;
12 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13 let generic = generic_builder.build();
14 let error_code = match generic.code() {
15 Some(code) => code,
16 None => return Err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "WAFInternalErrorException" => crate::operation::get_regex_match_set::GetRegexMatchSetError::WafInternalErrorException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::WafInternalErrorExceptionBuilder::default();
26 output = crate::protocol_serde::shape_waf_internal_error_exception::de_waf_internal_error_exception_json_err(_response_body, output)
27 .map_err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled)?;
28 let output = output.meta(generic);
29 output.build()
30 };
31 if tmp.message.is_none() {
32 tmp.message = _error_message;
33 }
34 tmp
35 }),
36 "WAFInvalidAccountException" => crate::operation::get_regex_match_set::GetRegexMatchSetError::WafInvalidAccountException({
37 #[allow(unused_mut)]
38 let mut tmp = {
39 #[allow(unused_mut)]
40 let mut output = crate::types::error::builders::WafInvalidAccountExceptionBuilder::default();
41 output =
42 crate::protocol_serde::shape_waf_invalid_account_exception::de_waf_invalid_account_exception_json_err(_response_body, output)
43 .map_err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled)?;
44 let output = output.meta(generic);
45 output.build()
46 };
47 if tmp.message.is_none() {
48 tmp.message = _error_message;
49 }
50 tmp
51 }),
52 "WAFNonexistentItemException" => crate::operation::get_regex_match_set::GetRegexMatchSetError::WafNonexistentItemException({
53 #[allow(unused_mut)]
54 let mut tmp = {
55 #[allow(unused_mut)]
56 let mut output = crate::types::error::builders::WafNonexistentItemExceptionBuilder::default();
57 output =
58 crate::protocol_serde::shape_waf_nonexistent_item_exception::de_waf_nonexistent_item_exception_json_err(_response_body, output)
59 .map_err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled)?;
60 let output = output.meta(generic);
61 output.build()
62 };
63 if tmp.message.is_none() {
64 tmp.message = _error_message;
65 }
66 tmp
67 }),
68 _ => crate::operation::get_regex_match_set::GetRegexMatchSetError::generic(generic),
69 })
70}
71
72#[allow(clippy::unnecessary_wraps)]
73pub fn de_get_regex_match_set_http_response(
74 _response_status: u16,
75 _response_headers: &::aws_smithy_runtime_api::http::Headers,
76 _response_body: &[u8],
77) -> std::result::Result<crate::operation::get_regex_match_set::GetRegexMatchSetOutput, crate::operation::get_regex_match_set::GetRegexMatchSetError>
78{
79 Ok({
80 #[allow(unused_mut)]
81 let mut output = crate::operation::get_regex_match_set::builders::GetRegexMatchSetOutputBuilder::default();
82 output = crate::protocol_serde::shape_get_regex_match_set::de_get_regex_match_set(_response_body, output)
83 .map_err(crate::operation::get_regex_match_set::GetRegexMatchSetError::unhandled)?;
84 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
85 output.build()
86 })
87}
88
89pub fn ser_get_regex_match_set_input(
90 input: &crate::operation::get_regex_match_set::GetRegexMatchSetInput,
91) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
92 let mut out = String::new();
93 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
94 crate::protocol_serde::shape_get_regex_match_set_input::ser_get_regex_match_set_input_input(&mut object, input)?;
95 object.finish();
96 Ok(::aws_smithy_types::body::SdkBody::from(out))
97}
98
99pub(crate) fn de_get_regex_match_set(
100 _value: &[u8],
101 mut builder: crate::operation::get_regex_match_set::builders::GetRegexMatchSetOutputBuilder,
102) -> ::std::result::Result<
103 crate::operation::get_regex_match_set::builders::GetRegexMatchSetOutputBuilder,
104 ::aws_smithy_json::deserialize::error::DeserializeError,
105> {
106 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
107 let tokens = &mut tokens_owned;
108 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
109 loop {
110 match tokens.next().transpose()? {
111 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
112 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
113 "RegexMatchSet" => {
114 builder = builder.set_regex_match_set(crate::protocol_serde::shape_regex_match_set::de_regex_match_set(tokens, _value)?);
115 }
116 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
117 },
118 other => {
119 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
120 "expected object key or end object, found: {other:?}"
121 )))
122 }
123 }
124 }
125 if tokens.next().is_some() {
126 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
127 "found more JSON tokens after completing parsing",
128 ));
129 }
130 Ok(builder)
131}