{-# 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.DocumentAttributeValue
-- 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.DocumentAttributeValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The value of a document attribute. You can only provide one value for a
-- document attribute.
--
-- /See:/ 'newDocumentAttributeValue' smart constructor.
data DocumentAttributeValue = DocumentAttributeValue'
  { -- | A date expressed as an ISO 8601 string.
    --
    -- It is important for the time zone to be included in the ISO 8601
    -- date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601
    -- date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in
    -- Central European Time.
    DocumentAttributeValue -> Maybe POSIX
dateValue :: Prelude.Maybe Data.POSIX,
    -- | A long integer value.
    DocumentAttributeValue -> Maybe Integer
longValue :: Prelude.Maybe Prelude.Integer,
    -- | A list of strings. The default maximum length or number of strings is
    -- 10.
    DocumentAttributeValue -> Maybe [Text]
stringListValue :: Prelude.Maybe [Prelude.Text],
    -- | A string, such as \"department\".
    DocumentAttributeValue -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text
  }
  deriving (DocumentAttributeValue -> DocumentAttributeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentAttributeValue -> DocumentAttributeValue -> Bool
$c/= :: DocumentAttributeValue -> DocumentAttributeValue -> Bool
== :: DocumentAttributeValue -> DocumentAttributeValue -> Bool
$c== :: DocumentAttributeValue -> DocumentAttributeValue -> Bool
Prelude.Eq, ReadPrec [DocumentAttributeValue]
ReadPrec DocumentAttributeValue
Int -> ReadS DocumentAttributeValue
ReadS [DocumentAttributeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentAttributeValue]
$creadListPrec :: ReadPrec [DocumentAttributeValue]
readPrec :: ReadPrec DocumentAttributeValue
$creadPrec :: ReadPrec DocumentAttributeValue
readList :: ReadS [DocumentAttributeValue]
$creadList :: ReadS [DocumentAttributeValue]
readsPrec :: Int -> ReadS DocumentAttributeValue
$creadsPrec :: Int -> ReadS DocumentAttributeValue
Prelude.Read, Int -> DocumentAttributeValue -> ShowS
[DocumentAttributeValue] -> ShowS
DocumentAttributeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentAttributeValue] -> ShowS
$cshowList :: [DocumentAttributeValue] -> ShowS
show :: DocumentAttributeValue -> String
$cshow :: DocumentAttributeValue -> String
showsPrec :: Int -> DocumentAttributeValue -> ShowS
$cshowsPrec :: Int -> DocumentAttributeValue -> ShowS
Prelude.Show, forall x. Rep DocumentAttributeValue x -> DocumentAttributeValue
forall x. DocumentAttributeValue -> Rep DocumentAttributeValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentAttributeValue x -> DocumentAttributeValue
$cfrom :: forall x. DocumentAttributeValue -> Rep DocumentAttributeValue x
Prelude.Generic)

-- |
-- Create a value of 'DocumentAttributeValue' 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:
--
-- 'dateValue', 'documentAttributeValue_dateValue' - A date expressed as an ISO 8601 string.
--
-- It is important for the time zone to be included in the ISO 8601
-- date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601
-- date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in
-- Central European Time.
--
-- 'longValue', 'documentAttributeValue_longValue' - A long integer value.
--
-- 'stringListValue', 'documentAttributeValue_stringListValue' - A list of strings. The default maximum length or number of strings is
-- 10.
--
-- 'stringValue', 'documentAttributeValue_stringValue' - A string, such as \"department\".
newDocumentAttributeValue ::
  DocumentAttributeValue
newDocumentAttributeValue :: DocumentAttributeValue
newDocumentAttributeValue =
  DocumentAttributeValue'
    { $sel:dateValue:DocumentAttributeValue' :: Maybe POSIX
dateValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:longValue:DocumentAttributeValue' :: Maybe Integer
longValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringListValue:DocumentAttributeValue' :: Maybe [Text]
stringListValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:DocumentAttributeValue' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing
    }

-- | A date expressed as an ISO 8601 string.
--
-- It is important for the time zone to be included in the ISO 8601
-- date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601
-- date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in
-- Central European Time.
documentAttributeValue_dateValue :: Lens.Lens' DocumentAttributeValue (Prelude.Maybe Prelude.UTCTime)
documentAttributeValue_dateValue :: Lens' DocumentAttributeValue (Maybe UTCTime)
documentAttributeValue_dateValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValue' {Maybe POSIX
dateValue :: Maybe POSIX
$sel:dateValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe POSIX
dateValue} -> Maybe POSIX
dateValue) (\s :: DocumentAttributeValue
s@DocumentAttributeValue' {} Maybe POSIX
a -> DocumentAttributeValue
s {$sel:dateValue:DocumentAttributeValue' :: Maybe POSIX
dateValue = Maybe POSIX
a} :: DocumentAttributeValue) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A long integer value.
documentAttributeValue_longValue :: Lens.Lens' DocumentAttributeValue (Prelude.Maybe Prelude.Integer)
documentAttributeValue_longValue :: Lens' DocumentAttributeValue (Maybe Integer)
documentAttributeValue_longValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValue' {Maybe Integer
longValue :: Maybe Integer
$sel:longValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Integer
longValue} -> Maybe Integer
longValue) (\s :: DocumentAttributeValue
s@DocumentAttributeValue' {} Maybe Integer
a -> DocumentAttributeValue
s {$sel:longValue:DocumentAttributeValue' :: Maybe Integer
longValue = Maybe Integer
a} :: DocumentAttributeValue)

-- | A list of strings. The default maximum length or number of strings is
-- 10.
documentAttributeValue_stringListValue :: Lens.Lens' DocumentAttributeValue (Prelude.Maybe [Prelude.Text])
documentAttributeValue_stringListValue :: Lens' DocumentAttributeValue (Maybe [Text])
documentAttributeValue_stringListValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValue' {Maybe [Text]
stringListValue :: Maybe [Text]
$sel:stringListValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe [Text]
stringListValue} -> Maybe [Text]
stringListValue) (\s :: DocumentAttributeValue
s@DocumentAttributeValue' {} Maybe [Text]
a -> DocumentAttributeValue
s {$sel:stringListValue:DocumentAttributeValue' :: Maybe [Text]
stringListValue = Maybe [Text]
a} :: DocumentAttributeValue) 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

-- | A string, such as \"department\".
documentAttributeValue_stringValue :: Lens.Lens' DocumentAttributeValue (Prelude.Maybe Prelude.Text)
documentAttributeValue_stringValue :: Lens' DocumentAttributeValue (Maybe Text)
documentAttributeValue_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValue' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: DocumentAttributeValue
s@DocumentAttributeValue' {} Maybe Text
a -> DocumentAttributeValue
s {$sel:stringValue:DocumentAttributeValue' :: Maybe Text
stringValue = Maybe Text
a} :: DocumentAttributeValue)

instance Data.FromJSON DocumentAttributeValue where
  parseJSON :: Value -> Parser DocumentAttributeValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentAttributeValue"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Integer
-> Maybe [Text]
-> Maybe Text
-> DocumentAttributeValue
DocumentAttributeValue'
            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
"DateValue")
            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
"LongValue")
            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
"StringListValue"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"StringValue")
      )

instance Prelude.Hashable DocumentAttributeValue where
  hashWithSalt :: Int -> DocumentAttributeValue -> Int
hashWithSalt Int
_salt DocumentAttributeValue' {Maybe Integer
Maybe [Text]
Maybe Text
Maybe POSIX
stringValue :: Maybe Text
stringListValue :: Maybe [Text]
longValue :: Maybe Integer
dateValue :: Maybe POSIX
$sel:stringValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Text
$sel:stringListValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe [Text]
$sel:longValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Integer
$sel:dateValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
dateValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
longValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
stringListValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue

instance Prelude.NFData DocumentAttributeValue where
  rnf :: DocumentAttributeValue -> ()
rnf DocumentAttributeValue' {Maybe Integer
Maybe [Text]
Maybe Text
Maybe POSIX
stringValue :: Maybe Text
stringListValue :: Maybe [Text]
longValue :: Maybe Integer
dateValue :: Maybe POSIX
$sel:stringValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Text
$sel:stringListValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe [Text]
$sel:longValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Integer
$sel:dateValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
dateValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
longValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
stringListValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue

instance Data.ToJSON DocumentAttributeValue where
  toJSON :: DocumentAttributeValue -> Value
toJSON DocumentAttributeValue' {Maybe Integer
Maybe [Text]
Maybe Text
Maybe POSIX
stringValue :: Maybe Text
stringListValue :: Maybe [Text]
longValue :: Maybe Integer
dateValue :: Maybe POSIX
$sel:stringValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Text
$sel:stringListValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe [Text]
$sel:longValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe Integer
$sel:dateValue:DocumentAttributeValue' :: DocumentAttributeValue -> Maybe POSIX
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DateValue" 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 POSIX
dateValue,
            (Key
"LongValue" 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 Integer
longValue,
            (Key
"StringListValue" 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]
stringListValue,
            (Key
"StringValue" 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
stringValue
          ]
      )