{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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@).
--
-- 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_document,
    analyzeDocument_featureTypes,

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

    -- * Response Lenses
    analyzeDocumentResponse_documentMetadata,
    analyzeDocumentResponse_blocks,
    analyzeDocumentResponse_humanLoopActivationOutput,
    analyzeDocumentResponse_analyzeDocumentModelVersion,
    analyzeDocumentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | 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 or PNG 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. To perform both types
    -- of analysis, add TABLES and FORMS to @FeatureTypes@. 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
(AnalyzeDocument -> AnalyzeDocument -> Bool)
-> (AnalyzeDocument -> AnalyzeDocument -> Bool)
-> Eq AnalyzeDocument
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]
(Int -> ReadS AnalyzeDocument)
-> ReadS [AnalyzeDocument]
-> ReadPrec AnalyzeDocument
-> ReadPrec [AnalyzeDocument]
-> Read 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
(Int -> AnalyzeDocument -> ShowS)
-> (AnalyzeDocument -> String)
-> ([AnalyzeDocument] -> ShowS)
-> Show AnalyzeDocument
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. AnalyzeDocument -> Rep AnalyzeDocument x)
-> (forall x. Rep AnalyzeDocument x -> AnalyzeDocument)
-> Generic AnalyzeDocument
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.
--
-- '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 or PNG 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. To perform both types
-- of analysis, add TABLES and FORMS to @FeatureTypes@. 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' :: Maybe HumanLoopConfig
-> Document -> [FeatureType] -> AnalyzeDocument
AnalyzeDocument'
    { $sel:humanLoopConfig:AnalyzeDocument' :: Maybe HumanLoopConfig
humanLoopConfig = Maybe HumanLoopConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:document:AnalyzeDocument' :: Document
document = Document
pDocument_,
      $sel:featureTypes:AnalyzeDocument' :: [FeatureType]
featureTypes = [FeatureType]
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 :: (Maybe HumanLoopConfig -> f (Maybe HumanLoopConfig))
-> AnalyzeDocument -> f AnalyzeDocument
analyzeDocument_humanLoopConfig = (AnalyzeDocument -> Maybe HumanLoopConfig)
-> (AnalyzeDocument -> Maybe HumanLoopConfig -> AnalyzeDocument)
-> Lens
     AnalyzeDocument
     AnalyzeDocument
     (Maybe HumanLoopConfig)
     (Maybe 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)

-- | 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 or PNG 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 :: (Document -> f Document) -> AnalyzeDocument -> f AnalyzeDocument
analyzeDocument_document = (AnalyzeDocument -> Document)
-> (AnalyzeDocument -> Document -> AnalyzeDocument)
-> Lens AnalyzeDocument AnalyzeDocument Document 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. To perform both types
-- of analysis, add TABLES and FORMS to @FeatureTypes@. 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 :: ([FeatureType] -> f [FeatureType])
-> AnalyzeDocument -> f AnalyzeDocument
analyzeDocument_featureTypes = (AnalyzeDocument -> [FeatureType])
-> (AnalyzeDocument -> [FeatureType] -> AnalyzeDocument)
-> Lens AnalyzeDocument AnalyzeDocument [FeatureType] [FeatureType]
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) (([FeatureType] -> f [FeatureType])
 -> AnalyzeDocument -> f AnalyzeDocument)
-> (([FeatureType] -> f [FeatureType])
    -> [FeatureType] -> f [FeatureType])
-> ([FeatureType] -> f [FeatureType])
-> AnalyzeDocument
-> f AnalyzeDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([FeatureType] -> f [FeatureType])
-> [FeatureType] -> f [FeatureType]
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 :: AnalyzeDocument -> Request AnalyzeDocument
request = Service -> AnalyzeDocument -> Request AnalyzeDocument
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AnalyzeDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AnalyzeDocument)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AnalyzeDocument))
-> Logger
-> Service
-> Proxy AnalyzeDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AnalyzeDocument)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DocumentMetadata
-> Maybe [Block]
-> Maybe HumanLoopActivationOutput
-> Maybe Text
-> Int
-> AnalyzeDocumentResponse
AnalyzeDocumentResponse'
            (Maybe DocumentMetadata
 -> Maybe [Block]
 -> Maybe HumanLoopActivationOutput
 -> Maybe Text
 -> Int
 -> AnalyzeDocumentResponse)
-> Either String (Maybe DocumentMetadata)
-> Either
     String
     (Maybe [Block]
      -> Maybe HumanLoopActivationOutput
      -> Maybe Text
      -> Int
      -> AnalyzeDocumentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DocumentMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DocumentMetadata")
            Either
  String
  (Maybe [Block]
   -> Maybe HumanLoopActivationOutput
   -> Maybe Text
   -> Int
   -> AnalyzeDocumentResponse)
-> Either String (Maybe [Block])
-> Either
     String
     (Maybe HumanLoopActivationOutput
      -> Maybe Text -> Int -> AnalyzeDocumentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Block]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Blocks" Either String (Maybe (Maybe [Block]))
-> Maybe [Block] -> Either String (Maybe [Block])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Block]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe HumanLoopActivationOutput
   -> Maybe Text -> Int -> AnalyzeDocumentResponse)
-> Either String (Maybe HumanLoopActivationOutput)
-> Either String (Maybe Text -> Int -> AnalyzeDocumentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe HumanLoopActivationOutput)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"HumanLoopActivationOutput")
            Either String (Maybe Text -> Int -> AnalyzeDocumentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AnalyzeDocumentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AnalyzeDocumentModelVersion")
            Either String (Int -> AnalyzeDocumentResponse)
-> Either String Int -> Either String AnalyzeDocumentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AnalyzeDocument

instance Prelude.NFData AnalyzeDocument

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

instance Core.ToJSON AnalyzeDocument where
  toJSON :: AnalyzeDocument -> Value
toJSON AnalyzeDocument' {[FeatureType]
Maybe HumanLoopConfig
Document
featureTypes :: [FeatureType]
document :: Document
humanLoopConfig :: Maybe HumanLoopConfig
$sel:featureTypes:AnalyzeDocument' :: AnalyzeDocument -> [FeatureType]
$sel:document:AnalyzeDocument' :: AnalyzeDocument -> Document
$sel:humanLoopConfig:AnalyzeDocument' :: AnalyzeDocument -> Maybe HumanLoopConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HumanLoopConfig" Text -> HumanLoopConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HumanLoopConfig -> Pair) -> Maybe HumanLoopConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HumanLoopConfig
humanLoopConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Document" Text -> Document -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Document
document),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FeatureTypes" Text -> [FeatureType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [FeatureType]
featureTypes)
          ]
      )

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

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

-- | /See:/ 'newAnalyzeDocumentResponse' smart constructor.
data AnalyzeDocumentResponse = AnalyzeDocumentResponse'
  { -- | Metadata about the analyzed document. An example is the number of pages.
    AnalyzeDocumentResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
    -- | The items that are detected and analyzed by @AnalyzeDocument@.
    AnalyzeDocumentResponse -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
    -- | Shows the results of the human in the loop evaluation.
    AnalyzeDocumentResponse -> Maybe HumanLoopActivationOutput
humanLoopActivationOutput :: Prelude.Maybe HumanLoopActivationOutput,
    -- | The version of the model used to analyze the document.
    AnalyzeDocumentResponse -> Maybe Text
analyzeDocumentModelVersion :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AnalyzeDocumentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool
(AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool)
-> (AnalyzeDocumentResponse -> AnalyzeDocumentResponse -> Bool)
-> Eq AnalyzeDocumentResponse
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]
(Int -> ReadS AnalyzeDocumentResponse)
-> ReadS [AnalyzeDocumentResponse]
-> ReadPrec AnalyzeDocumentResponse
-> ReadPrec [AnalyzeDocumentResponse]
-> Read 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
(Int -> AnalyzeDocumentResponse -> ShowS)
-> (AnalyzeDocumentResponse -> String)
-> ([AnalyzeDocumentResponse] -> ShowS)
-> Show AnalyzeDocumentResponse
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.
 AnalyzeDocumentResponse -> Rep AnalyzeDocumentResponse x)
-> (forall x.
    Rep AnalyzeDocumentResponse x -> AnalyzeDocumentResponse)
-> Generic AnalyzeDocumentResponse
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:
--
-- 'documentMetadata', 'analyzeDocumentResponse_documentMetadata' - Metadata about the analyzed document. An example is the number of pages.
--
-- 'blocks', 'analyzeDocumentResponse_blocks' - The items that are detected and analyzed by @AnalyzeDocument@.
--
-- 'humanLoopActivationOutput', 'analyzeDocumentResponse_humanLoopActivationOutput' - Shows the results of the human in the loop evaluation.
--
-- 'analyzeDocumentModelVersion', 'analyzeDocumentResponse_analyzeDocumentModelVersion' - The version of the model used to analyze the document.
--
-- 'httpStatus', 'analyzeDocumentResponse_httpStatus' - The response's http status code.
newAnalyzeDocumentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AnalyzeDocumentResponse
newAnalyzeDocumentResponse :: Int -> AnalyzeDocumentResponse
newAnalyzeDocumentResponse Int
pHttpStatus_ =
  AnalyzeDocumentResponse' :: Maybe DocumentMetadata
-> Maybe [Block]
-> Maybe HumanLoopActivationOutput
-> Maybe Text
-> Int
-> AnalyzeDocumentResponse
AnalyzeDocumentResponse'
    { $sel:documentMetadata:AnalyzeDocumentResponse' :: Maybe DocumentMetadata
documentMetadata =
        Maybe DocumentMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:blocks:AnalyzeDocumentResponse' :: Maybe [Block]
blocks = Maybe [Block]
forall a. Maybe a
Prelude.Nothing,
      $sel:humanLoopActivationOutput:AnalyzeDocumentResponse' :: Maybe HumanLoopActivationOutput
humanLoopActivationOutput = Maybe HumanLoopActivationOutput
forall a. Maybe a
Prelude.Nothing,
      $sel:analyzeDocumentModelVersion:AnalyzeDocumentResponse' :: Maybe Text
analyzeDocumentModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AnalyzeDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Metadata about the analyzed document. An example is the number of pages.
analyzeDocumentResponse_documentMetadata :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe DocumentMetadata)
analyzeDocumentResponse_documentMetadata :: (Maybe DocumentMetadata -> f (Maybe DocumentMetadata))
-> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse
analyzeDocumentResponse_documentMetadata = (AnalyzeDocumentResponse -> Maybe DocumentMetadata)
-> (AnalyzeDocumentResponse
    -> Maybe DocumentMetadata -> AnalyzeDocumentResponse)
-> Lens
     AnalyzeDocumentResponse
     AnalyzeDocumentResponse
     (Maybe DocumentMetadata)
     (Maybe 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)

-- | The items that are detected and analyzed by @AnalyzeDocument@.
analyzeDocumentResponse_blocks :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe [Block])
analyzeDocumentResponse_blocks :: (Maybe [Block] -> f (Maybe [Block]))
-> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse
analyzeDocumentResponse_blocks = (AnalyzeDocumentResponse -> Maybe [Block])
-> (AnalyzeDocumentResponse
    -> Maybe [Block] -> AnalyzeDocumentResponse)
-> Lens
     AnalyzeDocumentResponse
     AnalyzeDocumentResponse
     (Maybe [Block])
     (Maybe [Block])
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) ((Maybe [Block] -> f (Maybe [Block]))
 -> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse)
-> ((Maybe [Block] -> f (Maybe [Block]))
    -> Maybe [Block] -> f (Maybe [Block]))
-> (Maybe [Block] -> f (Maybe [Block]))
-> AnalyzeDocumentResponse
-> f AnalyzeDocumentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Block] [Block] [Block] [Block]
-> Iso
     (Maybe [Block]) (Maybe [Block]) (Maybe [Block]) (Maybe [Block])
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 AnIso [Block] [Block] [Block] [Block]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Shows the results of the human in the loop evaluation.
analyzeDocumentResponse_humanLoopActivationOutput :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe HumanLoopActivationOutput)
analyzeDocumentResponse_humanLoopActivationOutput :: (Maybe HumanLoopActivationOutput
 -> f (Maybe HumanLoopActivationOutput))
-> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse
analyzeDocumentResponse_humanLoopActivationOutput = (AnalyzeDocumentResponse -> Maybe HumanLoopActivationOutput)
-> (AnalyzeDocumentResponse
    -> Maybe HumanLoopActivationOutput -> AnalyzeDocumentResponse)
-> Lens
     AnalyzeDocumentResponse
     AnalyzeDocumentResponse
     (Maybe HumanLoopActivationOutput)
     (Maybe 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 version of the model used to analyze the document.
analyzeDocumentResponse_analyzeDocumentModelVersion :: Lens.Lens' AnalyzeDocumentResponse (Prelude.Maybe Prelude.Text)
analyzeDocumentResponse_analyzeDocumentModelVersion :: (Maybe Text -> f (Maybe Text))
-> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse
analyzeDocumentResponse_analyzeDocumentModelVersion = (AnalyzeDocumentResponse -> Maybe Text)
-> (AnalyzeDocumentResponse
    -> Maybe Text -> AnalyzeDocumentResponse)
-> Lens
     AnalyzeDocumentResponse
     AnalyzeDocumentResponse
     (Maybe Text)
     (Maybe Text)
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 response's http status code.
analyzeDocumentResponse_httpStatus :: Lens.Lens' AnalyzeDocumentResponse Prelude.Int
analyzeDocumentResponse_httpStatus :: (Int -> f Int)
-> AnalyzeDocumentResponse -> f AnalyzeDocumentResponse
analyzeDocumentResponse_httpStatus = (AnalyzeDocumentResponse -> Int)
-> (AnalyzeDocumentResponse -> Int -> AnalyzeDocumentResponse)
-> Lens AnalyzeDocumentResponse AnalyzeDocumentResponse Int Int
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