aws_sdk_elasticsearch/protocol_serde/
shape_domain_endpoint_options.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_domain_endpoint_options(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::DomainEndpointOptions,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.enforce_https {
7        object.key("EnforceHTTPS").boolean(*var_1);
8    }
9    if let Some(var_2) = &input.tls_security_policy {
10        object.key("TLSSecurityPolicy").string(var_2.as_str());
11    }
12    if let Some(var_3) = &input.custom_endpoint_enabled {
13        object.key("CustomEndpointEnabled").boolean(*var_3);
14    }
15    if let Some(var_4) = &input.custom_endpoint {
16        object.key("CustomEndpoint").string(var_4.as_str());
17    }
18    if let Some(var_5) = &input.custom_endpoint_certificate_arn {
19        object.key("CustomEndpointCertificateArn").string(var_5.as_str());
20    }
21    Ok(())
22}
23
24pub(crate) fn de_domain_endpoint_options<'a, I>(
25    tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::DomainEndpointOptions>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30    match tokens.next().transpose()? {
31        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33            #[allow(unused_mut)]
34            let mut builder = crate::types::builders::DomainEndpointOptionsBuilder::default();
35            loop {
36                match tokens.next().transpose()? {
37                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39                        "EnforceHTTPS" => {
40                            builder = builder.set_enforce_https(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
41                        }
42                        "TLSSecurityPolicy" => {
43                            builder = builder.set_tls_security_policy(
44                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45                                    .map(|s| s.to_unescaped().map(|u| crate::types::TlsSecurityPolicy::from(u.as_ref())))
46                                    .transpose()?,
47                            );
48                        }
49                        "CustomEndpointEnabled" => {
50                            builder = builder.set_custom_endpoint_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
51                        }
52                        "CustomEndpoint" => {
53                            builder = builder.set_custom_endpoint(
54                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
55                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
56                                    .transpose()?,
57                            );
58                        }
59                        "CustomEndpointCertificateArn" => {
60                            builder = builder.set_custom_endpoint_certificate_arn(
61                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
62                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
63                                    .transpose()?,
64                            );
65                        }
66                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
67                    },
68                    other => {
69                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
70                            "expected object key or end object, found: {:?}",
71                            other
72                        )))
73                    }
74                }
75            }
76            Ok(Some(builder.build()))
77        }
78        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
79            "expected start object or null",
80        )),
81    }
82}