aws_sdk_databrew/protocol_serde/
shape_create_schedule.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_schedule_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::create_schedule::CreateScheduleOutput, crate::operation::create_schedule::CreateScheduleError> {
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::create_schedule::CreateScheduleError::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::create_schedule::CreateScheduleError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ConflictException" => crate::operation::create_schedule::CreateScheduleError::ConflictException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
25 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
26 .map_err(crate::operation::create_schedule::CreateScheduleError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "ServiceQuotaExceededException" => crate::operation::create_schedule::CreateScheduleError::ServiceQuotaExceededException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
40 output = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
41 _response_body,
42 output,
43 )
44 .map_err(crate::operation::create_schedule::CreateScheduleError::unhandled)?;
45 let output = output.meta(generic);
46 output.build()
47 };
48 if tmp.message.is_none() {
49 tmp.message = _error_message;
50 }
51 tmp
52 }),
53 "ValidationException" => crate::operation::create_schedule::CreateScheduleError::ValidationException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
58 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
59 .map_err(crate::operation::create_schedule::CreateScheduleError::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::create_schedule::CreateScheduleError::generic(generic),
69 })
70}
71
72#[allow(clippy::unnecessary_wraps)]
73pub fn de_create_schedule_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::create_schedule::CreateScheduleOutput, crate::operation::create_schedule::CreateScheduleError> {
78 Ok({
79 #[allow(unused_mut)]
80 let mut output = crate::operation::create_schedule::builders::CreateScheduleOutputBuilder::default();
81 output = crate::protocol_serde::shape_create_schedule::de_create_schedule(_response_body, output)
82 .map_err(crate::operation::create_schedule::CreateScheduleError::unhandled)?;
83 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
84 crate::serde_util::create_schedule_output_output_correct_errors(output)
85 .build()
86 .map_err(crate::operation::create_schedule::CreateScheduleError::unhandled)?
87 })
88}
89
90pub fn ser_create_schedule_input(
91 input: &crate::operation::create_schedule::CreateScheduleInput,
92) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
93 let mut out = String::new();
94 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
95 crate::protocol_serde::shape_create_schedule_input::ser_create_schedule_input_input(&mut object, input)?;
96 object.finish();
97 Ok(::aws_smithy_types::body::SdkBody::from(out))
98}
99
100pub(crate) fn de_create_schedule(
101 value: &[u8],
102 mut builder: crate::operation::create_schedule::builders::CreateScheduleOutputBuilder,
103) -> ::std::result::Result<
104 crate::operation::create_schedule::builders::CreateScheduleOutputBuilder,
105 ::aws_smithy_json::deserialize::error::DeserializeError,
106> {
107 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
108 let tokens = &mut tokens_owned;
109 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
110 loop {
111 match tokens.next().transpose()? {
112 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
113 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
114 "Name" => {
115 builder = builder.set_name(
116 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
117 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
118 .transpose()?,
119 );
120 }
121 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
122 },
123 other => {
124 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
125 "expected object key or end object, found: {:?}",
126 other
127 )))
128 }
129 }
130 }
131 if tokens.next().is_some() {
132 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
133 "found more JSON tokens after completing parsing",
134 ));
135 }
136 Ok(builder)
137}