aws_sdk_sagemaker/protocol_serde/
shape_human_loop_config.rs1pub fn ser_human_loop_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::HumanLoopConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.workteam_arn {
7 object.key("WorkteamArn").string(var_1.as_str());
8 }
9 if let Some(var_2) = &input.human_task_ui_arn {
10 object.key("HumanTaskUiArn").string(var_2.as_str());
11 }
12 if let Some(var_3) = &input.task_title {
13 object.key("TaskTitle").string(var_3.as_str());
14 }
15 if let Some(var_4) = &input.task_description {
16 object.key("TaskDescription").string(var_4.as_str());
17 }
18 if let Some(var_5) = &input.task_count {
19 object.key("TaskCount").number(
20 #[allow(clippy::useless_conversion)]
21 ::aws_smithy_types::Number::NegInt((*var_5).into()),
22 );
23 }
24 if let Some(var_6) = &input.task_availability_lifetime_in_seconds {
25 object.key("TaskAvailabilityLifetimeInSeconds").number(
26 #[allow(clippy::useless_conversion)]
27 ::aws_smithy_types::Number::NegInt((*var_6).into()),
28 );
29 }
30 if let Some(var_7) = &input.task_time_limit_in_seconds {
31 object.key("TaskTimeLimitInSeconds").number(
32 #[allow(clippy::useless_conversion)]
33 ::aws_smithy_types::Number::NegInt((*var_7).into()),
34 );
35 }
36 if let Some(var_8) = &input.task_keywords {
37 let mut array_9 = object.key("TaskKeywords").start_array();
38 for item_10 in var_8 {
39 {
40 array_9.value().string(item_10.as_str());
41 }
42 }
43 array_9.finish();
44 }
45 if let Some(var_11) = &input.public_workforce_task_price {
46 #[allow(unused_mut)]
47 let mut object_12 = object.key("PublicWorkforceTaskPrice").start_object();
48 crate::protocol_serde::shape_public_workforce_task_price::ser_public_workforce_task_price(&mut object_12, var_11)?;
49 object_12.finish();
50 }
51 Ok(())
52}
53
54pub(crate) fn de_human_loop_config<'a, I>(
55 tokens: &mut ::std::iter::Peekable<I>,
56) -> ::std::result::Result<Option<crate::types::HumanLoopConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
57where
58 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
59{
60 match tokens.next().transpose()? {
61 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
62 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
63 #[allow(unused_mut)]
64 let mut builder = crate::types::builders::HumanLoopConfigBuilder::default();
65 loop {
66 match tokens.next().transpose()? {
67 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
68 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
69 "WorkteamArn" => {
70 builder = builder.set_workteam_arn(
71 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
72 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
73 .transpose()?,
74 );
75 }
76 "HumanTaskUiArn" => {
77 builder = builder.set_human_task_ui_arn(
78 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
79 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
80 .transpose()?,
81 );
82 }
83 "TaskTitle" => {
84 builder = builder.set_task_title(
85 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
86 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
87 .transpose()?,
88 );
89 }
90 "TaskDescription" => {
91 builder = builder.set_task_description(
92 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
93 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
94 .transpose()?,
95 );
96 }
97 "TaskCount" => {
98 builder = builder.set_task_count(
99 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
100 .map(i32::try_from)
101 .transpose()?,
102 );
103 }
104 "TaskAvailabilityLifetimeInSeconds" => {
105 builder = builder.set_task_availability_lifetime_in_seconds(
106 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
107 .map(i32::try_from)
108 .transpose()?,
109 );
110 }
111 "TaskTimeLimitInSeconds" => {
112 builder = builder.set_task_time_limit_in_seconds(
113 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
114 .map(i32::try_from)
115 .transpose()?,
116 );
117 }
118 "TaskKeywords" => {
119 builder = builder.set_task_keywords(
120 crate::protocol_serde::shape_flow_definition_task_keywords::de_flow_definition_task_keywords(tokens)?,
121 );
122 }
123 "PublicWorkforceTaskPrice" => {
124 builder = builder.set_public_workforce_task_price(
125 crate::protocol_serde::shape_public_workforce_task_price::de_public_workforce_task_price(tokens)?,
126 );
127 }
128 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
129 },
130 other => {
131 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
132 "expected object key or end object, found: {:?}",
133 other
134 )))
135 }
136 }
137 }
138 Ok(Some(crate::serde_util::human_loop_config_correct_errors(builder).build()))
139 }
140 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
141 "expected start object or null",
142 )),
143 }
144}