{-# 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.ConfluenceAttachmentToIndexFieldMapping
-- 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.ConfluenceAttachmentToIndexFieldMapping 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.ConfluenceAttachmentFieldName
import qualified Amazonka.Prelude as Prelude

-- | Maps attributes or field names of Confluence attachments to Amazon
-- Kendra index field names. To create custom fields, use the @UpdateIndex@
-- API before you map to Confluence fields. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
-- The Confuence data source field names must exist in your Confluence
-- custom metadata.
--
-- /See:/ 'newConfluenceAttachmentToIndexFieldMapping' smart constructor.
data ConfluenceAttachmentToIndexFieldMapping = ConfluenceAttachmentToIndexFieldMapping'
  { -- | The name of the field in the data source.
    --
    -- You must first create the index field using the @UpdateIndex@ API.
    ConfluenceAttachmentToIndexFieldMapping
-> Maybe ConfluenceAttachmentFieldName
dataSourceFieldName :: Prelude.Maybe ConfluenceAttachmentFieldName,
    -- | The format for date fields in the data source. If the field specified in
    -- @DataSourceFieldName@ is a date field you must specify the date format.
    -- If the field is not a date field, an exception is thrown.
    ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
dateFieldFormat :: Prelude.Maybe Prelude.Text,
    -- | The name of the index field to map to the Confluence data source field.
    -- The index field type must match the Confluence field type.
    ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
indexFieldName :: Prelude.Maybe Prelude.Text
  }
  deriving (ConfluenceAttachmentToIndexFieldMapping
-> ConfluenceAttachmentToIndexFieldMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfluenceAttachmentToIndexFieldMapping
-> ConfluenceAttachmentToIndexFieldMapping -> Bool
$c/= :: ConfluenceAttachmentToIndexFieldMapping
-> ConfluenceAttachmentToIndexFieldMapping -> Bool
== :: ConfluenceAttachmentToIndexFieldMapping
-> ConfluenceAttachmentToIndexFieldMapping -> Bool
$c== :: ConfluenceAttachmentToIndexFieldMapping
-> ConfluenceAttachmentToIndexFieldMapping -> Bool
Prelude.Eq, ReadPrec [ConfluenceAttachmentToIndexFieldMapping]
ReadPrec ConfluenceAttachmentToIndexFieldMapping
Int -> ReadS ConfluenceAttachmentToIndexFieldMapping
ReadS [ConfluenceAttachmentToIndexFieldMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfluenceAttachmentToIndexFieldMapping]
$creadListPrec :: ReadPrec [ConfluenceAttachmentToIndexFieldMapping]
readPrec :: ReadPrec ConfluenceAttachmentToIndexFieldMapping
$creadPrec :: ReadPrec ConfluenceAttachmentToIndexFieldMapping
readList :: ReadS [ConfluenceAttachmentToIndexFieldMapping]
$creadList :: ReadS [ConfluenceAttachmentToIndexFieldMapping]
readsPrec :: Int -> ReadS ConfluenceAttachmentToIndexFieldMapping
$creadsPrec :: Int -> ReadS ConfluenceAttachmentToIndexFieldMapping
Prelude.Read, Int -> ConfluenceAttachmentToIndexFieldMapping -> ShowS
[ConfluenceAttachmentToIndexFieldMapping] -> ShowS
ConfluenceAttachmentToIndexFieldMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfluenceAttachmentToIndexFieldMapping] -> ShowS
$cshowList :: [ConfluenceAttachmentToIndexFieldMapping] -> ShowS
show :: ConfluenceAttachmentToIndexFieldMapping -> String
$cshow :: ConfluenceAttachmentToIndexFieldMapping -> String
showsPrec :: Int -> ConfluenceAttachmentToIndexFieldMapping -> ShowS
$cshowsPrec :: Int -> ConfluenceAttachmentToIndexFieldMapping -> ShowS
Prelude.Show, forall x.
Rep ConfluenceAttachmentToIndexFieldMapping x
-> ConfluenceAttachmentToIndexFieldMapping
forall x.
ConfluenceAttachmentToIndexFieldMapping
-> Rep ConfluenceAttachmentToIndexFieldMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfluenceAttachmentToIndexFieldMapping x
-> ConfluenceAttachmentToIndexFieldMapping
$cfrom :: forall x.
ConfluenceAttachmentToIndexFieldMapping
-> Rep ConfluenceAttachmentToIndexFieldMapping x
Prelude.Generic)

-- |
-- Create a value of 'ConfluenceAttachmentToIndexFieldMapping' 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:
--
-- 'dataSourceFieldName', 'confluenceAttachmentToIndexFieldMapping_dataSourceFieldName' - The name of the field in the data source.
--
-- You must first create the index field using the @UpdateIndex@ API.
--
-- 'dateFieldFormat', 'confluenceAttachmentToIndexFieldMapping_dateFieldFormat' - The format for date fields in the data source. If the field specified in
-- @DataSourceFieldName@ is a date field you must specify the date format.
-- If the field is not a date field, an exception is thrown.
--
-- 'indexFieldName', 'confluenceAttachmentToIndexFieldMapping_indexFieldName' - The name of the index field to map to the Confluence data source field.
-- The index field type must match the Confluence field type.
newConfluenceAttachmentToIndexFieldMapping ::
  ConfluenceAttachmentToIndexFieldMapping
newConfluenceAttachmentToIndexFieldMapping :: ConfluenceAttachmentToIndexFieldMapping
newConfluenceAttachmentToIndexFieldMapping =
  ConfluenceAttachmentToIndexFieldMapping'
    { $sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: Maybe ConfluenceAttachmentFieldName
dataSourceFieldName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: Maybe Text
dateFieldFormat = forall a. Maybe a
Prelude.Nothing,
      $sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: Maybe Text
indexFieldName = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the field in the data source.
--
-- You must first create the index field using the @UpdateIndex@ API.
confluenceAttachmentToIndexFieldMapping_dataSourceFieldName :: Lens.Lens' ConfluenceAttachmentToIndexFieldMapping (Prelude.Maybe ConfluenceAttachmentFieldName)
confluenceAttachmentToIndexFieldMapping_dataSourceFieldName :: Lens'
  ConfluenceAttachmentToIndexFieldMapping
  (Maybe ConfluenceAttachmentFieldName)
confluenceAttachmentToIndexFieldMapping_dataSourceFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceAttachmentToIndexFieldMapping' {Maybe ConfluenceAttachmentFieldName
dataSourceFieldName :: Maybe ConfluenceAttachmentFieldName
$sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping
-> Maybe ConfluenceAttachmentFieldName
dataSourceFieldName} -> Maybe ConfluenceAttachmentFieldName
dataSourceFieldName) (\s :: ConfluenceAttachmentToIndexFieldMapping
s@ConfluenceAttachmentToIndexFieldMapping' {} Maybe ConfluenceAttachmentFieldName
a -> ConfluenceAttachmentToIndexFieldMapping
s {$sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: Maybe ConfluenceAttachmentFieldName
dataSourceFieldName = Maybe ConfluenceAttachmentFieldName
a} :: ConfluenceAttachmentToIndexFieldMapping)

-- | The format for date fields in the data source. If the field specified in
-- @DataSourceFieldName@ is a date field you must specify the date format.
-- If the field is not a date field, an exception is thrown.
confluenceAttachmentToIndexFieldMapping_dateFieldFormat :: Lens.Lens' ConfluenceAttachmentToIndexFieldMapping (Prelude.Maybe Prelude.Text)
confluenceAttachmentToIndexFieldMapping_dateFieldFormat :: Lens' ConfluenceAttachmentToIndexFieldMapping (Maybe Text)
confluenceAttachmentToIndexFieldMapping_dateFieldFormat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceAttachmentToIndexFieldMapping' {Maybe Text
dateFieldFormat :: Maybe Text
$sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
dateFieldFormat} -> Maybe Text
dateFieldFormat) (\s :: ConfluenceAttachmentToIndexFieldMapping
s@ConfluenceAttachmentToIndexFieldMapping' {} Maybe Text
a -> ConfluenceAttachmentToIndexFieldMapping
s {$sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: Maybe Text
dateFieldFormat = Maybe Text
a} :: ConfluenceAttachmentToIndexFieldMapping)

-- | The name of the index field to map to the Confluence data source field.
-- The index field type must match the Confluence field type.
confluenceAttachmentToIndexFieldMapping_indexFieldName :: Lens.Lens' ConfluenceAttachmentToIndexFieldMapping (Prelude.Maybe Prelude.Text)
confluenceAttachmentToIndexFieldMapping_indexFieldName :: Lens' ConfluenceAttachmentToIndexFieldMapping (Maybe Text)
confluenceAttachmentToIndexFieldMapping_indexFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceAttachmentToIndexFieldMapping' {Maybe Text
indexFieldName :: Maybe Text
$sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
indexFieldName} -> Maybe Text
indexFieldName) (\s :: ConfluenceAttachmentToIndexFieldMapping
s@ConfluenceAttachmentToIndexFieldMapping' {} Maybe Text
a -> ConfluenceAttachmentToIndexFieldMapping
s {$sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: Maybe Text
indexFieldName = Maybe Text
a} :: ConfluenceAttachmentToIndexFieldMapping)

instance
  Data.FromJSON
    ConfluenceAttachmentToIndexFieldMapping
  where
  parseJSON :: Value -> Parser ConfluenceAttachmentToIndexFieldMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfluenceAttachmentToIndexFieldMapping"
      ( \Object
x ->
          Maybe ConfluenceAttachmentFieldName
-> Maybe Text
-> Maybe Text
-> ConfluenceAttachmentToIndexFieldMapping
ConfluenceAttachmentToIndexFieldMapping'
            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
"DataSourceFieldName")
            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
"DateFieldFormat")
            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
"IndexFieldName")
      )

instance
  Prelude.Hashable
    ConfluenceAttachmentToIndexFieldMapping
  where
  hashWithSalt :: Int -> ConfluenceAttachmentToIndexFieldMapping -> Int
hashWithSalt
    Int
_salt
    ConfluenceAttachmentToIndexFieldMapping' {Maybe Text
Maybe ConfluenceAttachmentFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceAttachmentFieldName
$sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping
-> Maybe ConfluenceAttachmentFieldName
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConfluenceAttachmentFieldName
dataSourceFieldName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dateFieldFormat
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
indexFieldName

instance
  Prelude.NFData
    ConfluenceAttachmentToIndexFieldMapping
  where
  rnf :: ConfluenceAttachmentToIndexFieldMapping -> ()
rnf ConfluenceAttachmentToIndexFieldMapping' {Maybe Text
Maybe ConfluenceAttachmentFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceAttachmentFieldName
$sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping
-> Maybe ConfluenceAttachmentFieldName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConfluenceAttachmentFieldName
dataSourceFieldName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dateFieldFormat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
indexFieldName

instance
  Data.ToJSON
    ConfluenceAttachmentToIndexFieldMapping
  where
  toJSON :: ConfluenceAttachmentToIndexFieldMapping -> Value
toJSON ConfluenceAttachmentToIndexFieldMapping' {Maybe Text
Maybe ConfluenceAttachmentFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceAttachmentFieldName
$sel:indexFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceAttachmentToIndexFieldMapping' :: ConfluenceAttachmentToIndexFieldMapping
-> Maybe ConfluenceAttachmentFieldName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DataSourceFieldName" 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 ConfluenceAttachmentFieldName
dataSourceFieldName,
            (Key
"DateFieldFormat" 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
dateFieldFormat,
            (Key
"IndexFieldName" 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
indexFieldName
          ]
      )