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

-- | The target document attribute or metadata field you want to alter when
-- ingesting documents into Amazon Kendra.
--
-- For example, you can delete customer identification numbers associated
-- with the documents, stored in the document metadata field called
-- \'Customer_ID\'. You set the target key as \'Customer_ID\' and the
-- deletion flag to @TRUE@. This removes all customer ID values in the
-- field \'Customer_ID\'. This would scrub personally identifiable
-- information from each document\'s metadata.
--
-- Amazon Kendra cannot create a target field if it has not already been
-- created as an index field. After you create your index field, you can
-- create a document metadata field using @DocumentAttributeTarget@. Amazon
-- Kendra then will map your newly created metadata field to your index
-- field.
--
-- You can also use this with
-- <https://docs.aws.amazon.com/kendra/latest/dg/API_DocumentAttributeCondition.html DocumentAttributeCondition>.
--
-- /See:/ 'newDocumentAttributeTarget' smart constructor.
data DocumentAttributeTarget = DocumentAttributeTarget'
  { -- | The identifier of the target document attribute or metadata field.
    --
    -- For example, \'Department\' could be an identifier for the target
    -- attribute or metadata field that includes the department names
    -- associated with the documents.
    DocumentAttributeTarget -> Maybe Text
targetDocumentAttributeKey :: Prelude.Maybe Prelude.Text,
    -- | The target value you want to create for the target attribute.
    --
    -- For example, \'Finance\' could be the target value for the target
    -- attribute key \'Department\'.
    DocumentAttributeTarget -> Maybe DocumentAttributeValue
targetDocumentAttributeValue :: Prelude.Maybe DocumentAttributeValue,
    -- | @TRUE@ to delete the existing target value for your specified target
    -- attribute key. You cannot create a target value and set this to @TRUE@.
    -- To create a target value (@TargetDocumentAttributeValue@), set this to
    -- @FALSE@.
    DocumentAttributeTarget -> Maybe Bool
targetDocumentAttributeValueDeletion :: Prelude.Maybe Prelude.Bool
  }
  deriving (DocumentAttributeTarget -> DocumentAttributeTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentAttributeTarget -> DocumentAttributeTarget -> Bool
$c/= :: DocumentAttributeTarget -> DocumentAttributeTarget -> Bool
== :: DocumentAttributeTarget -> DocumentAttributeTarget -> Bool
$c== :: DocumentAttributeTarget -> DocumentAttributeTarget -> Bool
Prelude.Eq, ReadPrec [DocumentAttributeTarget]
ReadPrec DocumentAttributeTarget
Int -> ReadS DocumentAttributeTarget
ReadS [DocumentAttributeTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentAttributeTarget]
$creadListPrec :: ReadPrec [DocumentAttributeTarget]
readPrec :: ReadPrec DocumentAttributeTarget
$creadPrec :: ReadPrec DocumentAttributeTarget
readList :: ReadS [DocumentAttributeTarget]
$creadList :: ReadS [DocumentAttributeTarget]
readsPrec :: Int -> ReadS DocumentAttributeTarget
$creadsPrec :: Int -> ReadS DocumentAttributeTarget
Prelude.Read, Int -> DocumentAttributeTarget -> ShowS
[DocumentAttributeTarget] -> ShowS
DocumentAttributeTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentAttributeTarget] -> ShowS
$cshowList :: [DocumentAttributeTarget] -> ShowS
show :: DocumentAttributeTarget -> String
$cshow :: DocumentAttributeTarget -> String
showsPrec :: Int -> DocumentAttributeTarget -> ShowS
$cshowsPrec :: Int -> DocumentAttributeTarget -> ShowS
Prelude.Show, forall x. Rep DocumentAttributeTarget x -> DocumentAttributeTarget
forall x. DocumentAttributeTarget -> Rep DocumentAttributeTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentAttributeTarget x -> DocumentAttributeTarget
$cfrom :: forall x. DocumentAttributeTarget -> Rep DocumentAttributeTarget x
Prelude.Generic)

-- |
-- Create a value of 'DocumentAttributeTarget' 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:
--
-- 'targetDocumentAttributeKey', 'documentAttributeTarget_targetDocumentAttributeKey' - The identifier of the target document attribute or metadata field.
--
-- For example, \'Department\' could be an identifier for the target
-- attribute or metadata field that includes the department names
-- associated with the documents.
--
-- 'targetDocumentAttributeValue', 'documentAttributeTarget_targetDocumentAttributeValue' - The target value you want to create for the target attribute.
--
-- For example, \'Finance\' could be the target value for the target
-- attribute key \'Department\'.
--
-- 'targetDocumentAttributeValueDeletion', 'documentAttributeTarget_targetDocumentAttributeValueDeletion' - @TRUE@ to delete the existing target value for your specified target
-- attribute key. You cannot create a target value and set this to @TRUE@.
-- To create a target value (@TargetDocumentAttributeValue@), set this to
-- @FALSE@.
newDocumentAttributeTarget ::
  DocumentAttributeTarget
newDocumentAttributeTarget :: DocumentAttributeTarget
newDocumentAttributeTarget =
  DocumentAttributeTarget'
    { $sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: Maybe Text
targetDocumentAttributeKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: Maybe DocumentAttributeValue
targetDocumentAttributeValue = forall a. Maybe a
Prelude.Nothing,
      $sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: Maybe Bool
targetDocumentAttributeValueDeletion =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the target document attribute or metadata field.
--
-- For example, \'Department\' could be an identifier for the target
-- attribute or metadata field that includes the department names
-- associated with the documents.
documentAttributeTarget_targetDocumentAttributeKey :: Lens.Lens' DocumentAttributeTarget (Prelude.Maybe Prelude.Text)
documentAttributeTarget_targetDocumentAttributeKey :: Lens' DocumentAttributeTarget (Maybe Text)
documentAttributeTarget_targetDocumentAttributeKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeTarget' {Maybe Text
targetDocumentAttributeKey :: Maybe Text
$sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Text
targetDocumentAttributeKey} -> Maybe Text
targetDocumentAttributeKey) (\s :: DocumentAttributeTarget
s@DocumentAttributeTarget' {} Maybe Text
a -> DocumentAttributeTarget
s {$sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: Maybe Text
targetDocumentAttributeKey = Maybe Text
a} :: DocumentAttributeTarget)

-- | The target value you want to create for the target attribute.
--
-- For example, \'Finance\' could be the target value for the target
-- attribute key \'Department\'.
documentAttributeTarget_targetDocumentAttributeValue :: Lens.Lens' DocumentAttributeTarget (Prelude.Maybe DocumentAttributeValue)
documentAttributeTarget_targetDocumentAttributeValue :: Lens' DocumentAttributeTarget (Maybe DocumentAttributeValue)
documentAttributeTarget_targetDocumentAttributeValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeTarget' {Maybe DocumentAttributeValue
targetDocumentAttributeValue :: Maybe DocumentAttributeValue
$sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe DocumentAttributeValue
targetDocumentAttributeValue} -> Maybe DocumentAttributeValue
targetDocumentAttributeValue) (\s :: DocumentAttributeTarget
s@DocumentAttributeTarget' {} Maybe DocumentAttributeValue
a -> DocumentAttributeTarget
s {$sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: Maybe DocumentAttributeValue
targetDocumentAttributeValue = Maybe DocumentAttributeValue
a} :: DocumentAttributeTarget)

-- | @TRUE@ to delete the existing target value for your specified target
-- attribute key. You cannot create a target value and set this to @TRUE@.
-- To create a target value (@TargetDocumentAttributeValue@), set this to
-- @FALSE@.
documentAttributeTarget_targetDocumentAttributeValueDeletion :: Lens.Lens' DocumentAttributeTarget (Prelude.Maybe Prelude.Bool)
documentAttributeTarget_targetDocumentAttributeValueDeletion :: Lens' DocumentAttributeTarget (Maybe Bool)
documentAttributeTarget_targetDocumentAttributeValueDeletion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeTarget' {Maybe Bool
targetDocumentAttributeValueDeletion :: Maybe Bool
$sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Bool
targetDocumentAttributeValueDeletion} -> Maybe Bool
targetDocumentAttributeValueDeletion) (\s :: DocumentAttributeTarget
s@DocumentAttributeTarget' {} Maybe Bool
a -> DocumentAttributeTarget
s {$sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: Maybe Bool
targetDocumentAttributeValueDeletion = Maybe Bool
a} :: DocumentAttributeTarget)

instance Data.FromJSON DocumentAttributeTarget where
  parseJSON :: Value -> Parser DocumentAttributeTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentAttributeTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe DocumentAttributeValue
-> Maybe Bool
-> DocumentAttributeTarget
DocumentAttributeTarget'
            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
"TargetDocumentAttributeKey")
            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
"TargetDocumentAttributeValue")
            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
"TargetDocumentAttributeValueDeletion")
      )

instance Prelude.Hashable DocumentAttributeTarget where
  hashWithSalt :: Int -> DocumentAttributeTarget -> Int
hashWithSalt Int
_salt DocumentAttributeTarget' {Maybe Bool
Maybe Text
Maybe DocumentAttributeValue
targetDocumentAttributeValueDeletion :: Maybe Bool
targetDocumentAttributeValue :: Maybe DocumentAttributeValue
targetDocumentAttributeKey :: Maybe Text
$sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Bool
$sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe DocumentAttributeValue
$sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetDocumentAttributeKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentAttributeValue
targetDocumentAttributeValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
targetDocumentAttributeValueDeletion

instance Prelude.NFData DocumentAttributeTarget where
  rnf :: DocumentAttributeTarget -> ()
rnf DocumentAttributeTarget' {Maybe Bool
Maybe Text
Maybe DocumentAttributeValue
targetDocumentAttributeValueDeletion :: Maybe Bool
targetDocumentAttributeValue :: Maybe DocumentAttributeValue
targetDocumentAttributeKey :: Maybe Text
$sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Bool
$sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe DocumentAttributeValue
$sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetDocumentAttributeKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentAttributeValue
targetDocumentAttributeValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
targetDocumentAttributeValueDeletion

instance Data.ToJSON DocumentAttributeTarget where
  toJSON :: DocumentAttributeTarget -> Value
toJSON DocumentAttributeTarget' {Maybe Bool
Maybe Text
Maybe DocumentAttributeValue
targetDocumentAttributeValueDeletion :: Maybe Bool
targetDocumentAttributeValue :: Maybe DocumentAttributeValue
targetDocumentAttributeKey :: Maybe Text
$sel:targetDocumentAttributeValueDeletion:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Bool
$sel:targetDocumentAttributeValue:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe DocumentAttributeValue
$sel:targetDocumentAttributeKey:DocumentAttributeTarget' :: DocumentAttributeTarget -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TargetDocumentAttributeKey" 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
targetDocumentAttributeKey,
            (Key
"TargetDocumentAttributeValue" 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 DocumentAttributeValue
targetDocumentAttributeValue,
            (Key
"TargetDocumentAttributeValueDeletion" 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 Bool
targetDocumentAttributeValueDeletion
          ]
      )