aws_sdk_frauddetector/protocol_serde/
shape_get_variables.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_variables_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_variables::GetVariablesOutput, crate::operation::get_variables::GetVariablesError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::get_variables::GetVariablesError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::get_variables::GetVariablesError::AccessDeniedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
27 let output = output.meta(generic);
28 crate::serde_util::access_denied_exception_correct_errors(output)
29 .build()
30 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?
31 };
32 tmp
33 }),
34 "InternalServerException" => crate::operation::get_variables::GetVariablesError::InternalServerException({
35 #[allow(unused_mut)]
36 let mut tmp = {
37 #[allow(unused_mut)]
38 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
39 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
40 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
41 let output = output.meta(generic);
42 crate::serde_util::internal_server_exception_correct_errors(output)
43 .build()
44 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?
45 };
46 tmp
47 }),
48 "ResourceNotFoundException" => crate::operation::get_variables::GetVariablesError::ResourceNotFoundException({
49 #[allow(unused_mut)]
50 let mut tmp = {
51 #[allow(unused_mut)]
52 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
53 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
54 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
55 let output = output.meta(generic);
56 crate::serde_util::resource_not_found_exception_correct_errors(output)
57 .build()
58 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?
59 };
60 tmp
61 }),
62 "ThrottlingException" => crate::operation::get_variables::GetVariablesError::ThrottlingException({
63 #[allow(unused_mut)]
64 let mut tmp = {
65 #[allow(unused_mut)]
66 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
67 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
68 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
69 let output = output.meta(generic);
70 crate::serde_util::throttling_exception_correct_errors(output)
71 .build()
72 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?
73 };
74 tmp
75 }),
76 "ValidationException" => crate::operation::get_variables::GetVariablesError::ValidationException({
77 #[allow(unused_mut)]
78 let mut tmp = {
79 #[allow(unused_mut)]
80 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
81 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
82 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
83 let output = output.meta(generic);
84 crate::serde_util::validation_exception_correct_errors(output)
85 .build()
86 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?
87 };
88 tmp
89 }),
90 _ => crate::operation::get_variables::GetVariablesError::generic(generic),
91 })
92}
93
94#[allow(clippy::unnecessary_wraps)]
95pub fn de_get_variables_http_response(
96 _response_status: u16,
97 _response_headers: &::aws_smithy_runtime_api::http::Headers,
98 _response_body: &[u8],
99) -> std::result::Result<crate::operation::get_variables::GetVariablesOutput, crate::operation::get_variables::GetVariablesError> {
100 Ok({
101 #[allow(unused_mut)]
102 let mut output = crate::operation::get_variables::builders::GetVariablesOutputBuilder::default();
103 output = crate::protocol_serde::shape_get_variables::de_get_variables(_response_body, output)
104 .map_err(crate::operation::get_variables::GetVariablesError::unhandled)?;
105 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
106 output.build()
107 })
108}
109
110pub fn ser_get_variables_input(
111 input: &crate::operation::get_variables::GetVariablesInput,
112) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
113 let mut out = String::new();
114 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
115 crate::protocol_serde::shape_get_variables_input::ser_get_variables_input_input(&mut object, input)?;
116 object.finish();
117 Ok(::aws_smithy_types::body::SdkBody::from(out))
118}
119
120pub(crate) fn de_get_variables(
121 _value: &[u8],
122 mut builder: crate::operation::get_variables::builders::GetVariablesOutputBuilder,
123) -> ::std::result::Result<
124 crate::operation::get_variables::builders::GetVariablesOutputBuilder,
125 ::aws_smithy_json::deserialize::error::DeserializeError,
126> {
127 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
128 let tokens = &mut tokens_owned;
129 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
130 loop {
131 match tokens.next().transpose()? {
132 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
133 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
134 "variables" => {
135 builder = builder.set_variables(crate::protocol_serde::shape_variable_list::de_variable_list(tokens, _value)?);
136 }
137 "nextToken" => {
138 builder = builder.set_next_token(
139 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
140 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
141 .transpose()?,
142 );
143 }
144 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
145 },
146 other => {
147 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
148 "expected object key or end object, found: {other:?}"
149 )))
150 }
151 }
152 }
153 if tokens.next().is_some() {
154 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
155 "found more JSON tokens after completing parsing",
156 ));
157 }
158 Ok(builder)
159}