aws_sdk_sagemaker/protocol_serde/
shape_human_task_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_human_task_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::HumanTaskConfig,
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.ui_config {
10        #[allow(unused_mut)]
11        let mut object_3 = object.key("UiConfig").start_object();
12        crate::protocol_serde::shape_ui_config::ser_ui_config(&mut object_3, var_2)?;
13        object_3.finish();
14    }
15    if let Some(var_4) = &input.pre_human_task_lambda_arn {
16        object.key("PreHumanTaskLambdaArn").string(var_4.as_str());
17    }
18    if let Some(var_5) = &input.task_keywords {
19        let mut array_6 = object.key("TaskKeywords").start_array();
20        for item_7 in var_5 {
21            {
22                array_6.value().string(item_7.as_str());
23            }
24        }
25        array_6.finish();
26    }
27    if let Some(var_8) = &input.task_title {
28        object.key("TaskTitle").string(var_8.as_str());
29    }
30    if let Some(var_9) = &input.task_description {
31        object.key("TaskDescription").string(var_9.as_str());
32    }
33    if let Some(var_10) = &input.number_of_human_workers_per_data_object {
34        object.key("NumberOfHumanWorkersPerDataObject").number(
35            #[allow(clippy::useless_conversion)]
36            ::aws_smithy_types::Number::NegInt((*var_10).into()),
37        );
38    }
39    if let Some(var_11) = &input.task_time_limit_in_seconds {
40        object.key("TaskTimeLimitInSeconds").number(
41            #[allow(clippy::useless_conversion)]
42            ::aws_smithy_types::Number::NegInt((*var_11).into()),
43        );
44    }
45    if let Some(var_12) = &input.task_availability_lifetime_in_seconds {
46        object.key("TaskAvailabilityLifetimeInSeconds").number(
47            #[allow(clippy::useless_conversion)]
48            ::aws_smithy_types::Number::NegInt((*var_12).into()),
49        );
50    }
51    if let Some(var_13) = &input.max_concurrent_task_count {
52        object.key("MaxConcurrentTaskCount").number(
53            #[allow(clippy::useless_conversion)]
54            ::aws_smithy_types::Number::NegInt((*var_13).into()),
55        );
56    }
57    if let Some(var_14) = &input.annotation_consolidation_config {
58        #[allow(unused_mut)]
59        let mut object_15 = object.key("AnnotationConsolidationConfig").start_object();
60        crate::protocol_serde::shape_annotation_consolidation_config::ser_annotation_consolidation_config(&mut object_15, var_14)?;
61        object_15.finish();
62    }
63    if let Some(var_16) = &input.public_workforce_task_price {
64        #[allow(unused_mut)]
65        let mut object_17 = object.key("PublicWorkforceTaskPrice").start_object();
66        crate::protocol_serde::shape_public_workforce_task_price::ser_public_workforce_task_price(&mut object_17, var_16)?;
67        object_17.finish();
68    }
69    Ok(())
70}
71
72pub(crate) fn de_human_task_config<'a, I>(
73    tokens: &mut ::std::iter::Peekable<I>,
74) -> ::std::result::Result<Option<crate::types::HumanTaskConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
75where
76    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
77{
78    match tokens.next().transpose()? {
79        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
80        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
81            #[allow(unused_mut)]
82            let mut builder = crate::types::builders::HumanTaskConfigBuilder::default();
83            loop {
84                match tokens.next().transpose()? {
85                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
86                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
87                        "WorkteamArn" => {
88                            builder = builder.set_workteam_arn(
89                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
90                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
91                                    .transpose()?,
92                            );
93                        }
94                        "UiConfig" => {
95                            builder = builder.set_ui_config(crate::protocol_serde::shape_ui_config::de_ui_config(tokens)?);
96                        }
97                        "PreHumanTaskLambdaArn" => {
98                            builder = builder.set_pre_human_task_lambda_arn(
99                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
100                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
101                                    .transpose()?,
102                            );
103                        }
104                        "TaskKeywords" => {
105                            builder = builder.set_task_keywords(crate::protocol_serde::shape_task_keywords::de_task_keywords(tokens)?);
106                        }
107                        "TaskTitle" => {
108                            builder = builder.set_task_title(
109                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
110                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
111                                    .transpose()?,
112                            );
113                        }
114                        "TaskDescription" => {
115                            builder = builder.set_task_description(
116                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
117                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
118                                    .transpose()?,
119                            );
120                        }
121                        "NumberOfHumanWorkersPerDataObject" => {
122                            builder = builder.set_number_of_human_workers_per_data_object(
123                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
124                                    .map(i32::try_from)
125                                    .transpose()?,
126                            );
127                        }
128                        "TaskTimeLimitInSeconds" => {
129                            builder = builder.set_task_time_limit_in_seconds(
130                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
131                                    .map(i32::try_from)
132                                    .transpose()?,
133                            );
134                        }
135                        "TaskAvailabilityLifetimeInSeconds" => {
136                            builder = builder.set_task_availability_lifetime_in_seconds(
137                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
138                                    .map(i32::try_from)
139                                    .transpose()?,
140                            );
141                        }
142                        "MaxConcurrentTaskCount" => {
143                            builder = builder.set_max_concurrent_task_count(
144                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
145                                    .map(i32::try_from)
146                                    .transpose()?,
147                            );
148                        }
149                        "AnnotationConsolidationConfig" => {
150                            builder = builder.set_annotation_consolidation_config(
151                                crate::protocol_serde::shape_annotation_consolidation_config::de_annotation_consolidation_config(tokens)?,
152                            );
153                        }
154                        "PublicWorkforceTaskPrice" => {
155                            builder = builder.set_public_workforce_task_price(
156                                crate::protocol_serde::shape_public_workforce_task_price::de_public_workforce_task_price(tokens)?,
157                            );
158                        }
159                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
160                    },
161                    other => {
162                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
163                            "expected object key or end object, found: {:?}",
164                            other
165                        )))
166                    }
167                }
168            }
169            Ok(Some(crate::serde_util::human_task_config_correct_errors(builder).build()))
170        }
171        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
172            "expected start object or null",
173        )),
174    }
175}