{-# 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.GetDocumentAnalysis
-- 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)
--
-- Gets the results for an Amazon Textract asynchronous operation that
-- analyzes text in a document.
--
-- You start asynchronous text analysis by calling StartDocumentAnalysis,
-- which returns a job identifier (@JobId@). When the text analysis
-- operation finishes, Amazon Textract publishes a completion status to the
-- Amazon Simple Notification Service (Amazon SNS) topic that\'s registered
-- in the initial call to @StartDocumentAnalysis@. To get the results of
-- the text-detection operation, first check that the status value
-- published to the Amazon SNS topic is @SUCCEEDED@. If so, call
-- @GetDocumentAnalysis@, and pass the job identifier (@JobId@) from the
-- initial call to @StartDocumentAnalysis@.
--
-- @GetDocumentAnalysis@ returns an array of Block objects. The following
-- types of information are returned:
--
-- -   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 the @StartDocumentAnalysis@
--     @FeatureTypes@ input parameter).
--
-- 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.
--
-- Use the @MaxResults@ parameter to limit the number of blocks that are
-- returned. If there are more results than specified in @MaxResults@, the
-- value of @NextToken@ in the operation response contains a pagination
-- token for getting the next set of results. To get the next page of
-- results, call @GetDocumentAnalysis@, and populate the @NextToken@
-- request parameter with the token value that\'s returned from the
-- previous call to @GetDocumentAnalysis@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html Document Text Analysis>.
module Amazonka.Textract.GetDocumentAnalysis
  ( -- * Creating a Request
    GetDocumentAnalysis (..),
    newGetDocumentAnalysis,

    -- * Request Lenses
    getDocumentAnalysis_nextToken,
    getDocumentAnalysis_maxResults,
    getDocumentAnalysis_jobId,

    -- * Destructuring the Response
    GetDocumentAnalysisResponse (..),
    newGetDocumentAnalysisResponse,

    -- * Response Lenses
    getDocumentAnalysisResponse_documentMetadata,
    getDocumentAnalysisResponse_blocks,
    getDocumentAnalysisResponse_analyzeDocumentModelVersion,
    getDocumentAnalysisResponse_warnings,
    getDocumentAnalysisResponse_nextToken,
    getDocumentAnalysisResponse_statusMessage,
    getDocumentAnalysisResponse_jobStatus,
    getDocumentAnalysisResponse_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:/ 'newGetDocumentAnalysis' smart constructor.
data GetDocumentAnalysis = GetDocumentAnalysis'
  { -- | If the previous response was incomplete (because there are more blocks
    -- to retrieve), Amazon Textract returns a pagination token in the
    -- response. You can use this pagination token to retrieve the next set of
    -- blocks.
    GetDocumentAnalysis -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per paginated call. The largest
    -- value that you can specify is 1,000. If you specify a value greater than
    -- 1,000, a maximum of 1,000 results is returned. The default value is
    -- 1,000.
    GetDocumentAnalysis -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the text-detection job. The @JobId@ is returned
    -- from @StartDocumentAnalysis@. A @JobId@ value is only valid for 7 days.
    GetDocumentAnalysis -> Text
jobId :: Prelude.Text
  }
  deriving (GetDocumentAnalysis -> GetDocumentAnalysis -> Bool
(GetDocumentAnalysis -> GetDocumentAnalysis -> Bool)
-> (GetDocumentAnalysis -> GetDocumentAnalysis -> Bool)
-> Eq GetDocumentAnalysis
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentAnalysis -> GetDocumentAnalysis -> Bool
$c/= :: GetDocumentAnalysis -> GetDocumentAnalysis -> Bool
== :: GetDocumentAnalysis -> GetDocumentAnalysis -> Bool
$c== :: GetDocumentAnalysis -> GetDocumentAnalysis -> Bool
Prelude.Eq, ReadPrec [GetDocumentAnalysis]
ReadPrec GetDocumentAnalysis
Int -> ReadS GetDocumentAnalysis
ReadS [GetDocumentAnalysis]
(Int -> ReadS GetDocumentAnalysis)
-> ReadS [GetDocumentAnalysis]
-> ReadPrec GetDocumentAnalysis
-> ReadPrec [GetDocumentAnalysis]
-> Read GetDocumentAnalysis
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDocumentAnalysis]
$creadListPrec :: ReadPrec [GetDocumentAnalysis]
readPrec :: ReadPrec GetDocumentAnalysis
$creadPrec :: ReadPrec GetDocumentAnalysis
readList :: ReadS [GetDocumentAnalysis]
$creadList :: ReadS [GetDocumentAnalysis]
readsPrec :: Int -> ReadS GetDocumentAnalysis
$creadsPrec :: Int -> ReadS GetDocumentAnalysis
Prelude.Read, Int -> GetDocumentAnalysis -> ShowS
[GetDocumentAnalysis] -> ShowS
GetDocumentAnalysis -> String
(Int -> GetDocumentAnalysis -> ShowS)
-> (GetDocumentAnalysis -> String)
-> ([GetDocumentAnalysis] -> ShowS)
-> Show GetDocumentAnalysis
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentAnalysis] -> ShowS
$cshowList :: [GetDocumentAnalysis] -> ShowS
show :: GetDocumentAnalysis -> String
$cshow :: GetDocumentAnalysis -> String
showsPrec :: Int -> GetDocumentAnalysis -> ShowS
$cshowsPrec :: Int -> GetDocumentAnalysis -> ShowS
Prelude.Show, (forall x. GetDocumentAnalysis -> Rep GetDocumentAnalysis x)
-> (forall x. Rep GetDocumentAnalysis x -> GetDocumentAnalysis)
-> Generic GetDocumentAnalysis
forall x. Rep GetDocumentAnalysis x -> GetDocumentAnalysis
forall x. GetDocumentAnalysis -> Rep GetDocumentAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDocumentAnalysis x -> GetDocumentAnalysis
$cfrom :: forall x. GetDocumentAnalysis -> Rep GetDocumentAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'GetDocumentAnalysis' 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:
--
-- 'nextToken', 'getDocumentAnalysis_nextToken' - If the previous response was incomplete (because there are more blocks
-- to retrieve), Amazon Textract returns a pagination token in the
-- response. You can use this pagination token to retrieve the next set of
-- blocks.
--
-- 'maxResults', 'getDocumentAnalysis_maxResults' - The maximum number of results to return per paginated call. The largest
-- value that you can specify is 1,000. If you specify a value greater than
-- 1,000, a maximum of 1,000 results is returned. The default value is
-- 1,000.
--
-- 'jobId', 'getDocumentAnalysis_jobId' - A unique identifier for the text-detection job. The @JobId@ is returned
-- from @StartDocumentAnalysis@. A @JobId@ value is only valid for 7 days.
newGetDocumentAnalysis ::
  -- | 'jobId'
  Prelude.Text ->
  GetDocumentAnalysis
newGetDocumentAnalysis :: Text -> GetDocumentAnalysis
newGetDocumentAnalysis Text
pJobId_ =
  GetDocumentAnalysis' :: Maybe Text -> Maybe Natural -> Text -> GetDocumentAnalysis
GetDocumentAnalysis'
    { $sel:nextToken:GetDocumentAnalysis' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetDocumentAnalysis' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:GetDocumentAnalysis' :: Text
jobId = Text
pJobId_
    }

-- | If the previous response was incomplete (because there are more blocks
-- to retrieve), Amazon Textract returns a pagination token in the
-- response. You can use this pagination token to retrieve the next set of
-- blocks.
getDocumentAnalysis_nextToken :: Lens.Lens' GetDocumentAnalysis (Prelude.Maybe Prelude.Text)
getDocumentAnalysis_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDocumentAnalysis -> f GetDocumentAnalysis
getDocumentAnalysis_nextToken = (GetDocumentAnalysis -> Maybe Text)
-> (GetDocumentAnalysis -> Maybe Text -> GetDocumentAnalysis)
-> Lens
     GetDocumentAnalysis GetDocumentAnalysis (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysis' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDocumentAnalysis' :: GetDocumentAnalysis -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDocumentAnalysis
s@GetDocumentAnalysis' {} Maybe Text
a -> GetDocumentAnalysis
s {$sel:nextToken:GetDocumentAnalysis' :: Maybe Text
nextToken = Maybe Text
a} :: GetDocumentAnalysis)

-- | The maximum number of results to return per paginated call. The largest
-- value that you can specify is 1,000. If you specify a value greater than
-- 1,000, a maximum of 1,000 results is returned. The default value is
-- 1,000.
getDocumentAnalysis_maxResults :: Lens.Lens' GetDocumentAnalysis (Prelude.Maybe Prelude.Natural)
getDocumentAnalysis_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetDocumentAnalysis -> f GetDocumentAnalysis
getDocumentAnalysis_maxResults = (GetDocumentAnalysis -> Maybe Natural)
-> (GetDocumentAnalysis -> Maybe Natural -> GetDocumentAnalysis)
-> Lens
     GetDocumentAnalysis
     GetDocumentAnalysis
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysis' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetDocumentAnalysis' :: GetDocumentAnalysis -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetDocumentAnalysis
s@GetDocumentAnalysis' {} Maybe Natural
a -> GetDocumentAnalysis
s {$sel:maxResults:GetDocumentAnalysis' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetDocumentAnalysis)

-- | A unique identifier for the text-detection job. The @JobId@ is returned
-- from @StartDocumentAnalysis@. A @JobId@ value is only valid for 7 days.
getDocumentAnalysis_jobId :: Lens.Lens' GetDocumentAnalysis Prelude.Text
getDocumentAnalysis_jobId :: (Text -> f Text) -> GetDocumentAnalysis -> f GetDocumentAnalysis
getDocumentAnalysis_jobId = (GetDocumentAnalysis -> Text)
-> (GetDocumentAnalysis -> Text -> GetDocumentAnalysis)
-> Lens GetDocumentAnalysis GetDocumentAnalysis Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysis' {Text
jobId :: Text
$sel:jobId:GetDocumentAnalysis' :: GetDocumentAnalysis -> Text
jobId} -> Text
jobId) (\s :: GetDocumentAnalysis
s@GetDocumentAnalysis' {} Text
a -> GetDocumentAnalysis
s {$sel:jobId:GetDocumentAnalysis' :: Text
jobId = Text
a} :: GetDocumentAnalysis)

instance Core.AWSRequest GetDocumentAnalysis where
  type
    AWSResponse GetDocumentAnalysis =
      GetDocumentAnalysisResponse
  request :: GetDocumentAnalysis -> Request GetDocumentAnalysis
request = Service -> GetDocumentAnalysis -> Request GetDocumentAnalysis
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDocumentAnalysis
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDocumentAnalysis)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDocumentAnalysis))
-> Logger
-> Service
-> Proxy GetDocumentAnalysis
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDocumentAnalysis)))
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 Text
-> Maybe [Warning]
-> Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Int
-> GetDocumentAnalysisResponse
GetDocumentAnalysisResponse'
            (Maybe DocumentMetadata
 -> Maybe [Block]
 -> Maybe Text
 -> Maybe [Warning]
 -> Maybe Text
 -> Maybe Text
 -> Maybe JobStatus
 -> Int
 -> GetDocumentAnalysisResponse)
-> Either String (Maybe DocumentMetadata)
-> Either
     String
     (Maybe [Block]
      -> Maybe Text
      -> Maybe [Warning]
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentAnalysisResponse)
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 Text
   -> Maybe [Warning]
   -> Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentAnalysisResponse)
-> Either String (Maybe [Block])
-> Either
     String
     (Maybe Text
      -> Maybe [Warning]
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentAnalysisResponse)
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 Text
   -> Maybe [Warning]
   -> Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentAnalysisResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Warning]
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentAnalysisResponse)
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
  (Maybe [Warning]
   -> Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentAnalysisResponse)
-> Either String (Maybe [Warning])
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentAnalysisResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Warning]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Warnings" Either String (Maybe (Maybe [Warning]))
-> Maybe [Warning] -> Either String (Maybe [Warning])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Warning]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentAnalysisResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe JobStatus -> Int -> GetDocumentAnalysisResponse)
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
"NextToken")
            Either
  String
  (Maybe Text
   -> Maybe JobStatus -> Int -> GetDocumentAnalysisResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe JobStatus -> Int -> GetDocumentAnalysisResponse)
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
"StatusMessage")
            Either
  String (Maybe JobStatus -> Int -> GetDocumentAnalysisResponse)
-> Either String (Maybe JobStatus)
-> Either String (Int -> GetDocumentAnalysisResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe JobStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"JobStatus")
            Either String (Int -> GetDocumentAnalysisResponse)
-> Either String Int -> Either String GetDocumentAnalysisResponse
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 GetDocumentAnalysis

instance Prelude.NFData GetDocumentAnalysis

instance Core.ToHeaders GetDocumentAnalysis where
  toHeaders :: GetDocumentAnalysis -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDocumentAnalysis -> 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.GetDocumentAnalysis" ::
                          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 GetDocumentAnalysis where
  toJSON :: GetDocumentAnalysis -> Value
toJSON GetDocumentAnalysis' {Maybe Natural
Maybe Text
Text
jobId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:jobId:GetDocumentAnalysis' :: GetDocumentAnalysis -> Text
$sel:maxResults:GetDocumentAnalysis' :: GetDocumentAnalysis -> Maybe Natural
$sel:nextToken:GetDocumentAnalysis' :: GetDocumentAnalysis -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"JobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId)
          ]
      )

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

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

-- | /See:/ 'newGetDocumentAnalysisResponse' smart constructor.
data GetDocumentAnalysisResponse = GetDocumentAnalysisResponse'
  { -- | Information about a document that Amazon Textract processed.
    -- @DocumentMetadata@ is returned in every page of paginated responses from
    -- an Amazon Textract video operation.
    GetDocumentAnalysisResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
    -- | The results of the text-analysis operation.
    GetDocumentAnalysisResponse -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
    GetDocumentAnalysisResponse -> Maybe Text
analyzeDocumentModelVersion :: Prelude.Maybe Prelude.Text,
    -- | A list of warnings that occurred during the document-analysis operation.
    GetDocumentAnalysisResponse -> Maybe [Warning]
warnings :: Prelude.Maybe [Warning],
    -- | If the response is truncated, Amazon Textract returns this token. You
    -- can use this token in the subsequent request to retrieve the next set of
    -- text detection results.
    GetDocumentAnalysisResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Returns if the detection job could not be completed. Contains
    -- explanation for what error occured.
    GetDocumentAnalysisResponse -> Maybe Text
statusMessage :: Prelude.Maybe Prelude.Text,
    -- | The current status of the text detection job.
    GetDocumentAnalysisResponse -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The response's http status code.
    GetDocumentAnalysisResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDocumentAnalysisResponse -> GetDocumentAnalysisResponse -> Bool
(GetDocumentAnalysisResponse
 -> GetDocumentAnalysisResponse -> Bool)
-> (GetDocumentAnalysisResponse
    -> GetDocumentAnalysisResponse -> Bool)
-> Eq GetDocumentAnalysisResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentAnalysisResponse -> GetDocumentAnalysisResponse -> Bool
$c/= :: GetDocumentAnalysisResponse -> GetDocumentAnalysisResponse -> Bool
== :: GetDocumentAnalysisResponse -> GetDocumentAnalysisResponse -> Bool
$c== :: GetDocumentAnalysisResponse -> GetDocumentAnalysisResponse -> Bool
Prelude.Eq, ReadPrec [GetDocumentAnalysisResponse]
ReadPrec GetDocumentAnalysisResponse
Int -> ReadS GetDocumentAnalysisResponse
ReadS [GetDocumentAnalysisResponse]
(Int -> ReadS GetDocumentAnalysisResponse)
-> ReadS [GetDocumentAnalysisResponse]
-> ReadPrec GetDocumentAnalysisResponse
-> ReadPrec [GetDocumentAnalysisResponse]
-> Read GetDocumentAnalysisResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDocumentAnalysisResponse]
$creadListPrec :: ReadPrec [GetDocumentAnalysisResponse]
readPrec :: ReadPrec GetDocumentAnalysisResponse
$creadPrec :: ReadPrec GetDocumentAnalysisResponse
readList :: ReadS [GetDocumentAnalysisResponse]
$creadList :: ReadS [GetDocumentAnalysisResponse]
readsPrec :: Int -> ReadS GetDocumentAnalysisResponse
$creadsPrec :: Int -> ReadS GetDocumentAnalysisResponse
Prelude.Read, Int -> GetDocumentAnalysisResponse -> ShowS
[GetDocumentAnalysisResponse] -> ShowS
GetDocumentAnalysisResponse -> String
(Int -> GetDocumentAnalysisResponse -> ShowS)
-> (GetDocumentAnalysisResponse -> String)
-> ([GetDocumentAnalysisResponse] -> ShowS)
-> Show GetDocumentAnalysisResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentAnalysisResponse] -> ShowS
$cshowList :: [GetDocumentAnalysisResponse] -> ShowS
show :: GetDocumentAnalysisResponse -> String
$cshow :: GetDocumentAnalysisResponse -> String
showsPrec :: Int -> GetDocumentAnalysisResponse -> ShowS
$cshowsPrec :: Int -> GetDocumentAnalysisResponse -> ShowS
Prelude.Show, (forall x.
 GetDocumentAnalysisResponse -> Rep GetDocumentAnalysisResponse x)
-> (forall x.
    Rep GetDocumentAnalysisResponse x -> GetDocumentAnalysisResponse)
-> Generic GetDocumentAnalysisResponse
forall x.
Rep GetDocumentAnalysisResponse x -> GetDocumentAnalysisResponse
forall x.
GetDocumentAnalysisResponse -> Rep GetDocumentAnalysisResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDocumentAnalysisResponse x -> GetDocumentAnalysisResponse
$cfrom :: forall x.
GetDocumentAnalysisResponse -> Rep GetDocumentAnalysisResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDocumentAnalysisResponse' 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', 'getDocumentAnalysisResponse_documentMetadata' - Information about a document that Amazon Textract processed.
-- @DocumentMetadata@ is returned in every page of paginated responses from
-- an Amazon Textract video operation.
--
-- 'blocks', 'getDocumentAnalysisResponse_blocks' - The results of the text-analysis operation.
--
-- 'analyzeDocumentModelVersion', 'getDocumentAnalysisResponse_analyzeDocumentModelVersion' -
--
-- 'warnings', 'getDocumentAnalysisResponse_warnings' - A list of warnings that occurred during the document-analysis operation.
--
-- 'nextToken', 'getDocumentAnalysisResponse_nextToken' - If the response is truncated, Amazon Textract returns this token. You
-- can use this token in the subsequent request to retrieve the next set of
-- text detection results.
--
-- 'statusMessage', 'getDocumentAnalysisResponse_statusMessage' - Returns if the detection job could not be completed. Contains
-- explanation for what error occured.
--
-- 'jobStatus', 'getDocumentAnalysisResponse_jobStatus' - The current status of the text detection job.
--
-- 'httpStatus', 'getDocumentAnalysisResponse_httpStatus' - The response's http status code.
newGetDocumentAnalysisResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDocumentAnalysisResponse
newGetDocumentAnalysisResponse :: Int -> GetDocumentAnalysisResponse
newGetDocumentAnalysisResponse Int
pHttpStatus_ =
  GetDocumentAnalysisResponse' :: Maybe DocumentMetadata
-> Maybe [Block]
-> Maybe Text
-> Maybe [Warning]
-> Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Int
-> GetDocumentAnalysisResponse
GetDocumentAnalysisResponse'
    { $sel:documentMetadata:GetDocumentAnalysisResponse' :: Maybe DocumentMetadata
documentMetadata =
        Maybe DocumentMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:blocks:GetDocumentAnalysisResponse' :: Maybe [Block]
blocks = Maybe [Block]
forall a. Maybe a
Prelude.Nothing,
      $sel:analyzeDocumentModelVersion:GetDocumentAnalysisResponse' :: Maybe Text
analyzeDocumentModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:warnings:GetDocumentAnalysisResponse' :: Maybe [Warning]
warnings = Maybe [Warning]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetDocumentAnalysisResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusMessage:GetDocumentAnalysisResponse' :: Maybe Text
statusMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:GetDocumentAnalysisResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDocumentAnalysisResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about a document that Amazon Textract processed.
-- @DocumentMetadata@ is returned in every page of paginated responses from
-- an Amazon Textract video operation.
getDocumentAnalysisResponse_documentMetadata :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe DocumentMetadata)
getDocumentAnalysisResponse_documentMetadata :: (Maybe DocumentMetadata -> f (Maybe DocumentMetadata))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_documentMetadata = (GetDocumentAnalysisResponse -> Maybe DocumentMetadata)
-> (GetDocumentAnalysisResponse
    -> Maybe DocumentMetadata -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe DocumentMetadata)
     (Maybe DocumentMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe DocumentMetadata
documentMetadata :: Maybe DocumentMetadata
$sel:documentMetadata:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe DocumentMetadata
documentMetadata} -> Maybe DocumentMetadata
documentMetadata) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe DocumentMetadata
a -> GetDocumentAnalysisResponse
s {$sel:documentMetadata:GetDocumentAnalysisResponse' :: Maybe DocumentMetadata
documentMetadata = Maybe DocumentMetadata
a} :: GetDocumentAnalysisResponse)

-- | The results of the text-analysis operation.
getDocumentAnalysisResponse_blocks :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe [Block])
getDocumentAnalysisResponse_blocks :: (Maybe [Block] -> f (Maybe [Block]))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_blocks = (GetDocumentAnalysisResponse -> Maybe [Block])
-> (GetDocumentAnalysisResponse
    -> Maybe [Block] -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe [Block])
     (Maybe [Block])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe [Block]
blocks :: Maybe [Block]
$sel:blocks:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe [Block]
blocks} -> Maybe [Block]
blocks) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe [Block]
a -> GetDocumentAnalysisResponse
s {$sel:blocks:GetDocumentAnalysisResponse' :: Maybe [Block]
blocks = Maybe [Block]
a} :: GetDocumentAnalysisResponse) ((Maybe [Block] -> f (Maybe [Block]))
 -> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse)
-> ((Maybe [Block] -> f (Maybe [Block]))
    -> Maybe [Block] -> f (Maybe [Block]))
-> (Maybe [Block] -> f (Maybe [Block]))
-> GetDocumentAnalysisResponse
-> f GetDocumentAnalysisResponse
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

-- |
getDocumentAnalysisResponse_analyzeDocumentModelVersion :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe Prelude.Text)
getDocumentAnalysisResponse_analyzeDocumentModelVersion :: (Maybe Text -> f (Maybe Text))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_analyzeDocumentModelVersion = (GetDocumentAnalysisResponse -> Maybe Text)
-> (GetDocumentAnalysisResponse
    -> Maybe Text -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe Text
analyzeDocumentModelVersion :: Maybe Text
$sel:analyzeDocumentModelVersion:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe Text
analyzeDocumentModelVersion} -> Maybe Text
analyzeDocumentModelVersion) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe Text
a -> GetDocumentAnalysisResponse
s {$sel:analyzeDocumentModelVersion:GetDocumentAnalysisResponse' :: Maybe Text
analyzeDocumentModelVersion = Maybe Text
a} :: GetDocumentAnalysisResponse)

-- | A list of warnings that occurred during the document-analysis operation.
getDocumentAnalysisResponse_warnings :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe [Warning])
getDocumentAnalysisResponse_warnings :: (Maybe [Warning] -> f (Maybe [Warning]))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_warnings = (GetDocumentAnalysisResponse -> Maybe [Warning])
-> (GetDocumentAnalysisResponse
    -> Maybe [Warning] -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe [Warning])
     (Maybe [Warning])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe [Warning]
warnings :: Maybe [Warning]
$sel:warnings:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe [Warning]
warnings} -> Maybe [Warning]
warnings) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe [Warning]
a -> GetDocumentAnalysisResponse
s {$sel:warnings:GetDocumentAnalysisResponse' :: Maybe [Warning]
warnings = Maybe [Warning]
a} :: GetDocumentAnalysisResponse) ((Maybe [Warning] -> f (Maybe [Warning]))
 -> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse)
-> ((Maybe [Warning] -> f (Maybe [Warning]))
    -> Maybe [Warning] -> f (Maybe [Warning]))
-> (Maybe [Warning] -> f (Maybe [Warning]))
-> GetDocumentAnalysisResponse
-> f GetDocumentAnalysisResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Warning] [Warning] [Warning] [Warning]
-> Iso
     (Maybe [Warning])
     (Maybe [Warning])
     (Maybe [Warning])
     (Maybe [Warning])
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 [Warning] [Warning] [Warning] [Warning]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the response is truncated, Amazon Textract returns this token. You
-- can use this token in the subsequent request to retrieve the next set of
-- text detection results.
getDocumentAnalysisResponse_nextToken :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe Prelude.Text)
getDocumentAnalysisResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_nextToken = (GetDocumentAnalysisResponse -> Maybe Text)
-> (GetDocumentAnalysisResponse
    -> Maybe Text -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe Text
a -> GetDocumentAnalysisResponse
s {$sel:nextToken:GetDocumentAnalysisResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetDocumentAnalysisResponse)

-- | Returns if the detection job could not be completed. Contains
-- explanation for what error occured.
getDocumentAnalysisResponse_statusMessage :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe Prelude.Text)
getDocumentAnalysisResponse_statusMessage :: (Maybe Text -> f (Maybe Text))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_statusMessage = (GetDocumentAnalysisResponse -> Maybe Text)
-> (GetDocumentAnalysisResponse
    -> Maybe Text -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe Text
statusMessage :: Maybe Text
$sel:statusMessage:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe Text
statusMessage} -> Maybe Text
statusMessage) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe Text
a -> GetDocumentAnalysisResponse
s {$sel:statusMessage:GetDocumentAnalysisResponse' :: Maybe Text
statusMessage = Maybe Text
a} :: GetDocumentAnalysisResponse)

-- | The current status of the text detection job.
getDocumentAnalysisResponse_jobStatus :: Lens.Lens' GetDocumentAnalysisResponse (Prelude.Maybe JobStatus)
getDocumentAnalysisResponse_jobStatus :: (Maybe JobStatus -> f (Maybe JobStatus))
-> GetDocumentAnalysisResponse -> f GetDocumentAnalysisResponse
getDocumentAnalysisResponse_jobStatus = (GetDocumentAnalysisResponse -> Maybe JobStatus)
-> (GetDocumentAnalysisResponse
    -> Maybe JobStatus -> GetDocumentAnalysisResponse)
-> Lens
     GetDocumentAnalysisResponse
     GetDocumentAnalysisResponse
     (Maybe JobStatus)
     (Maybe JobStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentAnalysisResponse' {Maybe JobStatus
jobStatus :: Maybe JobStatus
$sel:jobStatus:GetDocumentAnalysisResponse' :: GetDocumentAnalysisResponse -> Maybe JobStatus
jobStatus} -> Maybe JobStatus
jobStatus) (\s :: GetDocumentAnalysisResponse
s@GetDocumentAnalysisResponse' {} Maybe JobStatus
a -> GetDocumentAnalysisResponse
s {$sel:jobStatus:GetDocumentAnalysisResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
a} :: GetDocumentAnalysisResponse)

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

instance Prelude.NFData GetDocumentAnalysisResponse