pub fn ser_knowledge_base_retrieve_and_generate_configuration(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::KnowledgeBaseRetrieveAndGenerateConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("knowledgeBaseId").string(input.knowledge_base_id.as_str());
}
{
object.key("modelArn").string(input.model_arn.as_str());
}
if let Some(var_1) = &input.retrieval_configuration {
#[allow(unused_mut)]
let mut object_2 = object.key("retrievalConfiguration").start_object();
crate::protocol_serde::shape_knowledge_base_retrieval_configuration::ser_knowledge_base_retrieval_configuration(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.generation_configuration {
#[allow(unused_mut)]
let mut object_4 = object.key("generationConfiguration").start_object();
crate::protocol_serde::shape_generation_configuration::ser_generation_configuration(&mut object_4, var_3)?;
object_4.finish();
}
if let Some(var_5) = &input.orchestration_configuration {
#[allow(unused_mut)]
let mut object_6 = object.key("orchestrationConfiguration").start_object();
crate::protocol_serde::shape_orchestration_configuration::ser_orchestration_configuration(&mut object_6, var_5)?;
object_6.finish();
}
Ok(())
}
pub(crate) fn de_knowledge_base_retrieve_and_generate_configuration<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::KnowledgeBaseRetrieveAndGenerateConfiguration>, ::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::KnowledgeBaseRetrieveAndGenerateConfigurationBuilder::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() {
"knowledgeBaseId" => {
builder = builder.set_knowledge_base_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"modelArn" => {
builder = builder.set_model_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"retrievalConfiguration" => {
builder = builder.set_retrieval_configuration(
crate::protocol_serde::shape_knowledge_base_retrieval_configuration::de_knowledge_base_retrieval_configuration(
tokens, _value,
)?,
);
}
"generationConfiguration" => {
builder = builder.set_generation_configuration(
crate::protocol_serde::shape_generation_configuration::de_generation_configuration(tokens, _value)?,
);
}
"orchestrationConfiguration" => {
builder = builder.set_orchestration_configuration(
crate::protocol_serde::shape_orchestration_configuration::de_orchestration_configuration(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::knowledge_base_retrieve_and_generate_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",
)),
}
}