aws_sdk_codedeploy/protocol_serde/
shape_delete_git_hub_account_token.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_git_hub_account_token_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::delete_git_hub_account_token::DeleteGitHubAccountTokenOutput,
9 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError,
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::delete_git_hub_account_token::DeleteGitHubAccountTokenError::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 => {
19 return Err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "GitHubAccountTokenDoesNotExistException" => {
28 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::GitHubAccountTokenDoesNotExistException({
29 #[allow(unused_mut)]
30 let mut tmp = {
31 #[allow(unused_mut)]
32 let mut output = crate::types::error::builders::GitHubAccountTokenDoesNotExistExceptionBuilder::default();
33 output = crate::protocol_serde::shape_git_hub_account_token_does_not_exist_exception::de_git_hub_account_token_does_not_exist_exception_json_err(_response_body, output).map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
34 let output = output.meta(generic);
35 output.build()
36 };
37 if tmp.message.is_none() {
38 tmp.message = _error_message;
39 }
40 tmp
41 })
42 }
43 "GitHubAccountTokenNameRequiredException" => {
44 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::GitHubAccountTokenNameRequiredException({
45 #[allow(unused_mut)]
46 let mut tmp = {
47 #[allow(unused_mut)]
48 let mut output = crate::types::error::builders::GitHubAccountTokenNameRequiredExceptionBuilder::default();
49 output = crate::protocol_serde::shape_git_hub_account_token_name_required_exception::de_git_hub_account_token_name_required_exception_json_err(_response_body, output).map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
50 let output = output.meta(generic);
51 output.build()
52 };
53 if tmp.message.is_none() {
54 tmp.message = _error_message;
55 }
56 tmp
57 })
58 }
59 "InvalidGitHubAccountTokenNameException" => {
60 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::InvalidGitHubAccountTokenNameException({
61 #[allow(unused_mut)]
62 let mut tmp = {
63 #[allow(unused_mut)]
64 let mut output = crate::types::error::builders::InvalidGitHubAccountTokenNameExceptionBuilder::default();
65 output = crate::protocol_serde::shape_invalid_git_hub_account_token_name_exception::de_invalid_git_hub_account_token_name_exception_json_err(_response_body, output).map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
66 let output = output.meta(generic);
67 output.build()
68 };
69 if tmp.message.is_none() {
70 tmp.message = _error_message;
71 }
72 tmp
73 })
74 }
75 "OperationNotSupportedException" => {
76 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::OperationNotSupportedException({
77 #[allow(unused_mut)]
78 let mut tmp = {
79 #[allow(unused_mut)]
80 let mut output = crate::types::error::builders::OperationNotSupportedExceptionBuilder::default();
81 output = crate::protocol_serde::shape_operation_not_supported_exception::de_operation_not_supported_exception_json_err(
82 _response_body,
83 output,
84 )
85 .map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
86 let output = output.meta(generic);
87 output.build()
88 };
89 if tmp.message.is_none() {
90 tmp.message = _error_message;
91 }
92 tmp
93 })
94 }
95 "ResourceValidationException" => {
96 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::ResourceValidationException({
97 #[allow(unused_mut)]
98 let mut tmp = {
99 #[allow(unused_mut)]
100 let mut output = crate::types::error::builders::ResourceValidationExceptionBuilder::default();
101 output =
102 crate::protocol_serde::shape_resource_validation_exception::de_resource_validation_exception_json_err(_response_body, output)
103 .map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
104 let output = output.meta(generic);
105 output.build()
106 };
107 if tmp.message.is_none() {
108 tmp.message = _error_message;
109 }
110 tmp
111 })
112 }
113 _ => crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::generic(generic),
114 })
115}
116
117#[allow(clippy::unnecessary_wraps)]
118pub fn de_delete_git_hub_account_token_http_response(
119 _response_status: u16,
120 _response_headers: &::aws_smithy_runtime_api::http::Headers,
121 _response_body: &[u8],
122) -> std::result::Result<
123 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenOutput,
124 crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError,
125> {
126 Ok({
127 #[allow(unused_mut)]
128 let mut output = crate::operation::delete_git_hub_account_token::builders::DeleteGitHubAccountTokenOutputBuilder::default();
129 output = crate::protocol_serde::shape_delete_git_hub_account_token::de_delete_git_hub_account_token(_response_body, output)
130 .map_err(crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenError::unhandled)?;
131 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
132 output.build()
133 })
134}
135
136pub fn ser_delete_git_hub_account_token_input(
137 input: &crate::operation::delete_git_hub_account_token::DeleteGitHubAccountTokenInput,
138) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
139 let mut out = String::new();
140 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
141 crate::protocol_serde::shape_delete_git_hub_account_token_input::ser_delete_git_hub_account_token_input_input(&mut object, input)?;
142 object.finish();
143 Ok(::aws_smithy_types::body::SdkBody::from(out))
144}
145
146pub(crate) fn de_delete_git_hub_account_token(
147 value: &[u8],
148 mut builder: crate::operation::delete_git_hub_account_token::builders::DeleteGitHubAccountTokenOutputBuilder,
149) -> ::std::result::Result<
150 crate::operation::delete_git_hub_account_token::builders::DeleteGitHubAccountTokenOutputBuilder,
151 ::aws_smithy_json::deserialize::error::DeserializeError,
152> {
153 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
154 let tokens = &mut tokens_owned;
155 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
156 loop {
157 match tokens.next().transpose()? {
158 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
159 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
160 "tokenName" => {
161 builder = builder.set_token_name(
162 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
163 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
164 .transpose()?,
165 );
166 }
167 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
168 },
169 other => {
170 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
171 "expected object key or end object, found: {:?}",
172 other
173 )))
174 }
175 }
176 }
177 if tokens.next().is_some() {
178 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
179 "found more JSON tokens after completing parsing",
180 ));
181 }
182 Ok(builder)
183}