{-# 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.GetDocumentTextDetection
-- 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
-- detects text in a document. Amazon Textract can detect lines of text and
-- the words that make up a line of text.
--
-- You start asynchronous text detection by calling
-- StartDocumentTextDetection, which returns a job identifier (@JobId@).
-- When the text detection 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
-- @StartDocumentTextDetection@. 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 @GetDocumentTextDetection@, and pass
-- the job identifier (@JobId@) from the initial call to
-- @StartDocumentTextDetection@.
--
-- @GetDocumentTextDetection@ returns an array of Block objects.
--
-- Each document page has as an associated @Block@ of type PAGE. Each PAGE
-- @Block@ object is the parent of LINE @Block@ objects that represent the
-- lines of detected text on a page. A LINE @Block@ object is a parent for
-- each word that makes up the line. Words are represented by @Block@
-- objects of type WORD.
--
-- 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 @GetDocumentTextDetection@, and populate the @NextToken@
-- request parameter with the token value that\'s returned from the
-- previous call to @GetDocumentTextDetection@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/how-it-works-detecting.html Document Text Detection>.
module Amazonka.Textract.GetDocumentTextDetection
  ( -- * Creating a Request
    GetDocumentTextDetection (..),
    newGetDocumentTextDetection,

    -- * Request Lenses
    getDocumentTextDetection_nextToken,
    getDocumentTextDetection_maxResults,
    getDocumentTextDetection_jobId,

    -- * Destructuring the Response
    GetDocumentTextDetectionResponse (..),
    newGetDocumentTextDetectionResponse,

    -- * Response Lenses
    getDocumentTextDetectionResponse_documentMetadata,
    getDocumentTextDetectionResponse_blocks,
    getDocumentTextDetectionResponse_warnings,
    getDocumentTextDetectionResponse_nextToken,
    getDocumentTextDetectionResponse_statusMessage,
    getDocumentTextDetectionResponse_detectDocumentTextModelVersion,
    getDocumentTextDetectionResponse_jobStatus,
    getDocumentTextDetectionResponse_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:/ 'newGetDocumentTextDetection' smart constructor.
data GetDocumentTextDetection = GetDocumentTextDetection'
  { -- | 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.
    GetDocumentTextDetection -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per paginated call. The largest
    -- value 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.
    GetDocumentTextDetection -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the text detection job. The @JobId@ is returned
    -- from @StartDocumentTextDetection@. A @JobId@ value is only valid for 7
    -- days.
    GetDocumentTextDetection -> Text
jobId :: Prelude.Text
  }
  deriving (GetDocumentTextDetection -> GetDocumentTextDetection -> Bool
(GetDocumentTextDetection -> GetDocumentTextDetection -> Bool)
-> (GetDocumentTextDetection -> GetDocumentTextDetection -> Bool)
-> Eq GetDocumentTextDetection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentTextDetection -> GetDocumentTextDetection -> Bool
$c/= :: GetDocumentTextDetection -> GetDocumentTextDetection -> Bool
== :: GetDocumentTextDetection -> GetDocumentTextDetection -> Bool
$c== :: GetDocumentTextDetection -> GetDocumentTextDetection -> Bool
Prelude.Eq, ReadPrec [GetDocumentTextDetection]
ReadPrec GetDocumentTextDetection
Int -> ReadS GetDocumentTextDetection
ReadS [GetDocumentTextDetection]
(Int -> ReadS GetDocumentTextDetection)
-> ReadS [GetDocumentTextDetection]
-> ReadPrec GetDocumentTextDetection
-> ReadPrec [GetDocumentTextDetection]
-> Read GetDocumentTextDetection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDocumentTextDetection]
$creadListPrec :: ReadPrec [GetDocumentTextDetection]
readPrec :: ReadPrec GetDocumentTextDetection
$creadPrec :: ReadPrec GetDocumentTextDetection
readList :: ReadS [GetDocumentTextDetection]
$creadList :: ReadS [GetDocumentTextDetection]
readsPrec :: Int -> ReadS GetDocumentTextDetection
$creadsPrec :: Int -> ReadS GetDocumentTextDetection
Prelude.Read, Int -> GetDocumentTextDetection -> ShowS
[GetDocumentTextDetection] -> ShowS
GetDocumentTextDetection -> String
(Int -> GetDocumentTextDetection -> ShowS)
-> (GetDocumentTextDetection -> String)
-> ([GetDocumentTextDetection] -> ShowS)
-> Show GetDocumentTextDetection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentTextDetection] -> ShowS
$cshowList :: [GetDocumentTextDetection] -> ShowS
show :: GetDocumentTextDetection -> String
$cshow :: GetDocumentTextDetection -> String
showsPrec :: Int -> GetDocumentTextDetection -> ShowS
$cshowsPrec :: Int -> GetDocumentTextDetection -> ShowS
Prelude.Show, (forall x.
 GetDocumentTextDetection -> Rep GetDocumentTextDetection x)
-> (forall x.
    Rep GetDocumentTextDetection x -> GetDocumentTextDetection)
-> Generic GetDocumentTextDetection
forall x.
Rep GetDocumentTextDetection x -> GetDocumentTextDetection
forall x.
GetDocumentTextDetection -> Rep GetDocumentTextDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDocumentTextDetection x -> GetDocumentTextDetection
$cfrom :: forall x.
GetDocumentTextDetection -> Rep GetDocumentTextDetection x
Prelude.Generic)

-- |
-- Create a value of 'GetDocumentTextDetection' 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', 'getDocumentTextDetection_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', 'getDocumentTextDetection_maxResults' - The maximum number of results to return per paginated call. The largest
-- value 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', 'getDocumentTextDetection_jobId' - A unique identifier for the text detection job. The @JobId@ is returned
-- from @StartDocumentTextDetection@. A @JobId@ value is only valid for 7
-- days.
newGetDocumentTextDetection ::
  -- | 'jobId'
  Prelude.Text ->
  GetDocumentTextDetection
newGetDocumentTextDetection :: Text -> GetDocumentTextDetection
newGetDocumentTextDetection Text
pJobId_ =
  GetDocumentTextDetection' :: Maybe Text -> Maybe Natural -> Text -> GetDocumentTextDetection
GetDocumentTextDetection'
    { $sel:nextToken:GetDocumentTextDetection' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetDocumentTextDetection' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:GetDocumentTextDetection' :: 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.
getDocumentTextDetection_nextToken :: Lens.Lens' GetDocumentTextDetection (Prelude.Maybe Prelude.Text)
getDocumentTextDetection_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDocumentTextDetection -> f GetDocumentTextDetection
getDocumentTextDetection_nextToken = (GetDocumentTextDetection -> Maybe Text)
-> (GetDocumentTextDetection
    -> Maybe Text -> GetDocumentTextDetection)
-> Lens
     GetDocumentTextDetection
     GetDocumentTextDetection
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentTextDetection' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDocumentTextDetection' :: GetDocumentTextDetection -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDocumentTextDetection
s@GetDocumentTextDetection' {} Maybe Text
a -> GetDocumentTextDetection
s {$sel:nextToken:GetDocumentTextDetection' :: Maybe Text
nextToken = Maybe Text
a} :: GetDocumentTextDetection)

-- | The maximum number of results to return per paginated call. The largest
-- value 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.
getDocumentTextDetection_maxResults :: Lens.Lens' GetDocumentTextDetection (Prelude.Maybe Prelude.Natural)
getDocumentTextDetection_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetDocumentTextDetection -> f GetDocumentTextDetection
getDocumentTextDetection_maxResults = (GetDocumentTextDetection -> Maybe Natural)
-> (GetDocumentTextDetection
    -> Maybe Natural -> GetDocumentTextDetection)
-> Lens
     GetDocumentTextDetection
     GetDocumentTextDetection
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentTextDetection' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetDocumentTextDetection' :: GetDocumentTextDetection -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetDocumentTextDetection
s@GetDocumentTextDetection' {} Maybe Natural
a -> GetDocumentTextDetection
s {$sel:maxResults:GetDocumentTextDetection' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetDocumentTextDetection)

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

instance Core.AWSRequest GetDocumentTextDetection where
  type
    AWSResponse GetDocumentTextDetection =
      GetDocumentTextDetectionResponse
  request :: GetDocumentTextDetection -> Request GetDocumentTextDetection
request = Service
-> GetDocumentTextDetection -> Request GetDocumentTextDetection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDocumentTextDetection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDocumentTextDetection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDocumentTextDetection))
-> Logger
-> Service
-> Proxy GetDocumentTextDetection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDocumentTextDetection)))
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 [Warning]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Int
-> GetDocumentTextDetectionResponse
GetDocumentTextDetectionResponse'
            (Maybe DocumentMetadata
 -> Maybe [Block]
 -> Maybe [Warning]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe JobStatus
 -> Int
 -> GetDocumentTextDetectionResponse)
-> Either String (Maybe DocumentMetadata)
-> Either
     String
     (Maybe [Block]
      -> Maybe [Warning]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentTextDetectionResponse)
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 [Warning]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentTextDetectionResponse)
-> Either String (Maybe [Block])
-> Either
     String
     (Maybe [Warning]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentTextDetectionResponse)
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 [Warning]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentTextDetectionResponse)
-> Either String (Maybe [Warning])
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentTextDetectionResponse)
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 Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentTextDetectionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe JobStatus
      -> Int
      -> GetDocumentTextDetectionResponse)
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 Text
   -> Maybe JobStatus
   -> Int
   -> GetDocumentTextDetectionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe JobStatus -> Int -> GetDocumentTextDetectionResponse)
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 Text
   -> Maybe JobStatus -> Int -> GetDocumentTextDetectionResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe JobStatus -> Int -> GetDocumentTextDetectionResponse)
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
"DetectDocumentTextModelVersion")
            Either
  String (Maybe JobStatus -> Int -> GetDocumentTextDetectionResponse)
-> Either String (Maybe JobStatus)
-> Either String (Int -> GetDocumentTextDetectionResponse)
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 -> GetDocumentTextDetectionResponse)
-> Either String Int
-> Either String GetDocumentTextDetectionResponse
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 GetDocumentTextDetection

instance Prelude.NFData GetDocumentTextDetection

instance Core.ToHeaders GetDocumentTextDetection where
  toHeaders :: GetDocumentTextDetection -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDocumentTextDetection -> 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.GetDocumentTextDetection" ::
                          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 GetDocumentTextDetection where
  toJSON :: GetDocumentTextDetection -> Value
toJSON GetDocumentTextDetection' {Maybe Natural
Maybe Text
Text
jobId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:jobId:GetDocumentTextDetection' :: GetDocumentTextDetection -> Text
$sel:maxResults:GetDocumentTextDetection' :: GetDocumentTextDetection -> Maybe Natural
$sel:nextToken:GetDocumentTextDetection' :: GetDocumentTextDetection -> 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 GetDocumentTextDetection where
  toPath :: GetDocumentTextDetection -> ByteString
toPath = ByteString -> GetDocumentTextDetection -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetDocumentTextDetectionResponse' 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', 'getDocumentTextDetectionResponse_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', 'getDocumentTextDetectionResponse_blocks' - The results of the text-detection operation.
--
-- 'warnings', 'getDocumentTextDetectionResponse_warnings' - A list of warnings that occurred during the text-detection operation for
-- the document.
--
-- 'nextToken', 'getDocumentTextDetectionResponse_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', 'getDocumentTextDetectionResponse_statusMessage' - Returns if the detection job could not be completed. Contains
-- explanation for what error occured.
--
-- 'detectDocumentTextModelVersion', 'getDocumentTextDetectionResponse_detectDocumentTextModelVersion' -
--
-- 'jobStatus', 'getDocumentTextDetectionResponse_jobStatus' - The current status of the text detection job.
--
-- 'httpStatus', 'getDocumentTextDetectionResponse_httpStatus' - The response's http status code.
newGetDocumentTextDetectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDocumentTextDetectionResponse
newGetDocumentTextDetectionResponse :: Int -> GetDocumentTextDetectionResponse
newGetDocumentTextDetectionResponse Int
pHttpStatus_ =
  GetDocumentTextDetectionResponse' :: Maybe DocumentMetadata
-> Maybe [Block]
-> Maybe [Warning]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Int
-> GetDocumentTextDetectionResponse
GetDocumentTextDetectionResponse'
    { $sel:documentMetadata:GetDocumentTextDetectionResponse' :: Maybe DocumentMetadata
documentMetadata =
        Maybe DocumentMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:blocks:GetDocumentTextDetectionResponse' :: Maybe [Block]
blocks = Maybe [Block]
forall a. Maybe a
Prelude.Nothing,
      $sel:warnings:GetDocumentTextDetectionResponse' :: Maybe [Warning]
warnings = Maybe [Warning]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetDocumentTextDetectionResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusMessage:GetDocumentTextDetectionResponse' :: Maybe Text
statusMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectDocumentTextModelVersion:GetDocumentTextDetectionResponse' :: Maybe Text
detectDocumentTextModelVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:GetDocumentTextDetectionResponse' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDocumentTextDetectionResponse' :: 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.
getDocumentTextDetectionResponse_documentMetadata :: Lens.Lens' GetDocumentTextDetectionResponse (Prelude.Maybe DocumentMetadata)
getDocumentTextDetectionResponse_documentMetadata :: (Maybe DocumentMetadata -> f (Maybe DocumentMetadata))
-> GetDocumentTextDetectionResponse
-> f GetDocumentTextDetectionResponse
getDocumentTextDetectionResponse_documentMetadata = (GetDocumentTextDetectionResponse -> Maybe DocumentMetadata)
-> (GetDocumentTextDetectionResponse
    -> Maybe DocumentMetadata -> GetDocumentTextDetectionResponse)
-> Lens
     GetDocumentTextDetectionResponse
     GetDocumentTextDetectionResponse
     (Maybe DocumentMetadata)
     (Maybe DocumentMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentTextDetectionResponse' {Maybe DocumentMetadata
documentMetadata :: Maybe DocumentMetadata
$sel:documentMetadata:GetDocumentTextDetectionResponse' :: GetDocumentTextDetectionResponse -> Maybe DocumentMetadata
documentMetadata} -> Maybe DocumentMetadata
documentMetadata) (\s :: GetDocumentTextDetectionResponse
s@GetDocumentTextDetectionResponse' {} Maybe DocumentMetadata
a -> GetDocumentTextDetectionResponse
s {$sel:documentMetadata:GetDocumentTextDetectionResponse' :: Maybe DocumentMetadata
documentMetadata = Maybe DocumentMetadata
a} :: GetDocumentTextDetectionResponse)

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

-- | A list of warnings that occurred during the text-detection operation for
-- the document.
getDocumentTextDetectionResponse_warnings :: Lens.Lens' GetDocumentTextDetectionResponse (Prelude.Maybe [Warning])
getDocumentTextDetectionResponse_warnings :: (Maybe [Warning] -> f (Maybe [Warning]))
-> GetDocumentTextDetectionResponse
-> f GetDocumentTextDetectionResponse
getDocumentTextDetectionResponse_warnings = (GetDocumentTextDetectionResponse -> Maybe [Warning])
-> (GetDocumentTextDetectionResponse
    -> Maybe [Warning] -> GetDocumentTextDetectionResponse)
-> Lens
     GetDocumentTextDetectionResponse
     GetDocumentTextDetectionResponse
     (Maybe [Warning])
     (Maybe [Warning])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentTextDetectionResponse' {Maybe [Warning]
warnings :: Maybe [Warning]
$sel:warnings:GetDocumentTextDetectionResponse' :: GetDocumentTextDetectionResponse -> Maybe [Warning]
warnings} -> Maybe [Warning]
warnings) (\s :: GetDocumentTextDetectionResponse
s@GetDocumentTextDetectionResponse' {} Maybe [Warning]
a -> GetDocumentTextDetectionResponse
s {$sel:warnings:GetDocumentTextDetectionResponse' :: Maybe [Warning]
warnings = Maybe [Warning]
a} :: GetDocumentTextDetectionResponse) ((Maybe [Warning] -> f (Maybe [Warning]))
 -> GetDocumentTextDetectionResponse
 -> f GetDocumentTextDetectionResponse)
-> ((Maybe [Warning] -> f (Maybe [Warning]))
    -> Maybe [Warning] -> f (Maybe [Warning]))
-> (Maybe [Warning] -> f (Maybe [Warning]))
-> GetDocumentTextDetectionResponse
-> f GetDocumentTextDetectionResponse
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.
getDocumentTextDetectionResponse_nextToken :: Lens.Lens' GetDocumentTextDetectionResponse (Prelude.Maybe Prelude.Text)
getDocumentTextDetectionResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDocumentTextDetectionResponse
-> f GetDocumentTextDetectionResponse
getDocumentTextDetectionResponse_nextToken = (GetDocumentTextDetectionResponse -> Maybe Text)
-> (GetDocumentTextDetectionResponse
    -> Maybe Text -> GetDocumentTextDetectionResponse)
-> Lens
     GetDocumentTextDetectionResponse
     GetDocumentTextDetectionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentTextDetectionResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDocumentTextDetectionResponse' :: GetDocumentTextDetectionResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDocumentTextDetectionResponse
s@GetDocumentTextDetectionResponse' {} Maybe Text
a -> GetDocumentTextDetectionResponse
s {$sel:nextToken:GetDocumentTextDetectionResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetDocumentTextDetectionResponse)

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

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

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

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

instance
  Prelude.NFData
    GetDocumentTextDetectionResponse