aws_sdk_amp/protocol_serde/
shape_eks_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_eks_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::EksConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("clusterArn").string(input.cluster_arn.as_str());
8    }
9    if let Some(var_1) = &input.security_group_ids {
10        let mut array_2 = object.key("securityGroupIds").start_array();
11        for item_3 in var_1 {
12            {
13                array_2.value().string(item_3.as_str());
14            }
15        }
16        array_2.finish();
17    }
18    {
19        let mut array_4 = object.key("subnetIds").start_array();
20        for item_5 in &input.subnet_ids {
21            {
22                array_4.value().string(item_5.as_str());
23            }
24        }
25        array_4.finish();
26    }
27    Ok(())
28}
29
30pub(crate) fn de_eks_configuration<'a, I>(
31    tokens: &mut ::std::iter::Peekable<I>,
32) -> ::std::result::Result<Option<crate::types::EksConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
33where
34    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
35{
36    match tokens.next().transpose()? {
37        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
38        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
39            #[allow(unused_mut)]
40            let mut builder = crate::types::builders::EksConfigurationBuilder::default();
41            loop {
42                match tokens.next().transpose()? {
43                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
44                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
45                        "clusterArn" => {
46                            builder = builder.set_cluster_arn(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
49                                    .transpose()?,
50                            );
51                        }
52                        "securityGroupIds" => {
53                            builder = builder.set_security_group_ids(crate::protocol_serde::shape_security_group_ids::de_security_group_ids(tokens)?);
54                        }
55                        "subnetIds" => {
56                            builder = builder.set_subnet_ids(crate::protocol_serde::shape_subnet_ids::de_subnet_ids(tokens)?);
57                        }
58                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
59                    },
60                    other => {
61                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
62                            "expected object key or end object, found: {:?}",
63                            other
64                        )))
65                    }
66                }
67            }
68            Ok(Some(crate::serde_util::eks_configuration_correct_errors(builder).build().map_err(
69                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
70            )?))
71        }
72        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
73            "expected start object or null",
74        )),
75    }
76}