aws_sdk_sagemaker/protocol_serde/
shape_data_capture_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_data_capture_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::DataCaptureConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.enable_capture {
7        object.key("EnableCapture").boolean(*var_1);
8    }
9    if let Some(var_2) = &input.initial_sampling_percentage {
10        object.key("InitialSamplingPercentage").number(
11            #[allow(clippy::useless_conversion)]
12            ::aws_smithy_types::Number::NegInt((*var_2).into()),
13        );
14    }
15    if let Some(var_3) = &input.destination_s3_uri {
16        object.key("DestinationS3Uri").string(var_3.as_str());
17    }
18    if let Some(var_4) = &input.kms_key_id {
19        object.key("KmsKeyId").string(var_4.as_str());
20    }
21    if let Some(var_5) = &input.capture_options {
22        let mut array_6 = object.key("CaptureOptions").start_array();
23        for item_7 in var_5 {
24            {
25                #[allow(unused_mut)]
26                let mut object_8 = array_6.value().start_object();
27                crate::protocol_serde::shape_capture_option::ser_capture_option(&mut object_8, item_7)?;
28                object_8.finish();
29            }
30        }
31        array_6.finish();
32    }
33    if let Some(var_9) = &input.capture_content_type_header {
34        #[allow(unused_mut)]
35        let mut object_10 = object.key("CaptureContentTypeHeader").start_object();
36        crate::protocol_serde::shape_capture_content_type_header::ser_capture_content_type_header(&mut object_10, var_9)?;
37        object_10.finish();
38    }
39    Ok(())
40}
41
42pub(crate) fn de_data_capture_config<'a, I>(
43    tokens: &mut ::std::iter::Peekable<I>,
44) -> ::std::result::Result<Option<crate::types::DataCaptureConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
45where
46    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
47{
48    match tokens.next().transpose()? {
49        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
50        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
51            #[allow(unused_mut)]
52            let mut builder = crate::types::builders::DataCaptureConfigBuilder::default();
53            loop {
54                match tokens.next().transpose()? {
55                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
56                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
57                        "EnableCapture" => {
58                            builder = builder.set_enable_capture(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
59                        }
60                        "InitialSamplingPercentage" => {
61                            builder = builder.set_initial_sampling_percentage(
62                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
63                                    .map(i32::try_from)
64                                    .transpose()?,
65                            );
66                        }
67                        "DestinationS3Uri" => {
68                            builder = builder.set_destination_s3_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                        "KmsKeyId" => {
75                            builder = builder.set_kms_key_id(
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                        "CaptureOptions" => {
82                            builder = builder.set_capture_options(crate::protocol_serde::shape_capture_option_list::de_capture_option_list(tokens)?);
83                        }
84                        "CaptureContentTypeHeader" => {
85                            builder = builder.set_capture_content_type_header(
86                                crate::protocol_serde::shape_capture_content_type_header::de_capture_content_type_header(tokens)?,
87                            );
88                        }
89                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
90                    },
91                    other => {
92                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
93                            "expected object key or end object, found: {:?}",
94                            other
95                        )))
96                    }
97                }
98            }
99            Ok(Some(crate::serde_util::data_capture_config_correct_errors(builder).build()))
100        }
101        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
102            "expected start object or null",
103        )),
104    }
105}