aws_sdk_lexmodelsv2/protocol_serde/
shape_describe_intent.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_intent_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::describe_intent::DescribeIntentOutput, crate::operation::describe_intent::DescribeIntentError> {
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::describe_intent::DescribeIntentError::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::describe_intent::DescribeIntentError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "InternalServerException" => crate::operation::describe_intent::DescribeIntentError::InternalServerException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
25 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
26 .map_err(crate::operation::describe_intent::DescribeIntentError::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 "ResourceNotFoundException" => crate::operation::describe_intent::DescribeIntentError::ResourceNotFoundException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
40 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
41 .map_err(crate::operation::describe_intent::DescribeIntentError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "ServiceQuotaExceededException" => crate::operation::describe_intent::DescribeIntentError::ServiceQuotaExceededException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
55 output = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
56 _response_body,
57 output,
58 )
59 .map_err(crate::operation::describe_intent::DescribeIntentError::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 "ThrottlingException" => crate::operation::describe_intent::DescribeIntentError::ThrottlingException({
69 #[allow(unused_mut)]
70 let mut tmp = {
71 #[allow(unused_mut)]
72 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
73 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
74 .map_err(crate::operation::describe_intent::DescribeIntentError::unhandled)?;
75 output = output.set_retry_after_seconds(
76 crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
77 crate::operation::describe_intent::DescribeIntentError::unhandled(
78 "Failed to parse retryAfterSeconds from header `Retry-After",
79 )
80 })?,
81 );
82 let output = output.meta(generic);
83 output.build()
84 };
85 if tmp.message.is_none() {
86 tmp.message = _error_message;
87 }
88 tmp
89 }),
90 "ValidationException" => crate::operation::describe_intent::DescribeIntentError::ValidationException({
91 #[allow(unused_mut)]
92 let mut tmp = {
93 #[allow(unused_mut)]
94 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
95 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
96 .map_err(crate::operation::describe_intent::DescribeIntentError::unhandled)?;
97 let output = output.meta(generic);
98 output.build()
99 };
100 if tmp.message.is_none() {
101 tmp.message = _error_message;
102 }
103 tmp
104 }),
105 _ => crate::operation::describe_intent::DescribeIntentError::generic(generic),
106 })
107}
108
109#[allow(clippy::unnecessary_wraps)]
110pub fn de_describe_intent_http_response(
111 _response_status: u16,
112 _response_headers: &::aws_smithy_runtime_api::http::Headers,
113 _response_body: &[u8],
114) -> std::result::Result<crate::operation::describe_intent::DescribeIntentOutput, crate::operation::describe_intent::DescribeIntentError> {
115 Ok({
116 #[allow(unused_mut)]
117 let mut output = crate::operation::describe_intent::builders::DescribeIntentOutputBuilder::default();
118 output = crate::protocol_serde::shape_describe_intent::de_describe_intent(_response_body, output)
119 .map_err(crate::operation::describe_intent::DescribeIntentError::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(crate) fn de_describe_intent(
126 value: &[u8],
127 mut builder: crate::operation::describe_intent::builders::DescribeIntentOutputBuilder,
128) -> ::std::result::Result<
129 crate::operation::describe_intent::builders::DescribeIntentOutputBuilder,
130 ::aws_smithy_json::deserialize::error::DeserializeError,
131> {
132 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
133 let tokens = &mut tokens_owned;
134 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
135 loop {
136 match tokens.next().transpose()? {
137 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
138 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
139 "botId" => {
140 builder = builder.set_bot_id(
141 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
142 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
143 .transpose()?,
144 );
145 }
146 "botVersion" => {
147 builder = builder.set_bot_version(
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 "creationDateTime" => {
154 builder = builder.set_creation_date_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
155 tokens.next(),
156 ::aws_smithy_types::date_time::Format::EpochSeconds,
157 )?);
158 }
159 "description" => {
160 builder = builder.set_description(
161 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
162 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
163 .transpose()?,
164 );
165 }
166 "dialogCodeHook" => {
167 builder = builder.set_dialog_code_hook(crate::protocol_serde::shape_dialog_code_hook_settings::de_dialog_code_hook_settings(
168 tokens,
169 )?);
170 }
171 "fulfillmentCodeHook" => {
172 builder = builder.set_fulfillment_code_hook(
173 crate::protocol_serde::shape_fulfillment_code_hook_settings::de_fulfillment_code_hook_settings(tokens)?,
174 );
175 }
176 "initialResponseSetting" => {
177 builder = builder.set_initial_response_setting(
178 crate::protocol_serde::shape_initial_response_setting::de_initial_response_setting(tokens)?,
179 );
180 }
181 "inputContexts" => {
182 builder = builder.set_input_contexts(crate::protocol_serde::shape_input_contexts_list::de_input_contexts_list(tokens)?);
183 }
184 "intentClosingSetting" => {
185 builder =
186 builder.set_intent_closing_setting(crate::protocol_serde::shape_intent_closing_setting::de_intent_closing_setting(tokens)?);
187 }
188 "intentConfirmationSetting" => {
189 builder = builder.set_intent_confirmation_setting(
190 crate::protocol_serde::shape_intent_confirmation_setting::de_intent_confirmation_setting(tokens)?,
191 );
192 }
193 "intentId" => {
194 builder = builder.set_intent_id(
195 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
196 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
197 .transpose()?,
198 );
199 }
200 "intentName" => {
201 builder = builder.set_intent_name(
202 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
203 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
204 .transpose()?,
205 );
206 }
207 "kendraConfiguration" => {
208 builder = builder.set_kendra_configuration(crate::protocol_serde::shape_kendra_configuration::de_kendra_configuration(tokens)?);
209 }
210 "lastUpdatedDateTime" => {
211 builder = builder.set_last_updated_date_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
212 tokens.next(),
213 ::aws_smithy_types::date_time::Format::EpochSeconds,
214 )?);
215 }
216 "localeId" => {
217 builder = builder.set_locale_id(
218 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
219 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
220 .transpose()?,
221 );
222 }
223 "outputContexts" => {
224 builder = builder.set_output_contexts(crate::protocol_serde::shape_output_contexts_list::de_output_contexts_list(tokens)?);
225 }
226 "parentIntentSignature" => {
227 builder = builder.set_parent_intent_signature(
228 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
229 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
230 .transpose()?,
231 );
232 }
233 "qInConnectIntentConfiguration" => {
234 builder = builder.set_q_in_connect_intent_configuration(
235 crate::protocol_serde::shape_q_in_connect_intent_configuration::de_q_in_connect_intent_configuration(tokens)?,
236 );
237 }
238 "qnAIntentConfiguration" => {
239 builder = builder.set_qn_a_intent_configuration(
240 crate::protocol_serde::shape_qn_a_intent_configuration::de_qn_a_intent_configuration(tokens)?,
241 );
242 }
243 "sampleUtterances" => {
244 builder = builder.set_sample_utterances(crate::protocol_serde::shape_sample_utterances_list::de_sample_utterances_list(tokens)?);
245 }
246 "slotPriorities" => {
247 builder = builder.set_slot_priorities(crate::protocol_serde::shape_slot_priorities_list::de_slot_priorities_list(tokens)?);
248 }
249 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
250 },
251 other => {
252 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
253 "expected object key or end object, found: {:?}",
254 other
255 )))
256 }
257 }
258 }
259 if tokens.next().is_some() {
260 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
261 "found more JSON tokens after completing parsing",
262 ));
263 }
264 Ok(builder)
265}