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

-- | >Maps attributes or field names of Confluence spaces 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 Confluence data source field names must exist in your Confluence
-- custom metadata.
--
-- /See:/ 'newConfluenceSpaceToIndexFieldMapping' smart constructor.
data ConfluenceSpaceToIndexFieldMapping = ConfluenceSpaceToIndexFieldMapping'
  { -- | The name of the field in the data source.
    ConfluenceSpaceToIndexFieldMapping
-> Maybe ConfluenceSpaceFieldName
dataSourceFieldName :: Prelude.Maybe ConfluenceSpaceFieldName,
    -- | 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.
    ConfluenceSpaceToIndexFieldMapping -> 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.
    ConfluenceSpaceToIndexFieldMapping -> Maybe Text
indexFieldName :: Prelude.Maybe Prelude.Text
  }
  deriving (ConfluenceSpaceToIndexFieldMapping
-> ConfluenceSpaceToIndexFieldMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfluenceSpaceToIndexFieldMapping
-> ConfluenceSpaceToIndexFieldMapping -> Bool
$c/= :: ConfluenceSpaceToIndexFieldMapping
-> ConfluenceSpaceToIndexFieldMapping -> Bool
== :: ConfluenceSpaceToIndexFieldMapping
-> ConfluenceSpaceToIndexFieldMapping -> Bool
$c== :: ConfluenceSpaceToIndexFieldMapping
-> ConfluenceSpaceToIndexFieldMapping -> Bool
Prelude.Eq, ReadPrec [ConfluenceSpaceToIndexFieldMapping]
ReadPrec ConfluenceSpaceToIndexFieldMapping
Int -> ReadS ConfluenceSpaceToIndexFieldMapping
ReadS [ConfluenceSpaceToIndexFieldMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfluenceSpaceToIndexFieldMapping]
$creadListPrec :: ReadPrec [ConfluenceSpaceToIndexFieldMapping]
readPrec :: ReadPrec ConfluenceSpaceToIndexFieldMapping
$creadPrec :: ReadPrec ConfluenceSpaceToIndexFieldMapping
readList :: ReadS [ConfluenceSpaceToIndexFieldMapping]
$creadList :: ReadS [ConfluenceSpaceToIndexFieldMapping]
readsPrec :: Int -> ReadS ConfluenceSpaceToIndexFieldMapping
$creadsPrec :: Int -> ReadS ConfluenceSpaceToIndexFieldMapping
Prelude.Read, Int -> ConfluenceSpaceToIndexFieldMapping -> ShowS
[ConfluenceSpaceToIndexFieldMapping] -> ShowS
ConfluenceSpaceToIndexFieldMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfluenceSpaceToIndexFieldMapping] -> ShowS
$cshowList :: [ConfluenceSpaceToIndexFieldMapping] -> ShowS
show :: ConfluenceSpaceToIndexFieldMapping -> String
$cshow :: ConfluenceSpaceToIndexFieldMapping -> String
showsPrec :: Int -> ConfluenceSpaceToIndexFieldMapping -> ShowS
$cshowsPrec :: Int -> ConfluenceSpaceToIndexFieldMapping -> ShowS
Prelude.Show, forall x.
Rep ConfluenceSpaceToIndexFieldMapping x
-> ConfluenceSpaceToIndexFieldMapping
forall x.
ConfluenceSpaceToIndexFieldMapping
-> Rep ConfluenceSpaceToIndexFieldMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfluenceSpaceToIndexFieldMapping x
-> ConfluenceSpaceToIndexFieldMapping
$cfrom :: forall x.
ConfluenceSpaceToIndexFieldMapping
-> Rep ConfluenceSpaceToIndexFieldMapping x
Prelude.Generic)

-- |
-- Create a value of 'ConfluenceSpaceToIndexFieldMapping' 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', 'confluenceSpaceToIndexFieldMapping_dataSourceFieldName' - The name of the field in the data source.
--
-- 'dateFieldFormat', 'confluenceSpaceToIndexFieldMapping_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', 'confluenceSpaceToIndexFieldMapping_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.
newConfluenceSpaceToIndexFieldMapping ::
  ConfluenceSpaceToIndexFieldMapping
newConfluenceSpaceToIndexFieldMapping :: ConfluenceSpaceToIndexFieldMapping
newConfluenceSpaceToIndexFieldMapping =
  ConfluenceSpaceToIndexFieldMapping'
    { $sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: Maybe ConfluenceSpaceFieldName
dataSourceFieldName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: Maybe Text
dateFieldFormat = forall a. Maybe a
Prelude.Nothing,
      $sel:indexFieldName:ConfluenceSpaceToIndexFieldMapping' :: Maybe Text
indexFieldName = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the field in the data source.
confluenceSpaceToIndexFieldMapping_dataSourceFieldName :: Lens.Lens' ConfluenceSpaceToIndexFieldMapping (Prelude.Maybe ConfluenceSpaceFieldName)
confluenceSpaceToIndexFieldMapping_dataSourceFieldName :: Lens'
  ConfluenceSpaceToIndexFieldMapping (Maybe ConfluenceSpaceFieldName)
confluenceSpaceToIndexFieldMapping_dataSourceFieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceSpaceToIndexFieldMapping' {Maybe ConfluenceSpaceFieldName
dataSourceFieldName :: Maybe ConfluenceSpaceFieldName
$sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping
-> Maybe ConfluenceSpaceFieldName
dataSourceFieldName} -> Maybe ConfluenceSpaceFieldName
dataSourceFieldName) (\s :: ConfluenceSpaceToIndexFieldMapping
s@ConfluenceSpaceToIndexFieldMapping' {} Maybe ConfluenceSpaceFieldName
a -> ConfluenceSpaceToIndexFieldMapping
s {$sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: Maybe ConfluenceSpaceFieldName
dataSourceFieldName = Maybe ConfluenceSpaceFieldName
a} :: ConfluenceSpaceToIndexFieldMapping)

-- | 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.
confluenceSpaceToIndexFieldMapping_dateFieldFormat :: Lens.Lens' ConfluenceSpaceToIndexFieldMapping (Prelude.Maybe Prelude.Text)
confluenceSpaceToIndexFieldMapping_dateFieldFormat :: Lens' ConfluenceSpaceToIndexFieldMapping (Maybe Text)
confluenceSpaceToIndexFieldMapping_dateFieldFormat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceSpaceToIndexFieldMapping' {Maybe Text
dateFieldFormat :: Maybe Text
$sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
dateFieldFormat} -> Maybe Text
dateFieldFormat) (\s :: ConfluenceSpaceToIndexFieldMapping
s@ConfluenceSpaceToIndexFieldMapping' {} Maybe Text
a -> ConfluenceSpaceToIndexFieldMapping
s {$sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: Maybe Text
dateFieldFormat = Maybe Text
a} :: ConfluenceSpaceToIndexFieldMapping)

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

instance
  Data.FromJSON
    ConfluenceSpaceToIndexFieldMapping
  where
  parseJSON :: Value -> Parser ConfluenceSpaceToIndexFieldMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfluenceSpaceToIndexFieldMapping"
      ( \Object
x ->
          Maybe ConfluenceSpaceFieldName
-> Maybe Text -> Maybe Text -> ConfluenceSpaceToIndexFieldMapping
ConfluenceSpaceToIndexFieldMapping'
            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
    ConfluenceSpaceToIndexFieldMapping
  where
  hashWithSalt :: Int -> ConfluenceSpaceToIndexFieldMapping -> Int
hashWithSalt
    Int
_salt
    ConfluenceSpaceToIndexFieldMapping' {Maybe Text
Maybe ConfluenceSpaceFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceSpaceFieldName
$sel:indexFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping
-> Maybe ConfluenceSpaceFieldName
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConfluenceSpaceFieldName
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
    ConfluenceSpaceToIndexFieldMapping
  where
  rnf :: ConfluenceSpaceToIndexFieldMapping -> ()
rnf ConfluenceSpaceToIndexFieldMapping' {Maybe Text
Maybe ConfluenceSpaceFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceSpaceFieldName
$sel:indexFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping
-> Maybe ConfluenceSpaceFieldName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConfluenceSpaceFieldName
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
    ConfluenceSpaceToIndexFieldMapping
  where
  toJSON :: ConfluenceSpaceToIndexFieldMapping -> Value
toJSON ConfluenceSpaceToIndexFieldMapping' {Maybe Text
Maybe ConfluenceSpaceFieldName
indexFieldName :: Maybe Text
dateFieldFormat :: Maybe Text
dataSourceFieldName :: Maybe ConfluenceSpaceFieldName
$sel:indexFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dateFieldFormat:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping -> Maybe Text
$sel:dataSourceFieldName:ConfluenceSpaceToIndexFieldMapping' :: ConfluenceSpaceToIndexFieldMapping
-> Maybe ConfluenceSpaceFieldName
..} =
    [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 ConfluenceSpaceFieldName
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
          ]
      )