aws_sdk_sagemaker/protocol_serde/
shape_monitoring_schedule_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_monitoring_schedule_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::MonitoringScheduleConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.schedule_config {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("ScheduleConfig").start_object();
9        crate::protocol_serde::shape_schedule_config::ser_schedule_config(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.monitoring_job_definition {
13        #[allow(unused_mut)]
14        let mut object_4 = object.key("MonitoringJobDefinition").start_object();
15        crate::protocol_serde::shape_monitoring_job_definition::ser_monitoring_job_definition(&mut object_4, var_3)?;
16        object_4.finish();
17    }
18    if let Some(var_5) = &input.monitoring_job_definition_name {
19        object.key("MonitoringJobDefinitionName").string(var_5.as_str());
20    }
21    if let Some(var_6) = &input.monitoring_type {
22        object.key("MonitoringType").string(var_6.as_str());
23    }
24    Ok(())
25}
26
27pub(crate) fn de_monitoring_schedule_config<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::MonitoringScheduleConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33    match tokens.next().transpose()? {
34        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36            #[allow(unused_mut)]
37            let mut builder = crate::types::builders::MonitoringScheduleConfigBuilder::default();
38            loop {
39                match tokens.next().transpose()? {
40                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42                        "ScheduleConfig" => {
43                            builder = builder.set_schedule_config(crate::protocol_serde::shape_schedule_config::de_schedule_config(tokens)?);
44                        }
45                        "MonitoringJobDefinition" => {
46                            builder = builder.set_monitoring_job_definition(
47                                crate::protocol_serde::shape_monitoring_job_definition::de_monitoring_job_definition(tokens)?,
48                            );
49                        }
50                        "MonitoringJobDefinitionName" => {
51                            builder = builder.set_monitoring_job_definition_name(
52                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
53                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
54                                    .transpose()?,
55                            );
56                        }
57                        "MonitoringType" => {
58                            builder = builder.set_monitoring_type(
59                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
60                                    .map(|s| s.to_unescaped().map(|u| crate::types::MonitoringType::from(u.as_ref())))
61                                    .transpose()?,
62                            );
63                        }
64                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
65                    },
66                    other => {
67                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
68                            "expected object key or end object, found: {:?}",
69                            other
70                        )))
71                    }
72                }
73            }
74            Ok(Some(builder.build()))
75        }
76        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
77            "expected start object or null",
78        )),
79    }
80}