{-# 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.SalesforceStandardObjectConfiguration
-- 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.SalesforceStandardObjectConfiguration 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 Amazonka.Kendra.Types.SalesforceStandardObjectName
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information for indexing a single standard
-- object.
--
-- /See:/ 'newSalesforceStandardObjectConfiguration' smart constructor.
data SalesforceStandardObjectConfiguration = SalesforceStandardObjectConfiguration'
  { -- | The name of the field in the standard object table that contains the
    -- document title.
    SalesforceStandardObjectConfiguration -> Maybe Text
documentTitleFieldName :: Prelude.Maybe Prelude.Text,
    -- | Maps attributes or field names of the standard object 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.
    SalesforceStandardObjectConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping),
    -- | The name of the standard object.
    SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectName
name :: SalesforceStandardObjectName,
    -- | The name of the field in the standard object table that contains the
    -- document contents.
    SalesforceStandardObjectConfiguration -> Text
documentDataFieldName :: Prelude.Text
  }
  deriving (SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectConfiguration -> Bool
$c/= :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectConfiguration -> Bool
== :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectConfiguration -> Bool
$c== :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectConfiguration -> Bool
Prelude.Eq, ReadPrec [SalesforceStandardObjectConfiguration]
ReadPrec SalesforceStandardObjectConfiguration
Int -> ReadS SalesforceStandardObjectConfiguration
ReadS [SalesforceStandardObjectConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SalesforceStandardObjectConfiguration]
$creadListPrec :: ReadPrec [SalesforceStandardObjectConfiguration]
readPrec :: ReadPrec SalesforceStandardObjectConfiguration
$creadPrec :: ReadPrec SalesforceStandardObjectConfiguration
readList :: ReadS [SalesforceStandardObjectConfiguration]
$creadList :: ReadS [SalesforceStandardObjectConfiguration]
readsPrec :: Int -> ReadS SalesforceStandardObjectConfiguration
$creadsPrec :: Int -> ReadS SalesforceStandardObjectConfiguration
Prelude.Read, Int -> SalesforceStandardObjectConfiguration -> ShowS
[SalesforceStandardObjectConfiguration] -> ShowS
SalesforceStandardObjectConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SalesforceStandardObjectConfiguration] -> ShowS
$cshowList :: [SalesforceStandardObjectConfiguration] -> ShowS
show :: SalesforceStandardObjectConfiguration -> String
$cshow :: SalesforceStandardObjectConfiguration -> String
showsPrec :: Int -> SalesforceStandardObjectConfiguration -> ShowS
$cshowsPrec :: Int -> SalesforceStandardObjectConfiguration -> ShowS
Prelude.Show, forall x.
Rep SalesforceStandardObjectConfiguration x
-> SalesforceStandardObjectConfiguration
forall x.
SalesforceStandardObjectConfiguration
-> Rep SalesforceStandardObjectConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SalesforceStandardObjectConfiguration x
-> SalesforceStandardObjectConfiguration
$cfrom :: forall x.
SalesforceStandardObjectConfiguration
-> Rep SalesforceStandardObjectConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SalesforceStandardObjectConfiguration' 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', 'salesforceStandardObjectConfiguration_documentTitleFieldName' - The name of the field in the standard object table that contains the
-- document title.
--
-- 'fieldMappings', 'salesforceStandardObjectConfiguration_fieldMappings' - Maps attributes or field names of the standard object 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', 'salesforceStandardObjectConfiguration_name' - The name of the standard object.
--
-- 'documentDataFieldName', 'salesforceStandardObjectConfiguration_documentDataFieldName' - The name of the field in the standard object table that contains the
-- document contents.
newSalesforceStandardObjectConfiguration ::
  -- | 'name'
  SalesforceStandardObjectName ->
  -- | 'documentDataFieldName'
  Prelude.Text ->
  SalesforceStandardObjectConfiguration
newSalesforceStandardObjectConfiguration :: SalesforceStandardObjectName
-> Text -> SalesforceStandardObjectConfiguration
newSalesforceStandardObjectConfiguration
  SalesforceStandardObjectName
pName_
  Text
pDocumentDataFieldName_ =
    SalesforceStandardObjectConfiguration'
      { $sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: Maybe Text
documentTitleFieldName =
          forall a. Maybe a
Prelude.Nothing,
        $sel:fieldMappings:SalesforceStandardObjectConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings = forall a. Maybe a
Prelude.Nothing,
        $sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectName
name = SalesforceStandardObjectName
pName_,
        $sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: Text
documentDataFieldName =
          Text
pDocumentDataFieldName_
      }

-- | The name of the field in the standard object table that contains the
-- document title.
salesforceStandardObjectConfiguration_documentTitleFieldName :: Lens.Lens' SalesforceStandardObjectConfiguration (Prelude.Maybe Prelude.Text)
salesforceStandardObjectConfiguration_documentTitleFieldName :: Lens' SalesforceStandardObjectConfiguration (Maybe Text)
salesforceStandardObjectConfiguration_documentTitleFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectConfiguration' {Maybe Text
documentTitleFieldName :: Maybe Text
$sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> Maybe Text
documentTitleFieldName} -> Maybe Text
documentTitleFieldName) (\s :: SalesforceStandardObjectConfiguration
s@SalesforceStandardObjectConfiguration' {} Maybe Text
a -> SalesforceStandardObjectConfiguration
s {$sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: Maybe Text
documentTitleFieldName = Maybe Text
a} :: SalesforceStandardObjectConfiguration)

-- | Maps attributes or field names of the standard object 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.
salesforceStandardObjectConfiguration_fieldMappings :: Lens.Lens' SalesforceStandardObjectConfiguration (Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping))
salesforceStandardObjectConfiguration_fieldMappings :: Lens'
  SalesforceStandardObjectConfiguration
  (Maybe (NonEmpty DataSourceToIndexFieldMapping))
salesforceStandardObjectConfiguration_fieldMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:fieldMappings:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings} -> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings) (\s :: SalesforceStandardObjectConfiguration
s@SalesforceStandardObjectConfiguration' {} Maybe (NonEmpty DataSourceToIndexFieldMapping)
a -> SalesforceStandardObjectConfiguration
s {$sel:fieldMappings:SalesforceStandardObjectConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings = Maybe (NonEmpty DataSourceToIndexFieldMapping)
a} :: SalesforceStandardObjectConfiguration) 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 standard object.
salesforceStandardObjectConfiguration_name :: Lens.Lens' SalesforceStandardObjectConfiguration SalesforceStandardObjectName
salesforceStandardObjectConfiguration_name :: Lens'
  SalesforceStandardObjectConfiguration SalesforceStandardObjectName
salesforceStandardObjectConfiguration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectConfiguration' {SalesforceStandardObjectName
name :: SalesforceStandardObjectName
$sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectName
name} -> SalesforceStandardObjectName
name) (\s :: SalesforceStandardObjectConfiguration
s@SalesforceStandardObjectConfiguration' {} SalesforceStandardObjectName
a -> SalesforceStandardObjectConfiguration
s {$sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectName
name = SalesforceStandardObjectName
a} :: SalesforceStandardObjectConfiguration)

-- | The name of the field in the standard object table that contains the
-- document contents.
salesforceStandardObjectConfiguration_documentDataFieldName :: Lens.Lens' SalesforceStandardObjectConfiguration Prelude.Text
salesforceStandardObjectConfiguration_documentDataFieldName :: Lens' SalesforceStandardObjectConfiguration Text
salesforceStandardObjectConfiguration_documentDataFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectConfiguration' {Text
documentDataFieldName :: Text
$sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> Text
documentDataFieldName} -> Text
documentDataFieldName) (\s :: SalesforceStandardObjectConfiguration
s@SalesforceStandardObjectConfiguration' {} Text
a -> SalesforceStandardObjectConfiguration
s {$sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: Text
documentDataFieldName = Text
a} :: SalesforceStandardObjectConfiguration)

instance
  Data.FromJSON
    SalesforceStandardObjectConfiguration
  where
  parseJSON :: Value -> Parser SalesforceStandardObjectConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SalesforceStandardObjectConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
-> SalesforceStandardObjectName
-> Text
-> SalesforceStandardObjectConfiguration
SalesforceStandardObjectConfiguration'
            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
    SalesforceStandardObjectConfiguration
  where
  hashWithSalt :: Int -> SalesforceStandardObjectConfiguration -> Int
hashWithSalt
    Int
_salt
    SalesforceStandardObjectConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
SalesforceStandardObjectName
documentDataFieldName :: Text
name :: SalesforceStandardObjectName
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> Text
$sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectName
$sel:fieldMappings:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> 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` SalesforceStandardObjectName
name
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentDataFieldName

instance
  Prelude.NFData
    SalesforceStandardObjectConfiguration
  where
  rnf :: SalesforceStandardObjectConfiguration -> ()
rnf SalesforceStandardObjectConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
SalesforceStandardObjectName
documentDataFieldName :: Text
name :: SalesforceStandardObjectName
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> Text
$sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectName
$sel:fieldMappings:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> 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 SalesforceStandardObjectName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentDataFieldName

instance
  Data.ToJSON
    SalesforceStandardObjectConfiguration
  where
  toJSON :: SalesforceStandardObjectConfiguration -> Value
toJSON SalesforceStandardObjectConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
Text
SalesforceStandardObjectName
documentDataFieldName :: Text
name :: SalesforceStandardObjectName
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:documentDataFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> Text
$sel:name:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> SalesforceStandardObjectName
$sel:fieldMappings:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectConfiguration' :: SalesforceStandardObjectConfiguration -> 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..= SalesforceStandardObjectName
name),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"DocumentDataFieldName"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
documentDataFieldName
              )
          ]
      )