{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Kendra.Types.SalesforceCustomKnowledgeArticleTypeConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kendra.Types.SalesforceCustomKnowledgeArticleTypeConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.DataSourceToIndexFieldMapping
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information for indexing Salesforce custom
-- articles.
--
-- /See:/ 'newSalesforceCustomKnowledgeArticleTypeConfiguration' smart constructor.
data SalesforceCustomKnowledgeArticleTypeConfiguration = SalesforceCustomKnowledgeArticleTypeConfiguration'
  { -- | The name of the field in the custom knowledge article that contains the
    -- document title.
    SalesforceCustomKnowledgeArticleTypeConfiguration -> Maybe Text
documentTitleFieldName :: Prelude.Maybe Prelude.Text,
    -- | Maps attributes or field names of the custom knowledge article to Amazon
    -- Kendra index field names. To create custom fields, use the @UpdateIndex@
    -- API before you map to Salesforce fields. For more information, see
    -- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
    -- The Salesforce data source field names must exist in your Salesforce
    -- custom metadata.
    SalesforceCustomKnowledgeArticleTypeConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping),
    -- | The name of the configuration.
    SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
name :: Prelude.Text,
    -- | The name of the field in the custom knowledge article that contains the
    -- document data to index.
    SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
documentDataFieldName :: Prelude.Text
  }
  deriving (SalesforceCustomKnowledgeArticleTypeConfiguration
-> SalesforceCustomKnowledgeArticleTypeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> SalesforceCustomKnowledgeArticleTypeConfiguration -> Bool
$c/= :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> SalesforceCustomKnowledgeArticleTypeConfiguration -> Bool
== :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> SalesforceCustomKnowledgeArticleTypeConfiguration -> Bool
$c== :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> SalesforceCustomKnowledgeArticleTypeConfiguration -> Bool
Prelude.Eq, ReadPrec [SalesforceCustomKnowledgeArticleTypeConfiguration]
ReadPrec SalesforceCustomKnowledgeArticleTypeConfiguration
Int -> ReadS SalesforceCustomKnowledgeArticleTypeConfiguration
ReadS [SalesforceCustomKnowledgeArticleTypeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SalesforceCustomKnowledgeArticleTypeConfiguration]
$creadListPrec :: ReadPrec [SalesforceCustomKnowledgeArticleTypeConfiguration]
readPrec :: ReadPrec SalesforceCustomKnowledgeArticleTypeConfiguration
$creadPrec :: ReadPrec SalesforceCustomKnowledgeArticleTypeConfiguration
readList :: ReadS [SalesforceCustomKnowledgeArticleTypeConfiguration]
$creadList :: ReadS [SalesforceCustomKnowledgeArticleTypeConfiguration]
readsPrec :: Int -> ReadS SalesforceCustomKnowledgeArticleTypeConfiguration
$creadsPrec :: Int -> ReadS SalesforceCustomKnowledgeArticleTypeConfiguration
Prelude.Read, Int -> SalesforceCustomKnowledgeArticleTypeConfiguration -> ShowS
[SalesforceCustomKnowledgeArticleTypeConfiguration] -> ShowS
SalesforceCustomKnowledgeArticleTypeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SalesforceCustomKnowledgeArticleTypeConfiguration] -> ShowS
$cshowList :: [SalesforceCustomKnowledgeArticleTypeConfiguration] -> ShowS
show :: SalesforceCustomKnowledgeArticleTypeConfiguration -> String
$cshow :: SalesforceCustomKnowledgeArticleTypeConfiguration -> String
showsPrec :: Int -> SalesforceCustomKnowledgeArticleTypeConfiguration -> ShowS
$cshowsPrec :: Int -> SalesforceCustomKnowledgeArticleTypeConfiguration -> ShowS
Prelude.Show, forall x.
Rep SalesforceCustomKnowledgeArticleTypeConfiguration x
-> SalesforceCustomKnowledgeArticleTypeConfiguration
forall x.
SalesforceCustomKnowledgeArticleTypeConfiguration
-> Rep SalesforceCustomKnowledgeArticleTypeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SalesforceCustomKnowledgeArticleTypeConfiguration x
-> SalesforceCustomKnowledgeArticleTypeConfiguration
$cfrom :: forall x.
SalesforceCustomKnowledgeArticleTypeConfiguration
-> Rep SalesforceCustomKnowledgeArticleTypeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SalesforceCustomKnowledgeArticleTypeConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'documentTitleFieldName', 'salesforceCustomKnowledgeArticleTypeConfiguration_documentTitleFieldName' - The name of the field in the custom knowledge article that contains the
-- document title.
--
-- 'fieldMappings', 'salesforceCustomKnowledgeArticleTypeConfiguration_fieldMappings' - Maps attributes or field names of the custom knowledge article to Amazon
-- Kendra index field names. To create custom fields, use the @UpdateIndex@
-- API before you map to Salesforce fields. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
-- The Salesforce data source field names must exist in your Salesforce
-- custom metadata.
--
-- 'name', 'salesforceCustomKnowledgeArticleTypeConfiguration_name' - The name of the configuration.
--
-- 'documentDataFieldName', 'salesforceCustomKnowledgeArticleTypeConfiguration_documentDataFieldName' - The name of the field in the custom knowledge article that contains the
-- document data to index.
newSalesforceCustomKnowledgeArticleTypeConfiguration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'documentDataFieldName'
  Prelude.Text ->
  SalesforceCustomKnowledgeArticleTypeConfiguration
newSalesforceCustomKnowledgeArticleTypeConfiguration :: Text -> Text -> SalesforceCustomKnowledgeArticleTypeConfiguration
newSalesforceCustomKnowledgeArticleTypeConfiguration
  Text
pName_
  Text
pDocumentDataFieldName_ =
    SalesforceCustomKnowledgeArticleTypeConfiguration'
      { $sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Maybe Text
documentTitleFieldName =
          forall a. Maybe a
Prelude.Nothing,
        $sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings =
          forall a. Maybe a
Prelude.Nothing,
        $sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Text
name = Text
pName_,
        $sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Text
documentDataFieldName =
          Text
pDocumentDataFieldName_
      }

-- | The name of the field in the custom knowledge article that contains the
-- document title.
salesforceCustomKnowledgeArticleTypeConfiguration_documentTitleFieldName :: Lens.Lens' SalesforceCustomKnowledgeArticleTypeConfiguration (Prelude.Maybe Prelude.Text)
salesforceCustomKnowledgeArticleTypeConfiguration_documentTitleFieldName :: Lens'
  SalesforceCustomKnowledgeArticleTypeConfiguration (Maybe Text)
salesforceCustomKnowledgeArticleTypeConfiguration_documentTitleFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceCustomKnowledgeArticleTypeConfiguration' {Maybe Text
documentTitleFieldName :: Maybe Text
$sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Maybe Text
documentTitleFieldName} -> Maybe Text
documentTitleFieldName) (\s :: SalesforceCustomKnowledgeArticleTypeConfiguration
s@SalesforceCustomKnowledgeArticleTypeConfiguration' {} Maybe Text
a -> SalesforceCustomKnowledgeArticleTypeConfiguration
s {$sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Maybe Text
documentTitleFieldName = Maybe Text
a} :: SalesforceCustomKnowledgeArticleTypeConfiguration)

-- | Maps attributes or field names of the custom knowledge article to Amazon
-- Kendra index field names. To create custom fields, use the @UpdateIndex@
-- API before you map to Salesforce fields. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
-- The Salesforce data source field names must exist in your Salesforce
-- custom metadata.
salesforceCustomKnowledgeArticleTypeConfiguration_fieldMappings :: Lens.Lens' SalesforceCustomKnowledgeArticleTypeConfiguration (Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping))
salesforceCustomKnowledgeArticleTypeConfiguration_fieldMappings :: Lens'
  SalesforceCustomKnowledgeArticleTypeConfiguration
  (Maybe (NonEmpty DataSourceToIndexFieldMapping))
salesforceCustomKnowledgeArticleTypeConfiguration_fieldMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceCustomKnowledgeArticleTypeConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings} -> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings) (\s :: SalesforceCustomKnowledgeArticleTypeConfiguration
s@SalesforceCustomKnowledgeArticleTypeConfiguration' {} Maybe (NonEmpty DataSourceToIndexFieldMapping)
a -> SalesforceCustomKnowledgeArticleTypeConfiguration
s {$sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings = Maybe (NonEmpty DataSourceToIndexFieldMapping)
a} :: SalesforceCustomKnowledgeArticleTypeConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the configuration.
salesforceCustomKnowledgeArticleTypeConfiguration_name :: Lens.Lens' SalesforceCustomKnowledgeArticleTypeConfiguration Prelude.Text
salesforceCustomKnowledgeArticleTypeConfiguration_name :: Lens' SalesforceCustomKnowledgeArticleTypeConfiguration Text
salesforceCustomKnowledgeArticleTypeConfiguration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceCustomKnowledgeArticleTypeConfiguration' {Text
name :: Text
$sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
name} -> Text
name) (\s :: SalesforceCustomKnowledgeArticleTypeConfiguration
s@SalesforceCustomKnowledgeArticleTypeConfiguration' {} Text
a -> SalesforceCustomKnowledgeArticleTypeConfiguration
s {$sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Text
name = Text
a} :: SalesforceCustomKnowledgeArticleTypeConfiguration)

-- | The name of the field in the custom knowledge article that contains the
-- document data to index.
salesforceCustomKnowledgeArticleTypeConfiguration_documentDataFieldName :: Lens.Lens' SalesforceCustomKnowledgeArticleTypeConfiguration Prelude.Text
salesforceCustomKnowledgeArticleTypeConfiguration_documentDataFieldName :: Lens' SalesforceCustomKnowledgeArticleTypeConfiguration Text
salesforceCustomKnowledgeArticleTypeConfiguration_documentDataFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceCustomKnowledgeArticleTypeConfiguration' {Text
documentDataFieldName :: Text
$sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
documentDataFieldName} -> Text
documentDataFieldName) (\s :: SalesforceCustomKnowledgeArticleTypeConfiguration
s@SalesforceCustomKnowledgeArticleTypeConfiguration' {} Text
a -> SalesforceCustomKnowledgeArticleTypeConfiguration
s {$sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: Text
documentDataFieldName = Text
a} :: SalesforceCustomKnowledgeArticleTypeConfiguration)

instance
  Data.FromJSON
    SalesforceCustomKnowledgeArticleTypeConfiguration
  where
  parseJSON :: Value -> Parser SalesforceCustomKnowledgeArticleTypeConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SalesforceCustomKnowledgeArticleTypeConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
-> Text
-> Text
-> SalesforceCustomKnowledgeArticleTypeConfiguration
SalesforceCustomKnowledgeArticleTypeConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DocumentTitleFieldName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FieldMappings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DocumentDataFieldName")
      )

instance
  Prelude.Hashable
    SalesforceCustomKnowledgeArticleTypeConfiguration
  where
  hashWithSalt :: Int -> SalesforceCustomKnowledgeArticleTypeConfiguration -> Int
hashWithSalt
    Int
_salt
    SalesforceCustomKnowledgeArticleTypeConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
documentDataFieldName :: Text
name :: Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
documentTitleFieldName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentDataFieldName

instance
  Prelude.NFData
    SalesforceCustomKnowledgeArticleTypeConfiguration
  where
  rnf :: SalesforceCustomKnowledgeArticleTypeConfiguration -> ()
rnf
    SalesforceCustomKnowledgeArticleTypeConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
documentDataFieldName :: Text
name :: Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Maybe Text
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
documentTitleFieldName
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentDataFieldName

instance
  Data.ToJSON
    SalesforceCustomKnowledgeArticleTypeConfiguration
  where
  toJSON :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Value
toJSON
    SalesforceCustomKnowledgeArticleTypeConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
documentDataFieldName :: Text
name :: Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:name:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Text
$sel:fieldMappings:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceCustomKnowledgeArticleTypeConfiguration' :: SalesforceCustomKnowledgeArticleTypeConfiguration -> Maybe Text
..} =
      [Pair] -> Value
Data.object
        ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Key
"DocumentTitleFieldName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
documentTitleFieldName,
              (Key
"FieldMappings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings,
              forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
              forall a. a -> Maybe a
Prelude.Just
                ( Key
"DocumentDataFieldName"
                    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
documentDataFieldName
                )
            ]
        )