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

-- | Identifies a document for which to retrieve status information
--
-- /See:/ 'newDocumentInfo' smart constructor.
data DocumentInfo = DocumentInfo'
  { -- | Attributes that identify a specific version of a document to check.
    --
    -- The only valid attributes are:
    --
    -- -   version
    --
    -- -   datasourceId
    --
    -- -   jobExecutionId
    --
    -- The attributes follow these rules:
    --
    -- -   @dataSourceId@ and @jobExecutionId@ must be used together.
    --
    -- -   @version@ is ignored if @dataSourceId@ and @jobExecutionId@ are not
    --     provided.
    --
    -- -   If @dataSourceId@ and @jobExecutionId@ are provided, but @version@
    --     is not, the version defaults to \"0\".
    DocumentInfo -> Maybe [DocumentAttribute]
attributes :: Prelude.Maybe [DocumentAttribute],
    -- | The identifier of the document.
    DocumentInfo -> Text
documentId :: Prelude.Text
  }
  deriving (DocumentInfo -> DocumentInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentInfo -> DocumentInfo -> Bool
$c/= :: DocumentInfo -> DocumentInfo -> Bool
== :: DocumentInfo -> DocumentInfo -> Bool
$c== :: DocumentInfo -> DocumentInfo -> Bool
Prelude.Eq, ReadPrec [DocumentInfo]
ReadPrec DocumentInfo
Int -> ReadS DocumentInfo
ReadS [DocumentInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentInfo]
$creadListPrec :: ReadPrec [DocumentInfo]
readPrec :: ReadPrec DocumentInfo
$creadPrec :: ReadPrec DocumentInfo
readList :: ReadS [DocumentInfo]
$creadList :: ReadS [DocumentInfo]
readsPrec :: Int -> ReadS DocumentInfo
$creadsPrec :: Int -> ReadS DocumentInfo
Prelude.Read, Int -> DocumentInfo -> ShowS
[DocumentInfo] -> ShowS
DocumentInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentInfo] -> ShowS
$cshowList :: [DocumentInfo] -> ShowS
show :: DocumentInfo -> String
$cshow :: DocumentInfo -> String
showsPrec :: Int -> DocumentInfo -> ShowS
$cshowsPrec :: Int -> DocumentInfo -> ShowS
Prelude.Show, forall x. Rep DocumentInfo x -> DocumentInfo
forall x. DocumentInfo -> Rep DocumentInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentInfo x -> DocumentInfo
$cfrom :: forall x. DocumentInfo -> Rep DocumentInfo x
Prelude.Generic)

-- |
-- Create a value of 'DocumentInfo' 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:
--
-- 'attributes', 'documentInfo_attributes' - Attributes that identify a specific version of a document to check.
--
-- The only valid attributes are:
--
-- -   version
--
-- -   datasourceId
--
-- -   jobExecutionId
--
-- The attributes follow these rules:
--
-- -   @dataSourceId@ and @jobExecutionId@ must be used together.
--
-- -   @version@ is ignored if @dataSourceId@ and @jobExecutionId@ are not
--     provided.
--
-- -   If @dataSourceId@ and @jobExecutionId@ are provided, but @version@
--     is not, the version defaults to \"0\".
--
-- 'documentId', 'documentInfo_documentId' - The identifier of the document.
newDocumentInfo ::
  -- | 'documentId'
  Prelude.Text ->
  DocumentInfo
newDocumentInfo :: Text -> DocumentInfo
newDocumentInfo Text
pDocumentId_ =
  DocumentInfo'
    { $sel:attributes:DocumentInfo' :: Maybe [DocumentAttribute]
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:DocumentInfo' :: Text
documentId = Text
pDocumentId_
    }

-- | Attributes that identify a specific version of a document to check.
--
-- The only valid attributes are:
--
-- -   version
--
-- -   datasourceId
--
-- -   jobExecutionId
--
-- The attributes follow these rules:
--
-- -   @dataSourceId@ and @jobExecutionId@ must be used together.
--
-- -   @version@ is ignored if @dataSourceId@ and @jobExecutionId@ are not
--     provided.
--
-- -   If @dataSourceId@ and @jobExecutionId@ are provided, but @version@
--     is not, the version defaults to \"0\".
documentInfo_attributes :: Lens.Lens' DocumentInfo (Prelude.Maybe [DocumentAttribute])
documentInfo_attributes :: Lens' DocumentInfo (Maybe [DocumentAttribute])
documentInfo_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentInfo' {Maybe [DocumentAttribute]
attributes :: Maybe [DocumentAttribute]
$sel:attributes:DocumentInfo' :: DocumentInfo -> Maybe [DocumentAttribute]
attributes} -> Maybe [DocumentAttribute]
attributes) (\s :: DocumentInfo
s@DocumentInfo' {} Maybe [DocumentAttribute]
a -> DocumentInfo
s {$sel:attributes:DocumentInfo' :: Maybe [DocumentAttribute]
attributes = Maybe [DocumentAttribute]
a} :: DocumentInfo) 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

-- | The identifier of the document.
documentInfo_documentId :: Lens.Lens' DocumentInfo Prelude.Text
documentInfo_documentId :: Lens' DocumentInfo Text
documentInfo_documentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentInfo' {Text
documentId :: Text
$sel:documentId:DocumentInfo' :: DocumentInfo -> Text
documentId} -> Text
documentId) (\s :: DocumentInfo
s@DocumentInfo' {} Text
a -> DocumentInfo
s {$sel:documentId:DocumentInfo' :: Text
documentId = Text
a} :: DocumentInfo)

instance Prelude.Hashable DocumentInfo where
  hashWithSalt :: Int -> DocumentInfo -> Int
hashWithSalt Int
_salt DocumentInfo' {Maybe [DocumentAttribute]
Text
documentId :: Text
attributes :: Maybe [DocumentAttribute]
$sel:documentId:DocumentInfo' :: DocumentInfo -> Text
$sel:attributes:DocumentInfo' :: DocumentInfo -> Maybe [DocumentAttribute]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DocumentAttribute]
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentId

instance Prelude.NFData DocumentInfo where
  rnf :: DocumentInfo -> ()
rnf DocumentInfo' {Maybe [DocumentAttribute]
Text
documentId :: Text
attributes :: Maybe [DocumentAttribute]
$sel:documentId:DocumentInfo' :: DocumentInfo -> Text
$sel:attributes:DocumentInfo' :: DocumentInfo -> Maybe [DocumentAttribute]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DocumentAttribute]
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentId

instance Data.ToJSON DocumentInfo where
  toJSON :: DocumentInfo -> Value
toJSON DocumentInfo' {Maybe [DocumentAttribute]
Text
documentId :: Text
attributes :: Maybe [DocumentAttribute]
$sel:documentId:DocumentInfo' :: DocumentInfo -> Text
$sel:attributes:DocumentInfo' :: DocumentInfo -> Maybe [DocumentAttribute]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Attributes" 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 [DocumentAttribute]
attributes,
            forall a. a -> Maybe a
Prelude.Just (Key
"DocumentId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
documentId)
          ]
      )