aws_sdk_codepipeline/protocol_serde/
shape_stop_pipeline_execution.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_stop_pipeline_execution_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<
8 crate::operation::stop_pipeline_execution::StopPipelineExecutionOutput,
9 crate::operation::stop_pipeline_execution::StopPipelineExecutionError,
10> {
11 #[allow(unused_mut)]
12 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
14 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15 let generic = generic_builder.build();
16 let error_code = match generic.code() {
17 Some(code) => code,
18 None => return Err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ConflictException" => crate::operation::stop_pipeline_execution::StopPipelineExecutionError::ConflictException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
28 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
29 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
30 let output = output.meta(generic);
31 output.build()
32 };
33 if tmp.message.is_none() {
34 tmp.message = _error_message;
35 }
36 tmp
37 }),
38 "DuplicatedStopRequestException" => crate::operation::stop_pipeline_execution::StopPipelineExecutionError::DuplicatedStopRequestException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::DuplicatedStopRequestExceptionBuilder::default();
43 output = crate::protocol_serde::shape_duplicated_stop_request_exception::de_duplicated_stop_request_exception_json_err(
44 _response_body,
45 output,
46 )
47 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
48 let output = output.meta(generic);
49 output.build()
50 };
51 if tmp.message.is_none() {
52 tmp.message = _error_message;
53 }
54 tmp
55 }),
56 "PipelineExecutionNotStoppableException" => {
57 crate::operation::stop_pipeline_execution::StopPipelineExecutionError::PipelineExecutionNotStoppableException({
58 #[allow(unused_mut)]
59 let mut tmp = {
60 #[allow(unused_mut)]
61 let mut output = crate::types::error::builders::PipelineExecutionNotStoppableExceptionBuilder::default();
62 output = crate::protocol_serde::shape_pipeline_execution_not_stoppable_exception::de_pipeline_execution_not_stoppable_exception_json_err(_response_body, output).map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
63 let output = output.meta(generic);
64 output.build()
65 };
66 if tmp.message.is_none() {
67 tmp.message = _error_message;
68 }
69 tmp
70 })
71 }
72 "PipelineNotFoundException" => crate::operation::stop_pipeline_execution::StopPipelineExecutionError::PipelineNotFoundException({
73 #[allow(unused_mut)]
74 let mut tmp = {
75 #[allow(unused_mut)]
76 let mut output = crate::types::error::builders::PipelineNotFoundExceptionBuilder::default();
77 output = crate::protocol_serde::shape_pipeline_not_found_exception::de_pipeline_not_found_exception_json_err(_response_body, output)
78 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
79 let output = output.meta(generic);
80 output.build()
81 };
82 if tmp.message.is_none() {
83 tmp.message = _error_message;
84 }
85 tmp
86 }),
87 "ValidationException" => crate::operation::stop_pipeline_execution::StopPipelineExecutionError::ValidationException({
88 #[allow(unused_mut)]
89 let mut tmp = {
90 #[allow(unused_mut)]
91 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
92 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
93 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
94 let output = output.meta(generic);
95 output.build()
96 };
97 if tmp.message.is_none() {
98 tmp.message = _error_message;
99 }
100 tmp
101 }),
102 _ => crate::operation::stop_pipeline_execution::StopPipelineExecutionError::generic(generic),
103 })
104}
105
106#[allow(clippy::unnecessary_wraps)]
107pub fn de_stop_pipeline_execution_http_response(
108 _response_status: u16,
109 _response_headers: &::aws_smithy_runtime_api::http::Headers,
110 _response_body: &[u8],
111) -> std::result::Result<
112 crate::operation::stop_pipeline_execution::StopPipelineExecutionOutput,
113 crate::operation::stop_pipeline_execution::StopPipelineExecutionError,
114> {
115 Ok({
116 #[allow(unused_mut)]
117 let mut output = crate::operation::stop_pipeline_execution::builders::StopPipelineExecutionOutputBuilder::default();
118 output = crate::protocol_serde::shape_stop_pipeline_execution::de_stop_pipeline_execution(_response_body, output)
119 .map_err(crate::operation::stop_pipeline_execution::StopPipelineExecutionError::unhandled)?;
120 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
121 output.build()
122 })
123}
124
125pub fn ser_stop_pipeline_execution_input(
126 input: &crate::operation::stop_pipeline_execution::StopPipelineExecutionInput,
127) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
128 let mut out = String::new();
129 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
130 crate::protocol_serde::shape_stop_pipeline_execution_input::ser_stop_pipeline_execution_input_input(&mut object, input)?;
131 object.finish();
132 Ok(::aws_smithy_types::body::SdkBody::from(out))
133}
134
135pub(crate) fn de_stop_pipeline_execution(
136 value: &[u8],
137 mut builder: crate::operation::stop_pipeline_execution::builders::StopPipelineExecutionOutputBuilder,
138) -> ::std::result::Result<
139 crate::operation::stop_pipeline_execution::builders::StopPipelineExecutionOutputBuilder,
140 ::aws_smithy_json::deserialize::error::DeserializeError,
141> {
142 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
143 let tokens = &mut tokens_owned;
144 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
145 loop {
146 match tokens.next().transpose()? {
147 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
148 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
149 "pipelineExecutionId" => {
150 builder = builder.set_pipeline_execution_id(
151 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
152 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
153 .transpose()?,
154 );
155 }
156 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
157 },
158 other => {
159 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
160 "expected object key or end object, found: {:?}",
161 other
162 )))
163 }
164 }
165 }
166 if tokens.next().is_some() {
167 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
168 "found more JSON tokens after completing parsing",
169 ));
170 }
171 Ok(builder)
172}