aws_sdk_ssmincidents/protocol_serde/
shape_incident_template.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_incident_template(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::IncidentTemplate,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("title").string(input.title.as_str());
8    }
9    {
10        object.key("impact").number(
11            #[allow(clippy::useless_conversion)]
12            ::aws_smithy_types::Number::NegInt((input.impact).into()),
13        );
14    }
15    if let Some(var_1) = &input.summary {
16        object.key("summary").string(var_1.as_str());
17    }
18    if let Some(var_2) = &input.dedupe_string {
19        object.key("dedupeString").string(var_2.as_str());
20    }
21    if let Some(var_3) = &input.notification_targets {
22        let mut array_4 = object.key("notificationTargets").start_array();
23        for item_5 in var_3 {
24            {
25                #[allow(unused_mut)]
26                let mut object_6 = array_4.value().start_object();
27                crate::protocol_serde::shape_notification_target_item::ser_notification_target_item(&mut object_6, item_5)?;
28                object_6.finish();
29            }
30        }
31        array_4.finish();
32    }
33    if let Some(var_7) = &input.incident_tags {
34        #[allow(unused_mut)]
35        let mut object_8 = object.key("incidentTags").start_object();
36        for (key_9, value_10) in var_7 {
37            {
38                object_8.key(key_9.as_str()).string(value_10.as_str());
39            }
40        }
41        object_8.finish();
42    }
43    Ok(())
44}
45
46pub(crate) fn de_incident_template<'a, I>(
47    tokens: &mut ::std::iter::Peekable<I>,
48) -> ::std::result::Result<Option<crate::types::IncidentTemplate>, ::aws_smithy_json::deserialize::error::DeserializeError>
49where
50    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
51{
52    match tokens.next().transpose()? {
53        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
54        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
55            #[allow(unused_mut)]
56            let mut builder = crate::types::builders::IncidentTemplateBuilder::default();
57            loop {
58                match tokens.next().transpose()? {
59                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
60                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
61                        "title" => {
62                            builder = builder.set_title(
63                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
64                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
65                                    .transpose()?,
66                            );
67                        }
68                        "impact" => {
69                            builder = builder.set_impact(
70                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
71                                    .map(i32::try_from)
72                                    .transpose()?,
73                            );
74                        }
75                        "summary" => {
76                            builder = builder.set_summary(
77                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
78                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
79                                    .transpose()?,
80                            );
81                        }
82                        "dedupeString" => {
83                            builder = builder.set_dedupe_string(
84                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
85                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
86                                    .transpose()?,
87                            );
88                        }
89                        "notificationTargets" => {
90                            builder = builder
91                                .set_notification_targets(crate::protocol_serde::shape_notification_target_set::de_notification_target_set(tokens)?);
92                        }
93                        "incidentTags" => {
94                            builder = builder.set_incident_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
95                        }
96                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
97                    },
98                    other => {
99                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
100                            "expected object key or end object, found: {:?}",
101                            other
102                        )))
103                    }
104                }
105            }
106            Ok(Some(crate::serde_util::incident_template_correct_errors(builder).build().map_err(
107                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
108            )?))
109        }
110        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
111            "expected start object or null",
112        )),
113    }
114}