aws-sdk-kendra 1.97.0

AWS SDK for AWSKendraFrontendService
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_salesforce_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::SalesforceConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    {
        object.key("ServerUrl").string(input.server_url.as_str());
    }
    {
        object.key("SecretArn").string(input.secret_arn.as_str());
    }
    if let Some(var_1) = &input.standard_object_configurations {
        let mut array_2 = object.key("StandardObjectConfigurations").start_array();
        for item_3 in var_1 {
            {
                #[allow(unused_mut)]
                let mut object_4 = array_2.value().start_object();
                crate::protocol_serde::shape_salesforce_standard_object_configuration::ser_salesforce_standard_object_configuration(
                    &mut object_4,
                    item_3,
                )?;
                object_4.finish();
            }
        }
        array_2.finish();
    }
    if let Some(var_5) = &input.knowledge_article_configuration {
        #[allow(unused_mut)]
        let mut object_6 = object.key("KnowledgeArticleConfiguration").start_object();
        crate::protocol_serde::shape_salesforce_knowledge_article_configuration::ser_salesforce_knowledge_article_configuration(
            &mut object_6,
            var_5,
        )?;
        object_6.finish();
    }
    if let Some(var_7) = &input.chatter_feed_configuration {
        #[allow(unused_mut)]
        let mut object_8 = object.key("ChatterFeedConfiguration").start_object();
        crate::protocol_serde::shape_salesforce_chatter_feed_configuration::ser_salesforce_chatter_feed_configuration(&mut object_8, var_7)?;
        object_8.finish();
    }
    if input.crawl_attachments {
        object.key("CrawlAttachments").boolean(input.crawl_attachments);
    }
    if let Some(var_9) = &input.standard_object_attachment_configuration {
        #[allow(unused_mut)]
        let mut object_10 = object.key("StandardObjectAttachmentConfiguration").start_object();
        crate::protocol_serde::shape_salesforce_standard_object_attachment_configuration::ser_salesforce_standard_object_attachment_configuration(
            &mut object_10,
            var_9,
        )?;
        object_10.finish();
    }
    if let Some(var_11) = &input.include_attachment_file_patterns {
        let mut array_12 = object.key("IncludeAttachmentFilePatterns").start_array();
        for item_13 in var_11 {
            {
                array_12.value().string(item_13.as_str());
            }
        }
        array_12.finish();
    }
    if let Some(var_14) = &input.exclude_attachment_file_patterns {
        let mut array_15 = object.key("ExcludeAttachmentFilePatterns").start_array();
        for item_16 in var_14 {
            {
                array_15.value().string(item_16.as_str());
            }
        }
        array_15.finish();
    }
    Ok(())
}

pub(crate) fn de_salesforce_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::SalesforceConfiguration>, ::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::SalesforceConfigurationBuilder::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() {
                            "ServerUrl" => {
                                builder = builder.set_server_url(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                        .transpose()?,
                                );
                            }
                            "SecretArn" => {
                                builder = builder.set_secret_arn(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                        .transpose()?,
                                );
                            }
                            "StandardObjectConfigurations" => {
                                builder = builder.set_standard_object_configurations(
                                    crate::protocol_serde::shape_salesforce_standard_object_configuration_list::de_salesforce_standard_object_configuration_list(tokens, _value)?
                                );
                            }
                            "KnowledgeArticleConfiguration" => {
                                builder = builder.set_knowledge_article_configuration(
                                    crate::protocol_serde::shape_salesforce_knowledge_article_configuration::de_salesforce_knowledge_article_configuration(tokens, _value)?
                                );
                            }
                            "ChatterFeedConfiguration" => {
                                builder = builder.set_chatter_feed_configuration(
                                    crate::protocol_serde::shape_salesforce_chatter_feed_configuration::de_salesforce_chatter_feed_configuration(
                                        tokens, _value,
                                    )?,
                                );
                            }
                            "CrawlAttachments" => {
                                builder = builder.set_crawl_attachments(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                            }
                            "StandardObjectAttachmentConfiguration" => {
                                builder = builder.set_standard_object_attachment_configuration(
                                    crate::protocol_serde::shape_salesforce_standard_object_attachment_configuration::de_salesforce_standard_object_attachment_configuration(tokens, _value)?
                                );
                            }
                            "IncludeAttachmentFilePatterns" => {
                                builder = builder.set_include_attachment_file_patterns(
                                    crate::protocol_serde::shape_data_source_inclusions_exclusions_strings::de_data_source_inclusions_exclusions_strings(tokens, _value)?
                                );
                            }
                            "ExcludeAttachmentFilePatterns" => {
                                builder = builder.set_exclude_attachment_file_patterns(
                                    crate::protocol_serde::shape_data_source_inclusions_exclusions_strings::de_data_source_inclusions_exclusions_strings(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::salesforce_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",
        )),
    }
}