aws_sdk_sagemaker/protocol_serde/
shape_monitoring_app_specification.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_monitoring_app_specification(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::MonitoringAppSpecification,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.image_uri {
7        object.key("ImageUri").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.container_entrypoint {
10        let mut array_3 = object.key("ContainerEntrypoint").start_array();
11        for item_4 in var_2 {
12            {
13                array_3.value().string(item_4.as_str());
14            }
15        }
16        array_3.finish();
17    }
18    if let Some(var_5) = &input.container_arguments {
19        let mut array_6 = object.key("ContainerArguments").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.record_preprocessor_source_uri {
28        object.key("RecordPreprocessorSourceUri").string(var_8.as_str());
29    }
30    if let Some(var_9) = &input.post_analytics_processor_source_uri {
31        object.key("PostAnalyticsProcessorSourceUri").string(var_9.as_str());
32    }
33    Ok(())
34}
35
36pub(crate) fn de_monitoring_app_specification<'a, I>(
37    tokens: &mut ::std::iter::Peekable<I>,
38) -> ::std::result::Result<Option<crate::types::MonitoringAppSpecification>, ::aws_smithy_json::deserialize::error::DeserializeError>
39where
40    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
41{
42    match tokens.next().transpose()? {
43        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
44        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
45            #[allow(unused_mut)]
46            let mut builder = crate::types::builders::MonitoringAppSpecificationBuilder::default();
47            loop {
48                match tokens.next().transpose()? {
49                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
50                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
51                        "ImageUri" => {
52                            builder = builder.set_image_uri(
53                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
54                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
55                                    .transpose()?,
56                            );
57                        }
58                        "ContainerEntrypoint" => {
59                            builder =
60                                builder.set_container_entrypoint(crate::protocol_serde::shape_container_entrypoint::de_container_entrypoint(tokens)?);
61                        }
62                        "ContainerArguments" => {
63                            builder = builder.set_container_arguments(
64                                crate::protocol_serde::shape_monitoring_container_arguments::de_monitoring_container_arguments(tokens)?,
65                            );
66                        }
67                        "RecordPreprocessorSourceUri" => {
68                            builder = builder.set_record_preprocessor_source_uri(
69                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
70                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
71                                    .transpose()?,
72                            );
73                        }
74                        "PostAnalyticsProcessorSourceUri" => {
75                            builder = builder.set_post_analytics_processor_source_uri(
76                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
77                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
78                                    .transpose()?,
79                            );
80                        }
81                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
82                    },
83                    other => {
84                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
85                            "expected object key or end object, found: {:?}",
86                            other
87                        )))
88                    }
89                }
90            }
91            Ok(Some(crate::serde_util::monitoring_app_specification_correct_errors(builder).build()))
92        }
93        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
94            "expected start object or null",
95        )),
96    }
97}