{-# 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.Textract.Types.DocumentGroup
-- 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.Textract.Types.DocumentGroup 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
import Amazonka.Textract.Types.DetectedSignature
import Amazonka.Textract.Types.SplitDocument
import Amazonka.Textract.Types.UndetectedSignature

-- | Summary information about documents grouped by the same document type.
--
-- /See:/ 'newDocumentGroup' smart constructor.
data DocumentGroup = DocumentGroup'
  { -- | A list of the detected signatures found in a document group.
    DocumentGroup -> Maybe [DetectedSignature]
detectedSignatures :: Prelude.Maybe [DetectedSignature],
    -- | An array that contains information about the pages of a document,
    -- defined by logical boundary.
    DocumentGroup -> Maybe [SplitDocument]
splitDocuments :: Prelude.Maybe [SplitDocument],
    -- | The type of document that Amazon Textract has detected. See LINK for a
    -- list of all types returned by Textract.
    DocumentGroup -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | A list of any expected signatures not found in a document group.
    DocumentGroup -> Maybe [UndetectedSignature]
undetectedSignatures :: Prelude.Maybe [UndetectedSignature]
  }
  deriving (DocumentGroup -> DocumentGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentGroup -> DocumentGroup -> Bool
$c/= :: DocumentGroup -> DocumentGroup -> Bool
== :: DocumentGroup -> DocumentGroup -> Bool
$c== :: DocumentGroup -> DocumentGroup -> Bool
Prelude.Eq, ReadPrec [DocumentGroup]
ReadPrec DocumentGroup
Int -> ReadS DocumentGroup
ReadS [DocumentGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentGroup]
$creadListPrec :: ReadPrec [DocumentGroup]
readPrec :: ReadPrec DocumentGroup
$creadPrec :: ReadPrec DocumentGroup
readList :: ReadS [DocumentGroup]
$creadList :: ReadS [DocumentGroup]
readsPrec :: Int -> ReadS DocumentGroup
$creadsPrec :: Int -> ReadS DocumentGroup
Prelude.Read, Int -> DocumentGroup -> ShowS
[DocumentGroup] -> ShowS
DocumentGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentGroup] -> ShowS
$cshowList :: [DocumentGroup] -> ShowS
show :: DocumentGroup -> String
$cshow :: DocumentGroup -> String
showsPrec :: Int -> DocumentGroup -> ShowS
$cshowsPrec :: Int -> DocumentGroup -> ShowS
Prelude.Show, forall x. Rep DocumentGroup x -> DocumentGroup
forall x. DocumentGroup -> Rep DocumentGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentGroup x -> DocumentGroup
$cfrom :: forall x. DocumentGroup -> Rep DocumentGroup x
Prelude.Generic)

-- |
-- Create a value of 'DocumentGroup' 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:
--
-- 'detectedSignatures', 'documentGroup_detectedSignatures' - A list of the detected signatures found in a document group.
--
-- 'splitDocuments', 'documentGroup_splitDocuments' - An array that contains information about the pages of a document,
-- defined by logical boundary.
--
-- 'type'', 'documentGroup_type' - The type of document that Amazon Textract has detected. See LINK for a
-- list of all types returned by Textract.
--
-- 'undetectedSignatures', 'documentGroup_undetectedSignatures' - A list of any expected signatures not found in a document group.
newDocumentGroup ::
  DocumentGroup
newDocumentGroup :: DocumentGroup
newDocumentGroup =
  DocumentGroup'
    { $sel:detectedSignatures:DocumentGroup' :: Maybe [DetectedSignature]
detectedSignatures =
        forall a. Maybe a
Prelude.Nothing,
      $sel:splitDocuments:DocumentGroup' :: Maybe [SplitDocument]
splitDocuments = forall a. Maybe a
Prelude.Nothing,
      $sel:type':DocumentGroup' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:undetectedSignatures:DocumentGroup' :: Maybe [UndetectedSignature]
undetectedSignatures = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of the detected signatures found in a document group.
documentGroup_detectedSignatures :: Lens.Lens' DocumentGroup (Prelude.Maybe [DetectedSignature])
documentGroup_detectedSignatures :: Lens' DocumentGroup (Maybe [DetectedSignature])
documentGroup_detectedSignatures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentGroup' {Maybe [DetectedSignature]
detectedSignatures :: Maybe [DetectedSignature]
$sel:detectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [DetectedSignature]
detectedSignatures} -> Maybe [DetectedSignature]
detectedSignatures) (\s :: DocumentGroup
s@DocumentGroup' {} Maybe [DetectedSignature]
a -> DocumentGroup
s {$sel:detectedSignatures:DocumentGroup' :: Maybe [DetectedSignature]
detectedSignatures = Maybe [DetectedSignature]
a} :: DocumentGroup) 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

-- | An array that contains information about the pages of a document,
-- defined by logical boundary.
documentGroup_splitDocuments :: Lens.Lens' DocumentGroup (Prelude.Maybe [SplitDocument])
documentGroup_splitDocuments :: Lens' DocumentGroup (Maybe [SplitDocument])
documentGroup_splitDocuments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentGroup' {Maybe [SplitDocument]
splitDocuments :: Maybe [SplitDocument]
$sel:splitDocuments:DocumentGroup' :: DocumentGroup -> Maybe [SplitDocument]
splitDocuments} -> Maybe [SplitDocument]
splitDocuments) (\s :: DocumentGroup
s@DocumentGroup' {} Maybe [SplitDocument]
a -> DocumentGroup
s {$sel:splitDocuments:DocumentGroup' :: Maybe [SplitDocument]
splitDocuments = Maybe [SplitDocument]
a} :: DocumentGroup) 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 type of document that Amazon Textract has detected. See LINK for a
-- list of all types returned by Textract.
documentGroup_type :: Lens.Lens' DocumentGroup (Prelude.Maybe Prelude.Text)
documentGroup_type :: Lens' DocumentGroup (Maybe Text)
documentGroup_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentGroup' {Maybe Text
type' :: Maybe Text
$sel:type':DocumentGroup' :: DocumentGroup -> Maybe Text
type'} -> Maybe Text
type') (\s :: DocumentGroup
s@DocumentGroup' {} Maybe Text
a -> DocumentGroup
s {$sel:type':DocumentGroup' :: Maybe Text
type' = Maybe Text
a} :: DocumentGroup)

-- | A list of any expected signatures not found in a document group.
documentGroup_undetectedSignatures :: Lens.Lens' DocumentGroup (Prelude.Maybe [UndetectedSignature])
documentGroup_undetectedSignatures :: Lens' DocumentGroup (Maybe [UndetectedSignature])
documentGroup_undetectedSignatures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentGroup' {Maybe [UndetectedSignature]
undetectedSignatures :: Maybe [UndetectedSignature]
$sel:undetectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [UndetectedSignature]
undetectedSignatures} -> Maybe [UndetectedSignature]
undetectedSignatures) (\s :: DocumentGroup
s@DocumentGroup' {} Maybe [UndetectedSignature]
a -> DocumentGroup
s {$sel:undetectedSignatures:DocumentGroup' :: Maybe [UndetectedSignature]
undetectedSignatures = Maybe [UndetectedSignature]
a} :: DocumentGroup) 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

instance Data.FromJSON DocumentGroup where
  parseJSON :: Value -> Parser DocumentGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentGroup"
      ( \Object
x ->
          Maybe [DetectedSignature]
-> Maybe [SplitDocument]
-> Maybe Text
-> Maybe [UndetectedSignature]
-> DocumentGroup
DocumentGroup'
            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
"DetectedSignatures"
                            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
"SplitDocuments" 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
"Type")
            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
"UndetectedSignatures"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable DocumentGroup where
  hashWithSalt :: Int -> DocumentGroup -> Int
hashWithSalt Int
_salt DocumentGroup' {Maybe [DetectedSignature]
Maybe [SplitDocument]
Maybe [UndetectedSignature]
Maybe Text
undetectedSignatures :: Maybe [UndetectedSignature]
type' :: Maybe Text
splitDocuments :: Maybe [SplitDocument]
detectedSignatures :: Maybe [DetectedSignature]
$sel:undetectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [UndetectedSignature]
$sel:type':DocumentGroup' :: DocumentGroup -> Maybe Text
$sel:splitDocuments:DocumentGroup' :: DocumentGroup -> Maybe [SplitDocument]
$sel:detectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [DetectedSignature]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DetectedSignature]
detectedSignatures
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SplitDocument]
splitDocuments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UndetectedSignature]
undetectedSignatures

instance Prelude.NFData DocumentGroup where
  rnf :: DocumentGroup -> ()
rnf DocumentGroup' {Maybe [DetectedSignature]
Maybe [SplitDocument]
Maybe [UndetectedSignature]
Maybe Text
undetectedSignatures :: Maybe [UndetectedSignature]
type' :: Maybe Text
splitDocuments :: Maybe [SplitDocument]
detectedSignatures :: Maybe [DetectedSignature]
$sel:undetectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [UndetectedSignature]
$sel:type':DocumentGroup' :: DocumentGroup -> Maybe Text
$sel:splitDocuments:DocumentGroup' :: DocumentGroup -> Maybe [SplitDocument]
$sel:detectedSignatures:DocumentGroup' :: DocumentGroup -> Maybe [DetectedSignature]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DetectedSignature]
detectedSignatures
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SplitDocument]
splitDocuments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UndetectedSignature]
undetectedSignatures