aws_sdk_backup/protocol_serde/
shape_get_backup_vault_notifications.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_backup_vault_notifications_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::get_backup_vault_notifications::GetBackupVaultNotificationsOutput,
9 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError,
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::get_backup_vault_notifications::GetBackupVaultNotificationsError::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::get_backup_vault_notifications::GetBackupVaultNotificationsError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "InvalidParameterValueException" => {
24 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::InvalidParameterValueException({
25 #[allow(unused_mut)]
26 let mut tmp = {
27 #[allow(unused_mut)]
28 let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
29 output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
30 _response_body,
31 output,
32 )
33 .map_err(crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::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 "MissingParameterValueException" => {
44 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::MissingParameterValueException({
45 #[allow(unused_mut)]
46 let mut tmp = {
47 #[allow(unused_mut)]
48 let mut output = crate::types::error::builders::MissingParameterValueExceptionBuilder::default();
49 output = crate::protocol_serde::shape_missing_parameter_value_exception::de_missing_parameter_value_exception_json_err(
50 _response_body,
51 output,
52 )
53 .map_err(crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::unhandled)?;
54 let output = output.meta(generic);
55 output.build()
56 };
57 if tmp.message.is_none() {
58 tmp.message = _error_message;
59 }
60 tmp
61 })
62 }
63 "ResourceNotFoundException" => {
64 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::ResourceNotFoundException({
65 #[allow(unused_mut)]
66 let mut tmp = {
67 #[allow(unused_mut)]
68 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
69 output =
70 crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
71 .map_err(crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::unhandled)?;
72 let output = output.meta(generic);
73 output.build()
74 };
75 if tmp.message.is_none() {
76 tmp.message = _error_message;
77 }
78 tmp
79 })
80 }
81 "ServiceUnavailableException" => {
82 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::ServiceUnavailableException({
83 #[allow(unused_mut)]
84 let mut tmp = {
85 #[allow(unused_mut)]
86 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
87 output =
88 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
89 .map_err(crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::unhandled)?;
90 let output = output.meta(generic);
91 output.build()
92 };
93 if tmp.message.is_none() {
94 tmp.message = _error_message;
95 }
96 tmp
97 })
98 }
99 _ => crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::generic(generic),
100 })
101}
102
103#[allow(clippy::unnecessary_wraps)]
104pub fn de_get_backup_vault_notifications_http_response(
105 _response_status: u16,
106 _response_headers: &::aws_smithy_runtime_api::http::Headers,
107 _response_body: &[u8],
108) -> std::result::Result<
109 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsOutput,
110 crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError,
111> {
112 Ok({
113 #[allow(unused_mut)]
114 let mut output = crate::operation::get_backup_vault_notifications::builders::GetBackupVaultNotificationsOutputBuilder::default();
115 output = crate::protocol_serde::shape_get_backup_vault_notifications::de_get_backup_vault_notifications(_response_body, output)
116 .map_err(crate::operation::get_backup_vault_notifications::GetBackupVaultNotificationsError::unhandled)?;
117 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
118 output.build()
119 })
120}
121
122pub(crate) fn de_get_backup_vault_notifications(
123 value: &[u8],
124 mut builder: crate::operation::get_backup_vault_notifications::builders::GetBackupVaultNotificationsOutputBuilder,
125) -> ::std::result::Result<
126 crate::operation::get_backup_vault_notifications::builders::GetBackupVaultNotificationsOutputBuilder,
127 ::aws_smithy_json::deserialize::error::DeserializeError,
128> {
129 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
130 let tokens = &mut tokens_owned;
131 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
132 loop {
133 match tokens.next().transpose()? {
134 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
135 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
136 "BackupVaultArn" => {
137 builder = builder.set_backup_vault_arn(
138 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
139 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
140 .transpose()?,
141 );
142 }
143 "BackupVaultEvents" => {
144 builder = builder.set_backup_vault_events(crate::protocol_serde::shape_backup_vault_events::de_backup_vault_events(tokens)?);
145 }
146 "BackupVaultName" => {
147 builder = builder.set_backup_vault_name(
148 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
149 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
150 .transpose()?,
151 );
152 }
153 "SNSTopicArn" => {
154 builder = builder.set_sns_topic_arn(
155 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
156 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
157 .transpose()?,
158 );
159 }
160 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
161 },
162 other => {
163 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
164 "expected object key or end object, found: {:?}",
165 other
166 )))
167 }
168 }
169 }
170 if tokens.next().is_some() {
171 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
172 "found more JSON tokens after completing parsing",
173 ));
174 }
175 Ok(builder)
176}