{-# 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.SalesforceStandardObjectAttachmentConfiguration
-- 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.SalesforceStandardObjectAttachmentConfiguration 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 processing attachments to
-- Salesforce standard objects.
--
-- /See:/ 'newSalesforceStandardObjectAttachmentConfiguration' smart constructor.
data SalesforceStandardObjectAttachmentConfiguration = SalesforceStandardObjectAttachmentConfiguration'
  { -- | The name of the field used for the document title.
    SalesforceStandardObjectAttachmentConfiguration -> Maybe Text
documentTitleFieldName :: Prelude.Maybe Prelude.Text,
    -- | One or more objects that map fields in attachments to Amazon Kendra
    -- index fields.
    SalesforceStandardObjectAttachmentConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping)
  }
  deriving (SalesforceStandardObjectAttachmentConfiguration
-> SalesforceStandardObjectAttachmentConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SalesforceStandardObjectAttachmentConfiguration
-> SalesforceStandardObjectAttachmentConfiguration -> Bool
$c/= :: SalesforceStandardObjectAttachmentConfiguration
-> SalesforceStandardObjectAttachmentConfiguration -> Bool
== :: SalesforceStandardObjectAttachmentConfiguration
-> SalesforceStandardObjectAttachmentConfiguration -> Bool
$c== :: SalesforceStandardObjectAttachmentConfiguration
-> SalesforceStandardObjectAttachmentConfiguration -> Bool
Prelude.Eq, ReadPrec [SalesforceStandardObjectAttachmentConfiguration]
ReadPrec SalesforceStandardObjectAttachmentConfiguration
Int -> ReadS SalesforceStandardObjectAttachmentConfiguration
ReadS [SalesforceStandardObjectAttachmentConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SalesforceStandardObjectAttachmentConfiguration]
$creadListPrec :: ReadPrec [SalesforceStandardObjectAttachmentConfiguration]
readPrec :: ReadPrec SalesforceStandardObjectAttachmentConfiguration
$creadPrec :: ReadPrec SalesforceStandardObjectAttachmentConfiguration
readList :: ReadS [SalesforceStandardObjectAttachmentConfiguration]
$creadList :: ReadS [SalesforceStandardObjectAttachmentConfiguration]
readsPrec :: Int -> ReadS SalesforceStandardObjectAttachmentConfiguration
$creadsPrec :: Int -> ReadS SalesforceStandardObjectAttachmentConfiguration
Prelude.Read, Int -> SalesforceStandardObjectAttachmentConfiguration -> ShowS
[SalesforceStandardObjectAttachmentConfiguration] -> ShowS
SalesforceStandardObjectAttachmentConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SalesforceStandardObjectAttachmentConfiguration] -> ShowS
$cshowList :: [SalesforceStandardObjectAttachmentConfiguration] -> ShowS
show :: SalesforceStandardObjectAttachmentConfiguration -> String
$cshow :: SalesforceStandardObjectAttachmentConfiguration -> String
showsPrec :: Int -> SalesforceStandardObjectAttachmentConfiguration -> ShowS
$cshowsPrec :: Int -> SalesforceStandardObjectAttachmentConfiguration -> ShowS
Prelude.Show, forall x.
Rep SalesforceStandardObjectAttachmentConfiguration x
-> SalesforceStandardObjectAttachmentConfiguration
forall x.
SalesforceStandardObjectAttachmentConfiguration
-> Rep SalesforceStandardObjectAttachmentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SalesforceStandardObjectAttachmentConfiguration x
-> SalesforceStandardObjectAttachmentConfiguration
$cfrom :: forall x.
SalesforceStandardObjectAttachmentConfiguration
-> Rep SalesforceStandardObjectAttachmentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SalesforceStandardObjectAttachmentConfiguration' 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', 'salesforceStandardObjectAttachmentConfiguration_documentTitleFieldName' - The name of the field used for the document title.
--
-- 'fieldMappings', 'salesforceStandardObjectAttachmentConfiguration_fieldMappings' - One or more objects that map fields in attachments to Amazon Kendra
-- index fields.
newSalesforceStandardObjectAttachmentConfiguration ::
  SalesforceStandardObjectAttachmentConfiguration
newSalesforceStandardObjectAttachmentConfiguration :: SalesforceStandardObjectAttachmentConfiguration
newSalesforceStandardObjectAttachmentConfiguration =
  SalesforceStandardObjectAttachmentConfiguration'
    { $sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: Maybe Text
documentTitleFieldName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the field used for the document title.
salesforceStandardObjectAttachmentConfiguration_documentTitleFieldName :: Lens.Lens' SalesforceStandardObjectAttachmentConfiguration (Prelude.Maybe Prelude.Text)
salesforceStandardObjectAttachmentConfiguration_documentTitleFieldName :: Lens' SalesforceStandardObjectAttachmentConfiguration (Maybe Text)
salesforceStandardObjectAttachmentConfiguration_documentTitleFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectAttachmentConfiguration' {Maybe Text
documentTitleFieldName :: Maybe Text
$sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration -> Maybe Text
documentTitleFieldName} -> Maybe Text
documentTitleFieldName) (\s :: SalesforceStandardObjectAttachmentConfiguration
s@SalesforceStandardObjectAttachmentConfiguration' {} Maybe Text
a -> SalesforceStandardObjectAttachmentConfiguration
s {$sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: Maybe Text
documentTitleFieldName = Maybe Text
a} :: SalesforceStandardObjectAttachmentConfiguration)

-- | One or more objects that map fields in attachments to Amazon Kendra
-- index fields.
salesforceStandardObjectAttachmentConfiguration_fieldMappings :: Lens.Lens' SalesforceStandardObjectAttachmentConfiguration (Prelude.Maybe (Prelude.NonEmpty DataSourceToIndexFieldMapping))
salesforceStandardObjectAttachmentConfiguration_fieldMappings :: Lens'
  SalesforceStandardObjectAttachmentConfiguration
  (Maybe (NonEmpty DataSourceToIndexFieldMapping))
salesforceStandardObjectAttachmentConfiguration_fieldMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceStandardObjectAttachmentConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings} -> Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings) (\s :: SalesforceStandardObjectAttachmentConfiguration
s@SalesforceStandardObjectAttachmentConfiguration' {} Maybe (NonEmpty DataSourceToIndexFieldMapping)
a -> SalesforceStandardObjectAttachmentConfiguration
s {$sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
fieldMappings = Maybe (NonEmpty DataSourceToIndexFieldMapping)
a} :: SalesforceStandardObjectAttachmentConfiguration) 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

instance
  Data.FromJSON
    SalesforceStandardObjectAttachmentConfiguration
  where
  parseJSON :: Value -> Parser SalesforceStandardObjectAttachmentConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SalesforceStandardObjectAttachmentConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
-> SalesforceStandardObjectAttachmentConfiguration
SalesforceStandardObjectAttachmentConfiguration'
            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")
      )

instance
  Prelude.Hashable
    SalesforceStandardObjectAttachmentConfiguration
  where
  hashWithSalt :: Int -> SalesforceStandardObjectAttachmentConfiguration -> Int
hashWithSalt
    Int
_salt
    SalesforceStandardObjectAttachmentConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration -> 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

instance
  Prelude.NFData
    SalesforceStandardObjectAttachmentConfiguration
  where
  rnf :: SalesforceStandardObjectAttachmentConfiguration -> ()
rnf
    SalesforceStandardObjectAttachmentConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration -> 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

instance
  Data.ToJSON
    SalesforceStandardObjectAttachmentConfiguration
  where
  toJSON :: SalesforceStandardObjectAttachmentConfiguration -> Value
toJSON
    SalesforceStandardObjectAttachmentConfiguration' {Maybe (NonEmpty DataSourceToIndexFieldMapping)
Maybe Text
fieldMappings :: Maybe (NonEmpty DataSourceToIndexFieldMapping)
documentTitleFieldName :: Maybe Text
$sel:fieldMappings:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration
-> Maybe (NonEmpty DataSourceToIndexFieldMapping)
$sel:documentTitleFieldName:SalesforceStandardObjectAttachmentConfiguration' :: SalesforceStandardObjectAttachmentConfiguration -> 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
            ]
        )