aws_sdk_sagemaker/protocol_serde/
shape_hyper_parameter_tuning_resource_config.rs1pub fn ser_hyper_parameter_tuning_resource_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::HyperParameterTuningResourceConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.instance_type {
7 object.key("InstanceType").string(var_1.as_str());
8 }
9 if let Some(var_2) = &input.instance_count {
10 object.key("InstanceCount").number(
11 #[allow(clippy::useless_conversion)]
12 ::aws_smithy_types::Number::NegInt((*var_2).into()),
13 );
14 }
15 if let Some(var_3) = &input.volume_size_in_gb {
16 object.key("VolumeSizeInGB").number(
17 #[allow(clippy::useless_conversion)]
18 ::aws_smithy_types::Number::NegInt((*var_3).into()),
19 );
20 }
21 if let Some(var_4) = &input.volume_kms_key_id {
22 object.key("VolumeKmsKeyId").string(var_4.as_str());
23 }
24 if let Some(var_5) = &input.allocation_strategy {
25 object.key("AllocationStrategy").string(var_5.as_str());
26 }
27 if let Some(var_6) = &input.instance_configs {
28 let mut array_7 = object.key("InstanceConfigs").start_array();
29 for item_8 in var_6 {
30 {
31 #[allow(unused_mut)]
32 let mut object_9 = array_7.value().start_object();
33 crate::protocol_serde::shape_hyper_parameter_tuning_instance_config::ser_hyper_parameter_tuning_instance_config(
34 &mut object_9,
35 item_8,
36 )?;
37 object_9.finish();
38 }
39 }
40 array_7.finish();
41 }
42 Ok(())
43}
44
45pub(crate) fn de_hyper_parameter_tuning_resource_config<'a, I>(
46 tokens: &mut ::std::iter::Peekable<I>,
47) -> ::std::result::Result<Option<crate::types::HyperParameterTuningResourceConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
48where
49 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
50{
51 match tokens.next().transpose()? {
52 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
53 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
54 #[allow(unused_mut)]
55 let mut builder = crate::types::builders::HyperParameterTuningResourceConfigBuilder::default();
56 loop {
57 match tokens.next().transpose()? {
58 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
59 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
60 "InstanceType" => {
61 builder = builder.set_instance_type(
62 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
63 .map(|s| s.to_unescaped().map(|u| crate::types::TrainingInstanceType::from(u.as_ref())))
64 .transpose()?,
65 );
66 }
67 "InstanceCount" => {
68 builder = builder.set_instance_count(
69 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
70 .map(i32::try_from)
71 .transpose()?,
72 );
73 }
74 "VolumeSizeInGB" => {
75 builder = builder.set_volume_size_in_gb(
76 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
77 .map(i32::try_from)
78 .transpose()?,
79 );
80 }
81 "VolumeKmsKeyId" => {
82 builder = builder.set_volume_kms_key_id(
83 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
84 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
85 .transpose()?,
86 );
87 }
88 "AllocationStrategy" => {
89 builder = builder.set_allocation_strategy(
90 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
91 .map(|s| {
92 s.to_unescaped()
93 .map(|u| crate::types::HyperParameterTuningAllocationStrategy::from(u.as_ref()))
94 })
95 .transpose()?,
96 );
97 }
98 "InstanceConfigs" => {
99 builder = builder.set_instance_configs(
100 crate::protocol_serde::shape_hyper_parameter_tuning_instance_configs::de_hyper_parameter_tuning_instance_configs(
101 tokens,
102 )?,
103 );
104 }
105 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
106 },
107 other => {
108 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
109 "expected object key or end object, found: {:?}",
110 other
111 )))
112 }
113 }
114 }
115 Ok(Some(builder.build()))
116 }
117 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
118 "expected start object or null",
119 )),
120 }
121}