pub(crate) fn de_opensearch_configuration<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::OpensearchConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::types::builders::OpensearchConfigurationBuilder::default();
loop {
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
"domainEndpoint" => {
builder = builder.set_domain_endpoint(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"indexName" => {
builder = builder.set_index_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"exactResponse" => {
builder = builder.set_exact_response(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"exactResponseFields" => {
builder = builder.set_exact_response_fields(
crate::protocol_serde::shape_exact_response_fields::de_exact_response_fields(tokens, _value)?,
);
}
"includeFields" => {
builder =
builder.set_include_fields(crate::protocol_serde::shape_os_include_fields::de_os_include_fields(tokens, _value)?);
}
_ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
},
other => {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
"expected object key or end object, found: {other:?}"
)))
}
}
}
Ok(Some(
crate::serde_util::opensearch_configuration_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}
pub fn ser_opensearch_configuration(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::OpensearchConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("domainEndpoint").string(input.domain_endpoint.as_str());
}
{
object.key("indexName").string(input.index_name.as_str());
}
if input.exact_response {
object.key("exactResponse").boolean(input.exact_response);
}
if let Some(var_1) = &input.exact_response_fields {
#[allow(unused_mut)]
let mut object_2 = object.key("exactResponseFields").start_object();
crate::protocol_serde::shape_exact_response_fields::ser_exact_response_fields(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.include_fields {
let mut array_4 = object.key("includeFields").start_array();
for item_5 in var_3 {
{
array_4.value().string(item_5.as_str());
}
}
array_4.finish();
}
Ok(())
}