{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.AnalyzeDocument
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Analyzes an input document for relationships between detected items.
--
-- The types of information returned are as follows:
--
-- -   Form data (key-value pairs). The related information is returned in
--     two Block objects, each of type @KEY_VALUE_SET@: a KEY @Block@
--     object and a VALUE @Block@ object. For example, /Name: Ana Silva
--     Carolina/ contains a key and value. /Name:/ is the key. /Ana Silva
--     Carolina/ is the value.
--
-- -   Table and table cell data. A TABLE @Block@ object contains
--     information about a detected table. A CELL @Block@ object is
--     returned for each cell in a table.
--
-- -   Lines and words of text. A LINE @Block@ object contains one or more
--     WORD @Block@ objects. All lines and words that are detected in the
--     document are returned (including text that doesn\'t have a
--     relationship with the value of @FeatureTypes@).
--
-- -   Signatures. A SIGNATURE @Block@ object contains the location
--     information of a signature in a document. If used in conjunction
--     with forms or tables, a signature can be given a Key-Value pairing
--     or be detected in the cell of a table.
--
-- -   Query. A QUERY Block object contains the query text, alias and link
--     to the associated Query results block object.
--
-- -   Query Result. A QUERY_RESULT Block object contains the answer to the
--     query and an ID that connects it to the query asked. This Block also
--     contains a confidence score.
--
-- Selection elements such as check boxes and option buttons (radio
-- buttons) can be detected in form data and in tables. A SELECTION_ELEMENT
-- @Block@ object contains information about a selection element, including
-- the selection status.
--
-- You can choose which type of analysis to perform by specifying the
-- @FeatureTypes@ list.
--
-- The output is returned in a list of @Block@ objects.
--
-- @AnalyzeDocument@ is a synchronous operation. To analyze documents
-- asynchronously, use StartDocumentAnalysis.
--
-- For more information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html Document Text Analysis>.
module Amazonka.Textract.AnalyzeDocument
  ( -- * Creating a Request
    AnalyzeDocument (..),
    newAnalyzeDocument,

    -- * Request Lenses
    analyzeDocument_humanLoopConfig,
    analyzeDocument_queriesConfig,
    analyzeDocument_document,
    analyzeDocument_featureTypes,

    -- * Destructuring the Response
    AnalyzeDocumentResponse (..),
    newAnalyzeDocumentResponse,

    -- * Response Lenses
    analyzeDocumentResponse_analyzeDocumentModelVersion,
    analyzeDocumentResponse_blocks,
    analyzeDocumentResponse_documentMetadata,
    analyzeDocumentResponse_humanLoopActivationOutput,
    analyzeDocumentResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Textract.Types

-- | /See:/ 'newAnalyzeDocument' smart constructor.
data AnalyzeDocument = AnalyzeDocument'
  { -- | Sets the configuration for the human in the loop workflow for analyzing
    -- documents.
    AnalyzeDocument -> Maybe HumanLoopConfig
humanLoopConfig :: Prelude.Maybe HumanLoopConfig,
    -- | Contains Queries and the alias for those Queries, as determined by the
    -- input.
    AnalyzeDocument -> Maybe QueriesConfig
queriesConfig :: Prelude.Maybe QueriesConfig,
    -- | The input document as base64-encoded bytes or an Amazon S3 object. If
    -- you use the AWS CLI to call Amazon Textract operations, you can\'t pass
    -- image bytes. The document must be an image in JPEG, PNG, PDF, or TIFF
    -- format.
    --
    -- If you\'re using an AWS SDK to call Amazon Textract, you might not need
    -- to base64-encode image bytes that are passed using the @Bytes@ field.
    AnalyzeDocument -> Document
document :: Document,
    -- | A list of the types of analysis to perform. Add TABLES to the list to
    -- return information about the tables that are detected in the input
    -- document. Add FORMS to return detected form data. Add SIGNATURES to
    -- return the locations of detected signatures. To perform both forms and
    -- table analysis, add TABLES and FORMS to @FeatureTypes@. To detect
    -- signatures within form data and table data, add SIGNATURES to either
    -- TABLES or FORMS. All lines and words detected in the document are
    -- included in the response (including text that isn\'t related to the
    -- value of @FeatureTypes@).
    AnalyzeDocument -> [FeatureType]
featureTypes :: [FeatureType]
  }
  deriving (AnalyzeDocument -> AnalyzeDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyzeDocument -> AnalyzeDocument -> Bool
$c/= :: AnalyzeDocument -> AnalyzeDocument -> Bool
== :: AnalyzeDocument -> AnalyzeDocument -> Bool
$c== :: AnalyzeDocument -> AnalyzeDocument -> Bool
Prelude.Eq, ReadPrec [AnalyzeDocument]
ReadPrec AnalyzeDocument
Int -> ReadS AnalyzeDocument
ReadS [AnalyzeDocument]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyzeDocument]
$creadListPrec :: ReadPrec [AnalyzeDocument]
readPrec :: ReadPrec AnalyzeDocument
$creadPrec :: ReadPrec AnalyzeDocument
readList :: ReadS [AnalyzeDocument]
$creadList :: ReadS [AnalyzeDocument]
readsPrec :: Int -> ReadS AnalyzeDocument
$creadsPrec :: Int -> ReadS AnalyzeDocument
Prelude.Read, Int -> AnalyzeDocument -> ShowS
[AnalyzeDocument] -> ShowS
AnalyzeDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyzeDocument] -> ShowS
$cshowList :: [AnalyzeDocument] -> ShowS
show :: AnalyzeDocument -> String
$cshow :: AnalyzeDocument -> String
showsPrec :: Int -> AnalyzeDocument -> ShowS
$cshowsPrec :: Int -> AnalyzeDocument -> ShowS
Prelude.Show, forall x. Rep AnalyzeDocument x -> AnalyzeDocument
forall x. AnalyzeDocument -> Rep AnalyzeDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalyzeDocument x -> AnalyzeDocument
$cfrom :: forall x. AnalyzeDocument -> Rep AnalyzeDocument x
Prelude.Generic)

-- |
-- Create a value of 'AnalyzeDocument' 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:
--
-- 'humanLoopConfig', 'analyzeDocument_humanLoopConfig' - Sets the configuration for the human in the loop workflow for analyzing
-- documents.
--
-- 'queriesConfig', 'analyzeDocument_queriesConfig' - Contains Queries and the alias for those Queries, as determined by the
-- input.
--
-- 'document', 'analyzeDocument_document' - The input document as base64-encoded bytes or an Amazon S3 object. If
-- you use the AWS CLI to call Amazon Textract operations, you can\'t pass
-- image bytes. The document must be an image in JPEG, PNG, PDF, or TIFF
-- format.
--
-- If you\'re using an AWS SDK to call Amazon Textract, you might not need
-- to base64-encode image bytes that are passed using the @Bytes@ field.
--
-- 'featureTypes', 'analyzeDocument_featureTypes' - A list of the types of analysis to perform. Add TABLES to the list to
-- return information about the tables that are detected in the input
-- document. Add FORMS to return detected form data. Add SIGNATURES to
-- return the locations of detected signatures. To perform both forms and
-- table analysis, add TABLES and FORMS to @FeatureTypes@. To detect
-- signatures within form data and table data, add SIGNATURES to either
-- TABLES or FORMS. All lines and words detected in the document are
-- included in the response (including text that isn\'t related to the
-- value of @FeatureTypes@).
newAnalyzeDocument ::
  -- | 'document'
  Document ->
  AnalyzeDocument
newAnalyzeDocument :: Document -> AnalyzeDocument
newAnalyzeDocument Document
pDocument_ =
  AnalyzeDocument'
    { $sel:humanLoopConfig:AnalyzeDocument' :: Maybe HumanLoopConfig
humanLoopConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:queriesConfig:AnalyzeDocument' :: Maybe QueriesConfig
queriesConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:document:AnalyzeDocument' :: Document
document = Document
pDocument_,
      $sel:featureTypes:AnalyzeDocument' :: [FeatureType]
featureTypes = forall a. Monoid a => a
Prelude.mempty
    }

-- | Sets the configuration for the human in the loop workflow for analyzing
-- documents.
analyzeDocument_humanLoopConfig :: Lens.Lens' AnalyzeDocument (Prelude.Maybe HumanLoopConfig)
analyzeDocument_humanLoopConfig :: Lens' AnalyzeDocument (Maybe HumanLoopConfig)
analyzeDocument_humanLoopConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocument' {Maybe HumanLoopConfig
humanLoopConfig :: Maybe HumanLoopConfig
$sel:humanLoopConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe HumanLoopConfig
humanLoopConfig} -> Maybe HumanLoopConfig
humanLoopConfig) (\s :: AnalyzeDocument
s@AnalyzeDocument' {} Maybe HumanLoopConfig
a -> AnalyzeDocument
s {$sel:humanLoopConfig:AnalyzeDocument' :: Maybe HumanLoopConfig
humanLoopConfig = Maybe HumanLoopConfig
a} :: AnalyzeDocument)

-- | Contains Queries and the alias for those Queries, as determined by the
-- input.
analyzeDocument_queriesConfig :: Lens.Lens' AnalyzeDocument (Prelude.Maybe QueriesConfig)
analyzeDocument_queriesConfig :: Lens' AnalyzeDocument (Maybe QueriesConfig)
analyzeDocument_queriesConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocument' {Maybe QueriesConfig
queriesConfig :: Maybe QueriesConfig
$sel:queriesConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe QueriesConfig
queriesConfig} -> Maybe QueriesConfig
queriesConfig) (\s :: AnalyzeDocument
s@AnalyzeDocument' {} Maybe QueriesConfig
a -> AnalyzeDocument
s {$sel:queriesConfig:AnalyzeDocument' :: Maybe QueriesConfig
queriesConfig = Maybe QueriesConfig
a} :: AnalyzeDocument)

-- | The input document as base64-encoded bytes or an Amazon S3 object. If
-- you use the AWS CLI to call Amazon Textract operations, you can\'t pass
-- image bytes. The document must be an image in JPEG, PNG, PDF, or TIFF
-- format.
--
-- If you\'re using an AWS SDK to call Amazon Textract, you might not need
-- to base64-encode image bytes that are passed using the @Bytes@ field.
analyzeDocument_document :: Lens.Lens' AnalyzeDocument Document
analyzeDocument_document :: Lens' AnalyzeDocument Document
analyzeDocument_document = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocument' {Document
document :: Document
$sel:document:AnalyzeDocument' :: AnalyzeDocument -> Document
document} -> Document
document) (\s :: AnalyzeDocument
s@AnalyzeDocument' {} Document
a -> AnalyzeDocument
s {$sel:document:AnalyzeDocument' :: Document
document = Document
a} :: AnalyzeDocument)

-- | A list of the types of analysis to perform. Add TABLES to the list to
-- return information about the tables that are detected in the input
-- document. Add FORMS to return detected form data. Add SIGNATURES to
-- return the locations of detected signatures. To perform both forms and
-- table analysis, add TABLES and FORMS to @FeatureTypes@. To detect
-- signatures within form data and table data, add SIGNATURES to either
-- TABLES or FORMS. All lines and words detected in the document are
-- included in the response (including text that isn\'t related to the
-- value of @FeatureTypes@).
analyzeDocument_featureTypes :: Lens.Lens' AnalyzeDocument [FeatureType]
analyzeDocument_featureTypes :: Lens' AnalyzeDocument [FeatureType]
analyzeDocument_featureTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocument' {[FeatureType]
featureTypes :: [FeatureType]
$sel:featureTypes:AnalyzeDocument' :: AnalyzeDocument -> [FeatureType]
featureTypes} -> [FeatureType]
featureTypes) (\s :: AnalyzeDocument
s@AnalyzeDocument' {} [FeatureType]
a -> AnalyzeDocument
s {$sel:featureTypes:AnalyzeDocument' :: [FeatureType]
featureTypes = [FeatureType]
a} :: AnalyzeDocument) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest AnalyzeDocument where
  type
    AWSResponse AnalyzeDocument =
      AnalyzeDocumentResponse
  request :: (Service -> Service) -> AnalyzeDocument -> Request AnalyzeDocument
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AnalyzeDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AnalyzeDocument)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe [Block]
-> Maybe DocumentMetadata
-> Maybe HumanLoopActivationOutput
-> Int
-> AnalyzeDocumentResponse
AnalyzeDocumentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"AnalyzeDocumentModelVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Blocks" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ 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 -> Either String (Maybe a)
Data..?> Key
"DocumentMetadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"HumanLoopActivationOutput")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AnalyzeDocument where
  hashWithSalt :: Int -> AnalyzeDocument -> Int
hashWithSalt Int
_salt AnalyzeDocument' {[FeatureType]
Maybe HumanLoopConfig
Maybe QueriesConfig
Document
featureTypes :: [FeatureType]
document :: Document
queriesConfig :: Maybe QueriesConfig
humanLoopConfig :: Maybe HumanLoopConfig
$sel:featureTypes:AnalyzeDocument' :: AnalyzeDocument -> [FeatureType]
$sel:document:AnalyzeDocument' :: AnalyzeDocument -> Document
$sel:queriesConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe QueriesConfig
$sel:humanLoopConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe HumanLoopConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HumanLoopConfig
humanLoopConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueriesConfig
queriesConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Document
document
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [FeatureType]
featureTypes

instance Prelude.NFData AnalyzeDocument where
  rnf :: AnalyzeDocument -> ()
rnf AnalyzeDocument' {[FeatureType]
Maybe HumanLoopConfig
Maybe QueriesConfig
Document
featureTypes :: [FeatureType]
document :: Document
queriesConfig :: Maybe QueriesConfig
humanLoopConfig :: Maybe HumanLoopConfig
$sel:featureTypes:AnalyzeDocument' :: AnalyzeDocument -> [FeatureType]
$sel:document:AnalyzeDocument' :: AnalyzeDocument -> Document
$sel:queriesConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe QueriesConfig
$sel:humanLoopConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe HumanLoopConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe HumanLoopConfig
humanLoopConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QueriesConfig
queriesConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Document
document
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [FeatureType]
featureTypes

instance Data.ToHeaders AnalyzeDocument where
  toHeaders :: AnalyzeDocument -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"Textract.AnalyzeDocument" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON AnalyzeDocument where
  toJSON :: AnalyzeDocument -> Value
toJSON AnalyzeDocument' {[FeatureType]
Maybe HumanLoopConfig
Maybe QueriesConfig
Document
featureTypes :: [FeatureType]
document :: Document
queriesConfig :: Maybe QueriesConfig
humanLoopConfig :: Maybe HumanLoopConfig
$sel:featureTypes:AnalyzeDocument' :: AnalyzeDocument -> [FeatureType]
$sel:document:AnalyzeDocument' :: AnalyzeDocument -> Document
$sel:queriesConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe QueriesConfig
$sel:humanLoopConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe HumanLoopConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"HumanLoopConfig" 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 HumanLoopConfig
humanLoopConfig,
            (Key
"QueriesConfig" 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 QueriesConfig
queriesConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"Document" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Document
document),
            forall a. a -> Maybe a
Prelude.Just (Key
"FeatureTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [FeatureType]
featureTypes)
          ]
      )

instance Data.ToPath AnalyzeDocument where
  toPath :: AnalyzeDocument -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery AnalyzeDocument where
  toQuery :: AnalyzeDocument -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newAnalyzeDocumentResponse' smart constructor.
data AnalyzeDocumentResponse = AnalyzeDocumentResponse'
  { -- | The version of the model used to analyze the document.
    AnalyzeDocumentResponse -> Maybe Text
analyzeDocumentModelVersion :: Prelude.Maybe Prelude.Text,
    -- | The items that are detected and analyzed by @AnalyzeDocument@.
    AnalyzeDocumentResponse -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
    -- | Metadata about the analyzed document. An example is the number of pages.
    AnalyzeDocumentResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
    -- | Shows the results of the human in the loop evaluation.
    AnalyzeDocumentResponse -> Maybe HumanLoopActivationOutput
humanLoopActivationOutput :: Prelude.Maybe HumanLoopActivationOutput,
    -- | The response's http status code.
    AnalyzeDocumentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
$c/= :: AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
== :: AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
$c== :: AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
Prelude.Eq, ReadPrec [AnalyzeDocumentResponse]
ReadPrec AnalyzeDocumentResponse
Int -> ReadS AnalyzeDocumentResponse
ReadS [AnalyzeDocumentResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyzeDocumentResponse]
$creadListPrec :: ReadPrec [AnalyzeDocumentResponse]
readPrec :: ReadPrec AnalyzeDocumentResponse
$creadPrec :: ReadPrec AnalyzeDocumentResponse
readList :: ReadS [AnalyzeDocumentResponse]
$creadList :: ReadS [AnalyzeDocumentResponse]
readsPrec :: Int -> ReadS AnalyzeDocumentResponse
$creadsPrec :: Int -> ReadS AnalyzeDocumentResponse
Prelude.Read, Int -> AnalyzeDocumentResponse -> ShowS
[AnalyzeDocumentResponse] -> ShowS
AnalyzeDocumentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyzeDocumentResponse] -> ShowS
$cshowList :: [AnalyzeDocumentResponse] -> ShowS
show :: AnalyzeDocumentResponse -> String
$cshow :: AnalyzeDocumentResponse -> String
showsPrec :: Int -> AnalyzeDocumentResponse -> ShowS
$cshowsPrec :: Int -> AnalyzeDocumentResponse -> ShowS
Prelude.Show, forall x. Rep AnalyzeDocumentResponse x -> AnalyzeDocumentResponse
forall x. AnalyzeDocumentResponse -> Rep AnalyzeDocumentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalyzeDocumentResponse x -> AnalyzeDocumentResponse
$cfrom :: forall x. AnalyzeDocumentResponse -> Rep AnalyzeDocumentResponse x
Prelude.Generic)

-- |
-- Create a value of 'AnalyzeDocumentResponse' 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:
--
-- 'analyzeDocumentModelVersion', 'analyzeDocumentResponse_analyzeDocumentModelVersion' - The version of the model used to analyze the document.
--
-- 'blocks', 'analyzeDocumentResponse_blocks' - The items that are detected and analyzed by @AnalyzeDocument@.
--
-- 'documentMetadata', 'analyzeDocumentResponse_documentMetadata' - Metadata about the analyzed document. An example is the number of pages.
--
-- 'humanLoopActivationOutput', 'analyzeDocumentResponse_humanLoopActivationOutput' - Shows the results of the human in the loop evaluation.
--
-- 'httpStatus', 'analyzeDocumentResponse_httpStatus' - The response's http status code.
newAnalyzeDocumentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AnalyzeDocumentResponse
newAnalyzeDocumentResponse :: Int -> AnalyzeDocumentResponse
newAnalyzeDocumentResponse Int
pHttpStatus_ =
  AnalyzeDocumentResponse'
    { $sel:analyzeDocumentModelVersion:AnalyzeDocumentResponse' :: Maybe Text
analyzeDocumentModelVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:blocks:AnalyzeDocumentResponse' :: Maybe [Block]
blocks = forall a. Maybe a
Prelude.Nothing,
      $sel:documentMetadata:AnalyzeDocumentResponse' :: Maybe DocumentMetadata
documentMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:humanLoopActivationOutput:AnalyzeDocumentResponse' :: Maybe HumanLoopActivationOutput
humanLoopActivationOutput = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AnalyzeDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The version of the model used to analyze the document.
analyzeDocumentResponse_analyzeDocumentModelVersion :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe Prelude.Text)
analyzeDocumentResponse_analyzeDocumentModelVersion :: Lens' AnalyzeDocumentResponse (Maybe Text)
analyzeDocumentResponse_analyzeDocumentModelVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocumentResponse' {Maybe Text
analyzeDocumentModelVersion :: Maybe Text
$sel:analyzeDocumentModelVersion:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe Text
analyzeDocumentModelVersion} -> Maybe Text
analyzeDocumentModelVersion) (\s :: AnalyzeDocumentResponse
s@AnalyzeDocumentResponse' {} Maybe Text
a -> AnalyzeDocumentResponse
s {$sel:analyzeDocumentModelVersion:AnalyzeDocumentResponse' :: Maybe Text
analyzeDocumentModelVersion = Maybe Text
a} :: AnalyzeDocumentResponse)

-- | The items that are detected and analyzed by @AnalyzeDocument@.
analyzeDocumentResponse_blocks :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe [Block])
analyzeDocumentResponse_blocks :: Lens' AnalyzeDocumentResponse (Maybe [Block])
analyzeDocumentResponse_blocks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocumentResponse' {Maybe [Block]
blocks :: Maybe [Block]
$sel:blocks:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe [Block]
blocks} -> Maybe [Block]
blocks) (\s :: AnalyzeDocumentResponse
s@AnalyzeDocumentResponse' {} Maybe [Block]
a -> AnalyzeDocumentResponse
s {$sel:blocks:AnalyzeDocumentResponse' :: Maybe [Block]
blocks = Maybe [Block]
a} :: AnalyzeDocumentResponse) 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

-- | Metadata about the analyzed document. An example is the number of pages.
analyzeDocumentResponse_documentMetadata :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe DocumentMetadata)
analyzeDocumentResponse_documentMetadata :: Lens' AnalyzeDocumentResponse (Maybe DocumentMetadata)
analyzeDocumentResponse_documentMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocumentResponse' {Maybe DocumentMetadata
documentMetadata :: Maybe DocumentMetadata
$sel:documentMetadata:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe DocumentMetadata
documentMetadata} -> Maybe DocumentMetadata
documentMetadata) (\s :: AnalyzeDocumentResponse
s@AnalyzeDocumentResponse' {} Maybe DocumentMetadata
a -> AnalyzeDocumentResponse
s {$sel:documentMetadata:AnalyzeDocumentResponse' :: Maybe DocumentMetadata
documentMetadata = Maybe DocumentMetadata
a} :: AnalyzeDocumentResponse)

-- | Shows the results of the human in the loop evaluation.
analyzeDocumentResponse_humanLoopActivationOutput :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe HumanLoopActivationOutput)
analyzeDocumentResponse_humanLoopActivationOutput :: Lens' AnalyzeDocumentResponse (Maybe HumanLoopActivationOutput)
analyzeDocumentResponse_humanLoopActivationOutput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocumentResponse' {Maybe HumanLoopActivationOutput
humanLoopActivationOutput :: Maybe HumanLoopActivationOutput
$sel:humanLoopActivationOutput:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe HumanLoopActivationOutput
humanLoopActivationOutput} -> Maybe HumanLoopActivationOutput
humanLoopActivationOutput) (\s :: AnalyzeDocumentResponse
s@AnalyzeDocumentResponse' {} Maybe HumanLoopActivationOutput
a -> AnalyzeDocumentResponse
s {$sel:humanLoopActivationOutput:AnalyzeDocumentResponse' :: Maybe HumanLoopActivationOutput
humanLoopActivationOutput = Maybe HumanLoopActivationOutput
a} :: AnalyzeDocumentResponse)

-- | The response's http status code.
analyzeDocumentResponse_httpStatus :: Lens.Lens' AnalyzeDocumentResponse Prelude.Int
analyzeDocumentResponse_httpStatus :: Lens' AnalyzeDocumentResponse Int
analyzeDocumentResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeDocumentResponse' {Int
httpStatus :: Int
$sel:httpStatus:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AnalyzeDocumentResponse
s@AnalyzeDocumentResponse' {} Int
a -> AnalyzeDocumentResponse
s {$sel:httpStatus:AnalyzeDocumentResponse' :: Int
httpStatus = Int
a} :: AnalyzeDocumentResponse)

instance Prelude.NFData AnalyzeDocumentResponse where
  rnf :: AnalyzeDocumentResponse -> ()
rnf AnalyzeDocumentResponse' {Int
Maybe [Block]
Maybe Text
Maybe DocumentMetadata
Maybe HumanLoopActivationOutput
httpStatus :: Int
humanLoopActivationOutput :: Maybe HumanLoopActivationOutput
documentMetadata :: Maybe DocumentMetadata
blocks :: Maybe [Block]
analyzeDocumentModelVersion :: Maybe Text
$sel:httpStatus:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Int
$sel:humanLoopActivationOutput:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe HumanLoopActivationOutput
$sel:documentMetadata:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe DocumentMetadata
$sel:blocks:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe [Block]
$sel:analyzeDocumentModelVersion:AnalyzeDocumentResponse' :: AnalyzeDocumentResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
analyzeDocumentModelVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Block]
blocks
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentMetadata
documentMetadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HumanLoopActivationOutput
humanLoopActivationOutput
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus