{-# 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 #-}
module Amazonka.Kendra.Types.DocumentAttribute 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
data DocumentAttribute = DocumentAttribute'
{
DocumentAttribute -> Text
key :: Prelude.Text,
DocumentAttribute -> DocumentAttributeValue
value :: DocumentAttributeValue
}
deriving (DocumentAttribute -> DocumentAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentAttribute -> DocumentAttribute -> Bool
$c/= :: DocumentAttribute -> DocumentAttribute -> Bool
== :: DocumentAttribute -> DocumentAttribute -> Bool
$c== :: DocumentAttribute -> DocumentAttribute -> Bool
Prelude.Eq, ReadPrec [DocumentAttribute]
ReadPrec DocumentAttribute
Int -> ReadS DocumentAttribute
ReadS [DocumentAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentAttribute]
$creadListPrec :: ReadPrec [DocumentAttribute]
readPrec :: ReadPrec DocumentAttribute
$creadPrec :: ReadPrec DocumentAttribute
readList :: ReadS [DocumentAttribute]
$creadList :: ReadS [DocumentAttribute]
readsPrec :: Int -> ReadS DocumentAttribute
$creadsPrec :: Int -> ReadS DocumentAttribute
Prelude.Read, Int -> DocumentAttribute -> ShowS
[DocumentAttribute] -> ShowS
DocumentAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentAttribute] -> ShowS
$cshowList :: [DocumentAttribute] -> ShowS
show :: DocumentAttribute -> String
$cshow :: DocumentAttribute -> String
showsPrec :: Int -> DocumentAttribute -> ShowS
$cshowsPrec :: Int -> DocumentAttribute -> ShowS
Prelude.Show, forall x. Rep DocumentAttribute x -> DocumentAttribute
forall x. DocumentAttribute -> Rep DocumentAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentAttribute x -> DocumentAttribute
$cfrom :: forall x. DocumentAttribute -> Rep DocumentAttribute x
Prelude.Generic)
newDocumentAttribute ::
Prelude.Text ->
DocumentAttributeValue ->
DocumentAttribute
newDocumentAttribute :: Text -> DocumentAttributeValue -> DocumentAttribute
newDocumentAttribute Text
pKey_ DocumentAttributeValue
pValue_ =
DocumentAttribute' {$sel:key:DocumentAttribute' :: Text
key = Text
pKey_, $sel:value:DocumentAttribute' :: DocumentAttributeValue
value = DocumentAttributeValue
pValue_}
documentAttribute_key :: Lens.Lens' DocumentAttribute Prelude.Text
documentAttribute_key :: Lens' DocumentAttribute Text
documentAttribute_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttribute' {Text
key :: Text
$sel:key:DocumentAttribute' :: DocumentAttribute -> Text
key} -> Text
key) (\s :: DocumentAttribute
s@DocumentAttribute' {} Text
a -> DocumentAttribute
s {$sel:key:DocumentAttribute' :: Text
key = Text
a} :: DocumentAttribute)
documentAttribute_value :: Lens.Lens' DocumentAttribute DocumentAttributeValue
documentAttribute_value :: Lens' DocumentAttribute DocumentAttributeValue
documentAttribute_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttribute' {DocumentAttributeValue
value :: DocumentAttributeValue
$sel:value:DocumentAttribute' :: DocumentAttribute -> DocumentAttributeValue
value} -> DocumentAttributeValue
value) (\s :: DocumentAttribute
s@DocumentAttribute' {} DocumentAttributeValue
a -> DocumentAttribute
s {$sel:value:DocumentAttribute' :: DocumentAttributeValue
value = DocumentAttributeValue
a} :: DocumentAttribute)
instance Data.FromJSON DocumentAttribute where
parseJSON :: Value -> Parser DocumentAttribute
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"DocumentAttribute"
( \Object
x ->
Text -> DocumentAttributeValue -> DocumentAttribute
DocumentAttribute'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Key")
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
"Value")
)
instance Prelude.Hashable DocumentAttribute where
hashWithSalt :: Int -> DocumentAttribute -> Int
hashWithSalt Int
_salt DocumentAttribute' {Text
DocumentAttributeValue
value :: DocumentAttributeValue
key :: Text
$sel:value:DocumentAttribute' :: DocumentAttribute -> DocumentAttributeValue
$sel:key:DocumentAttribute' :: DocumentAttribute -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DocumentAttributeValue
value
instance Prelude.NFData DocumentAttribute where
rnf :: DocumentAttribute -> ()
rnf DocumentAttribute' {Text
DocumentAttributeValue
value :: DocumentAttributeValue
key :: Text
$sel:value:DocumentAttribute' :: DocumentAttribute -> DocumentAttributeValue
$sel:key:DocumentAttribute' :: DocumentAttribute -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DocumentAttributeValue
value
instance Data.ToJSON DocumentAttribute where
toJSON :: DocumentAttribute -> Value
toJSON DocumentAttribute' {Text
DocumentAttributeValue
value :: DocumentAttributeValue
key :: Text
$sel:value:DocumentAttribute' :: DocumentAttribute -> DocumentAttributeValue
$sel:key:DocumentAttribute' :: DocumentAttribute -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DocumentAttributeValue
value)
]
)