{-# 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.StartDocumentAnalysis
-- 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)
--
-- Starts the asynchronous analysis of an input document for relationships
-- between detected items such as key-value pairs, tables, and selection
-- elements.
--
-- @StartDocumentAnalysis@ can analyze text in documents that are in JPEG,
-- PNG, and PDF format. The documents are stored in an Amazon S3 bucket.
-- Use DocumentLocation to specify the bucket name and file name of the
-- document.
--
-- @StartDocumentAnalysis@ returns a job identifier (@JobId@) that you use
-- to get the results of the operation. When text analysis is finished,
-- Amazon Textract publishes a completion status to the Amazon Simple
-- Notification Service (Amazon SNS) topic that you specify in
-- @NotificationChannel@. To get the results of the text analysis
-- 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@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html Document Text Analysis>.
module Amazonka.Textract.StartDocumentAnalysis
  ( -- * Creating a Request
    StartDocumentAnalysis (..),
    newStartDocumentAnalysis,

    -- * Request Lenses
    startDocumentAnalysis_jobTag,
    startDocumentAnalysis_notificationChannel,
    startDocumentAnalysis_kmsKeyId,
    startDocumentAnalysis_outputConfig,
    startDocumentAnalysis_clientRequestToken,
    startDocumentAnalysis_documentLocation,
    startDocumentAnalysis_featureTypes,

    -- * Destructuring the Response
    StartDocumentAnalysisResponse (..),
    newStartDocumentAnalysisResponse,

    -- * Response Lenses
    startDocumentAnalysisResponse_jobId,
    startDocumentAnalysisResponse_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:/ 'newStartDocumentAnalysis' smart constructor.
data StartDocumentAnalysis = StartDocumentAnalysis'
  { -- | An identifier that you specify that\'s included in the completion
    -- notification published to the Amazon SNS topic. For example, you can use
    -- @JobTag@ to identify the type of document that the completion
    -- notification corresponds to (such as a tax form or a receipt).
    StartDocumentAnalysis -> Maybe Text
jobTag :: Prelude.Maybe Prelude.Text,
    -- | The Amazon SNS topic ARN that you want Amazon Textract to publish the
    -- completion status of the operation to.
    StartDocumentAnalysis -> Maybe NotificationChannel
notificationChannel :: Prelude.Maybe NotificationChannel,
    -- | The KMS key used to encrypt the inference results. This can be in either
    -- Key ID or Key Alias format. When a KMS key is provided, the KMS key will
    -- be used for server-side encryption of the objects in the customer
    -- bucket. When this parameter is not enabled, the result will be encrypted
    -- server side,using SSE-S3.
    StartDocumentAnalysis -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | Sets if the output will go to a customer defined bucket. By default,
    -- Amazon Textract will save the results internally to be accessed by the
    -- GetDocumentAnalysis operation.
    StartDocumentAnalysis -> Maybe OutputConfig
outputConfig :: Prelude.Maybe OutputConfig,
    -- | The idempotent token that you use to identify the start request. If you
    -- use the same token with multiple @StartDocumentAnalysis@ requests, the
    -- same @JobId@ is returned. Use @ClientRequestToken@ to prevent the same
    -- job from being accidentally started more than once. For more
    -- information, see
    -- <https://docs.aws.amazon.com/textract/latest/dg/api-async.html Calling Amazon Textract Asynchronous Operations>.
    StartDocumentAnalysis -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The location of the document to be processed.
    StartDocumentAnalysis -> DocumentLocation
documentLocation :: DocumentLocation,
    -- | 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@).
    StartDocumentAnalysis -> [FeatureType]
featureTypes :: [FeatureType]
  }
  deriving (StartDocumentAnalysis -> StartDocumentAnalysis -> Bool
(StartDocumentAnalysis -> StartDocumentAnalysis -> Bool)
-> (StartDocumentAnalysis -> StartDocumentAnalysis -> Bool)
-> Eq StartDocumentAnalysis
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDocumentAnalysis -> StartDocumentAnalysis -> Bool
$c/= :: StartDocumentAnalysis -> StartDocumentAnalysis -> Bool
== :: StartDocumentAnalysis -> StartDocumentAnalysis -> Bool
$c== :: StartDocumentAnalysis -> StartDocumentAnalysis -> Bool
Prelude.Eq, ReadPrec [StartDocumentAnalysis]
ReadPrec StartDocumentAnalysis
Int -> ReadS StartDocumentAnalysis
ReadS [StartDocumentAnalysis]
(Int -> ReadS StartDocumentAnalysis)
-> ReadS [StartDocumentAnalysis]
-> ReadPrec StartDocumentAnalysis
-> ReadPrec [StartDocumentAnalysis]
-> Read StartDocumentAnalysis
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDocumentAnalysis]
$creadListPrec :: ReadPrec [StartDocumentAnalysis]
readPrec :: ReadPrec StartDocumentAnalysis
$creadPrec :: ReadPrec StartDocumentAnalysis
readList :: ReadS [StartDocumentAnalysis]
$creadList :: ReadS [StartDocumentAnalysis]
readsPrec :: Int -> ReadS StartDocumentAnalysis
$creadsPrec :: Int -> ReadS StartDocumentAnalysis
Prelude.Read, Int -> StartDocumentAnalysis -> ShowS
[StartDocumentAnalysis] -> ShowS
StartDocumentAnalysis -> String
(Int -> StartDocumentAnalysis -> ShowS)
-> (StartDocumentAnalysis -> String)
-> ([StartDocumentAnalysis] -> ShowS)
-> Show StartDocumentAnalysis
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDocumentAnalysis] -> ShowS
$cshowList :: [StartDocumentAnalysis] -> ShowS
show :: StartDocumentAnalysis -> String
$cshow :: StartDocumentAnalysis -> String
showsPrec :: Int -> StartDocumentAnalysis -> ShowS
$cshowsPrec :: Int -> StartDocumentAnalysis -> ShowS
Prelude.Show, (forall x. StartDocumentAnalysis -> Rep StartDocumentAnalysis x)
-> (forall x. Rep StartDocumentAnalysis x -> StartDocumentAnalysis)
-> Generic StartDocumentAnalysis
forall x. Rep StartDocumentAnalysis x -> StartDocumentAnalysis
forall x. StartDocumentAnalysis -> Rep StartDocumentAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartDocumentAnalysis x -> StartDocumentAnalysis
$cfrom :: forall x. StartDocumentAnalysis -> Rep StartDocumentAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'StartDocumentAnalysis' 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:
--
-- 'jobTag', 'startDocumentAnalysis_jobTag' - An identifier that you specify that\'s included in the completion
-- notification published to the Amazon SNS topic. For example, you can use
-- @JobTag@ to identify the type of document that the completion
-- notification corresponds to (such as a tax form or a receipt).
--
-- 'notificationChannel', 'startDocumentAnalysis_notificationChannel' - The Amazon SNS topic ARN that you want Amazon Textract to publish the
-- completion status of the operation to.
--
-- 'kmsKeyId', 'startDocumentAnalysis_kmsKeyId' - The KMS key used to encrypt the inference results. This can be in either
-- Key ID or Key Alias format. When a KMS key is provided, the KMS key will
-- be used for server-side encryption of the objects in the customer
-- bucket. When this parameter is not enabled, the result will be encrypted
-- server side,using SSE-S3.
--
-- 'outputConfig', 'startDocumentAnalysis_outputConfig' - Sets if the output will go to a customer defined bucket. By default,
-- Amazon Textract will save the results internally to be accessed by the
-- GetDocumentAnalysis operation.
--
-- 'clientRequestToken', 'startDocumentAnalysis_clientRequestToken' - The idempotent token that you use to identify the start request. If you
-- use the same token with multiple @StartDocumentAnalysis@ requests, the
-- same @JobId@ is returned. Use @ClientRequestToken@ to prevent the same
-- job from being accidentally started more than once. For more
-- information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/api-async.html Calling Amazon Textract Asynchronous Operations>.
--
-- 'documentLocation', 'startDocumentAnalysis_documentLocation' - The location of the document to be processed.
--
-- 'featureTypes', 'startDocumentAnalysis_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@).
newStartDocumentAnalysis ::
  -- | 'documentLocation'
  DocumentLocation ->
  StartDocumentAnalysis
newStartDocumentAnalysis :: DocumentLocation -> StartDocumentAnalysis
newStartDocumentAnalysis DocumentLocation
pDocumentLocation_ =
  StartDocumentAnalysis' :: Maybe Text
-> Maybe NotificationChannel
-> Maybe Text
-> Maybe OutputConfig
-> Maybe Text
-> DocumentLocation
-> [FeatureType]
-> StartDocumentAnalysis
StartDocumentAnalysis'
    { $sel:jobTag:StartDocumentAnalysis' :: Maybe Text
jobTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notificationChannel:StartDocumentAnalysis' :: Maybe NotificationChannel
notificationChannel = Maybe NotificationChannel
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:StartDocumentAnalysis' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputConfig:StartDocumentAnalysis' :: Maybe OutputConfig
outputConfig = Maybe OutputConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:clientRequestToken:StartDocumentAnalysis' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:documentLocation:StartDocumentAnalysis' :: DocumentLocation
documentLocation = DocumentLocation
pDocumentLocation_,
      $sel:featureTypes:StartDocumentAnalysis' :: [FeatureType]
featureTypes = [FeatureType]
forall a. Monoid a => a
Prelude.mempty
    }

-- | An identifier that you specify that\'s included in the completion
-- notification published to the Amazon SNS topic. For example, you can use
-- @JobTag@ to identify the type of document that the completion
-- notification corresponds to (such as a tax form or a receipt).
startDocumentAnalysis_jobTag :: Lens.Lens' StartDocumentAnalysis (Prelude.Maybe Prelude.Text)
startDocumentAnalysis_jobTag :: (Maybe Text -> f (Maybe Text))
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_jobTag = (StartDocumentAnalysis -> Maybe Text)
-> (StartDocumentAnalysis -> Maybe Text -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {Maybe Text
jobTag :: Maybe Text
$sel:jobTag:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
jobTag} -> Maybe Text
jobTag) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} Maybe Text
a -> StartDocumentAnalysis
s {$sel:jobTag:StartDocumentAnalysis' :: Maybe Text
jobTag = Maybe Text
a} :: StartDocumentAnalysis)

-- | The Amazon SNS topic ARN that you want Amazon Textract to publish the
-- completion status of the operation to.
startDocumentAnalysis_notificationChannel :: Lens.Lens' StartDocumentAnalysis (Prelude.Maybe NotificationChannel)
startDocumentAnalysis_notificationChannel :: (Maybe NotificationChannel -> f (Maybe NotificationChannel))
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_notificationChannel = (StartDocumentAnalysis -> Maybe NotificationChannel)
-> (StartDocumentAnalysis
    -> Maybe NotificationChannel -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     (Maybe NotificationChannel)
     (Maybe NotificationChannel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {Maybe NotificationChannel
notificationChannel :: Maybe NotificationChannel
$sel:notificationChannel:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe NotificationChannel
notificationChannel} -> Maybe NotificationChannel
notificationChannel) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} Maybe NotificationChannel
a -> StartDocumentAnalysis
s {$sel:notificationChannel:StartDocumentAnalysis' :: Maybe NotificationChannel
notificationChannel = Maybe NotificationChannel
a} :: StartDocumentAnalysis)

-- | The KMS key used to encrypt the inference results. This can be in either
-- Key ID or Key Alias format. When a KMS key is provided, the KMS key will
-- be used for server-side encryption of the objects in the customer
-- bucket. When this parameter is not enabled, the result will be encrypted
-- server side,using SSE-S3.
startDocumentAnalysis_kmsKeyId :: Lens.Lens' StartDocumentAnalysis (Prelude.Maybe Prelude.Text)
startDocumentAnalysis_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_kmsKeyId = (StartDocumentAnalysis -> Maybe Text)
-> (StartDocumentAnalysis -> Maybe Text -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} Maybe Text
a -> StartDocumentAnalysis
s {$sel:kmsKeyId:StartDocumentAnalysis' :: Maybe Text
kmsKeyId = Maybe Text
a} :: StartDocumentAnalysis)

-- | Sets if the output will go to a customer defined bucket. By default,
-- Amazon Textract will save the results internally to be accessed by the
-- GetDocumentAnalysis operation.
startDocumentAnalysis_outputConfig :: Lens.Lens' StartDocumentAnalysis (Prelude.Maybe OutputConfig)
startDocumentAnalysis_outputConfig :: (Maybe OutputConfig -> f (Maybe OutputConfig))
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_outputConfig = (StartDocumentAnalysis -> Maybe OutputConfig)
-> (StartDocumentAnalysis
    -> Maybe OutputConfig -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     (Maybe OutputConfig)
     (Maybe OutputConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {Maybe OutputConfig
outputConfig :: Maybe OutputConfig
$sel:outputConfig:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe OutputConfig
outputConfig} -> Maybe OutputConfig
outputConfig) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} Maybe OutputConfig
a -> StartDocumentAnalysis
s {$sel:outputConfig:StartDocumentAnalysis' :: Maybe OutputConfig
outputConfig = Maybe OutputConfig
a} :: StartDocumentAnalysis)

-- | The idempotent token that you use to identify the start request. If you
-- use the same token with multiple @StartDocumentAnalysis@ requests, the
-- same @JobId@ is returned. Use @ClientRequestToken@ to prevent the same
-- job from being accidentally started more than once. For more
-- information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/api-async.html Calling Amazon Textract Asynchronous Operations>.
startDocumentAnalysis_clientRequestToken :: Lens.Lens' StartDocumentAnalysis (Prelude.Maybe Prelude.Text)
startDocumentAnalysis_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_clientRequestToken = (StartDocumentAnalysis -> Maybe Text)
-> (StartDocumentAnalysis -> Maybe Text -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} Maybe Text
a -> StartDocumentAnalysis
s {$sel:clientRequestToken:StartDocumentAnalysis' :: Maybe Text
clientRequestToken = Maybe Text
a} :: StartDocumentAnalysis)

-- | The location of the document to be processed.
startDocumentAnalysis_documentLocation :: Lens.Lens' StartDocumentAnalysis DocumentLocation
startDocumentAnalysis_documentLocation :: (DocumentLocation -> f DocumentLocation)
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_documentLocation = (StartDocumentAnalysis -> DocumentLocation)
-> (StartDocumentAnalysis
    -> DocumentLocation -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     DocumentLocation
     DocumentLocation
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {DocumentLocation
documentLocation :: DocumentLocation
$sel:documentLocation:StartDocumentAnalysis' :: StartDocumentAnalysis -> DocumentLocation
documentLocation} -> DocumentLocation
documentLocation) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} DocumentLocation
a -> StartDocumentAnalysis
s {$sel:documentLocation:StartDocumentAnalysis' :: DocumentLocation
documentLocation = DocumentLocation
a} :: StartDocumentAnalysis)

-- | 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@).
startDocumentAnalysis_featureTypes :: Lens.Lens' StartDocumentAnalysis [FeatureType]
startDocumentAnalysis_featureTypes :: ([FeatureType] -> f [FeatureType])
-> StartDocumentAnalysis -> f StartDocumentAnalysis
startDocumentAnalysis_featureTypes = (StartDocumentAnalysis -> [FeatureType])
-> (StartDocumentAnalysis
    -> [FeatureType] -> StartDocumentAnalysis)
-> Lens
     StartDocumentAnalysis
     StartDocumentAnalysis
     [FeatureType]
     [FeatureType]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysis' {[FeatureType]
featureTypes :: [FeatureType]
$sel:featureTypes:StartDocumentAnalysis' :: StartDocumentAnalysis -> [FeatureType]
featureTypes} -> [FeatureType]
featureTypes) (\s :: StartDocumentAnalysis
s@StartDocumentAnalysis' {} [FeatureType]
a -> StartDocumentAnalysis
s {$sel:featureTypes:StartDocumentAnalysis' :: [FeatureType]
featureTypes = [FeatureType]
a} :: StartDocumentAnalysis) (([FeatureType] -> f [FeatureType])
 -> StartDocumentAnalysis -> f StartDocumentAnalysis)
-> (([FeatureType] -> f [FeatureType])
    -> [FeatureType] -> f [FeatureType])
-> ([FeatureType] -> f [FeatureType])
-> StartDocumentAnalysis
-> f StartDocumentAnalysis
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 StartDocumentAnalysis where
  type
    AWSResponse StartDocumentAnalysis =
      StartDocumentAnalysisResponse
  request :: StartDocumentAnalysis -> Request StartDocumentAnalysis
request = Service -> StartDocumentAnalysis -> Request StartDocumentAnalysis
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartDocumentAnalysis
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartDocumentAnalysis)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartDocumentAnalysis))
-> Logger
-> Service
-> Proxy StartDocumentAnalysis
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartDocumentAnalysis)))
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 Text -> Int -> StartDocumentAnalysisResponse
StartDocumentAnalysisResponse'
            (Maybe Text -> Int -> StartDocumentAnalysisResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StartDocumentAnalysisResponse)
forall (f :: * -> *) a b. Functor 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
"JobId")
            Either String (Int -> StartDocumentAnalysisResponse)
-> Either String Int -> Either String StartDocumentAnalysisResponse
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 StartDocumentAnalysis

instance Prelude.NFData StartDocumentAnalysis

instance Core.ToHeaders StartDocumentAnalysis where
  toHeaders :: StartDocumentAnalysis -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartDocumentAnalysis -> 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.StartDocumentAnalysis" ::
                          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 StartDocumentAnalysis where
  toJSON :: StartDocumentAnalysis -> Value
toJSON StartDocumentAnalysis' {[FeatureType]
Maybe Text
Maybe NotificationChannel
Maybe OutputConfig
DocumentLocation
featureTypes :: [FeatureType]
documentLocation :: DocumentLocation
clientRequestToken :: Maybe Text
outputConfig :: Maybe OutputConfig
kmsKeyId :: Maybe Text
notificationChannel :: Maybe NotificationChannel
jobTag :: Maybe Text
$sel:featureTypes:StartDocumentAnalysis' :: StartDocumentAnalysis -> [FeatureType]
$sel:documentLocation:StartDocumentAnalysis' :: StartDocumentAnalysis -> DocumentLocation
$sel:clientRequestToken:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
$sel:outputConfig:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe OutputConfig
$sel:kmsKeyId:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
$sel:notificationChannel:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe NotificationChannel
$sel:jobTag:StartDocumentAnalysis' :: StartDocumentAnalysis -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"JobTag" 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
jobTag,
            (Text
"NotificationChannel" Text -> NotificationChannel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NotificationChannel -> Pair)
-> Maybe NotificationChannel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotificationChannel
notificationChannel,
            (Text
"KMSKeyId" 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
kmsKeyId,
            (Text
"OutputConfig" Text -> OutputConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OutputConfig -> Pair) -> Maybe OutputConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OutputConfig
outputConfig,
            (Text
"ClientRequestToken" 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
clientRequestToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DocumentLocation" Text -> DocumentLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DocumentLocation
documentLocation),
            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 StartDocumentAnalysis where
  toPath :: StartDocumentAnalysis -> ByteString
toPath = ByteString -> StartDocumentAnalysis -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newStartDocumentAnalysisResponse' smart constructor.
data StartDocumentAnalysisResponse = StartDocumentAnalysisResponse'
  { -- | The identifier for the document text detection job. Use @JobId@ to
    -- identify the job in a subsequent call to @GetDocumentAnalysis@. A
    -- @JobId@ value is only valid for 7 days.
    StartDocumentAnalysisResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartDocumentAnalysisResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartDocumentAnalysisResponse
-> StartDocumentAnalysisResponse -> Bool
(StartDocumentAnalysisResponse
 -> StartDocumentAnalysisResponse -> Bool)
-> (StartDocumentAnalysisResponse
    -> StartDocumentAnalysisResponse -> Bool)
-> Eq StartDocumentAnalysisResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDocumentAnalysisResponse
-> StartDocumentAnalysisResponse -> Bool
$c/= :: StartDocumentAnalysisResponse
-> StartDocumentAnalysisResponse -> Bool
== :: StartDocumentAnalysisResponse
-> StartDocumentAnalysisResponse -> Bool
$c== :: StartDocumentAnalysisResponse
-> StartDocumentAnalysisResponse -> Bool
Prelude.Eq, ReadPrec [StartDocumentAnalysisResponse]
ReadPrec StartDocumentAnalysisResponse
Int -> ReadS StartDocumentAnalysisResponse
ReadS [StartDocumentAnalysisResponse]
(Int -> ReadS StartDocumentAnalysisResponse)
-> ReadS [StartDocumentAnalysisResponse]
-> ReadPrec StartDocumentAnalysisResponse
-> ReadPrec [StartDocumentAnalysisResponse]
-> Read StartDocumentAnalysisResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDocumentAnalysisResponse]
$creadListPrec :: ReadPrec [StartDocumentAnalysisResponse]
readPrec :: ReadPrec StartDocumentAnalysisResponse
$creadPrec :: ReadPrec StartDocumentAnalysisResponse
readList :: ReadS [StartDocumentAnalysisResponse]
$creadList :: ReadS [StartDocumentAnalysisResponse]
readsPrec :: Int -> ReadS StartDocumentAnalysisResponse
$creadsPrec :: Int -> ReadS StartDocumentAnalysisResponse
Prelude.Read, Int -> StartDocumentAnalysisResponse -> ShowS
[StartDocumentAnalysisResponse] -> ShowS
StartDocumentAnalysisResponse -> String
(Int -> StartDocumentAnalysisResponse -> ShowS)
-> (StartDocumentAnalysisResponse -> String)
-> ([StartDocumentAnalysisResponse] -> ShowS)
-> Show StartDocumentAnalysisResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDocumentAnalysisResponse] -> ShowS
$cshowList :: [StartDocumentAnalysisResponse] -> ShowS
show :: StartDocumentAnalysisResponse -> String
$cshow :: StartDocumentAnalysisResponse -> String
showsPrec :: Int -> StartDocumentAnalysisResponse -> ShowS
$cshowsPrec :: Int -> StartDocumentAnalysisResponse -> ShowS
Prelude.Show, (forall x.
 StartDocumentAnalysisResponse
 -> Rep StartDocumentAnalysisResponse x)
-> (forall x.
    Rep StartDocumentAnalysisResponse x
    -> StartDocumentAnalysisResponse)
-> Generic StartDocumentAnalysisResponse
forall x.
Rep StartDocumentAnalysisResponse x
-> StartDocumentAnalysisResponse
forall x.
StartDocumentAnalysisResponse
-> Rep StartDocumentAnalysisResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartDocumentAnalysisResponse x
-> StartDocumentAnalysisResponse
$cfrom :: forall x.
StartDocumentAnalysisResponse
-> Rep StartDocumentAnalysisResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartDocumentAnalysisResponse' 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:
--
-- 'jobId', 'startDocumentAnalysisResponse_jobId' - The identifier for the document text detection job. Use @JobId@ to
-- identify the job in a subsequent call to @GetDocumentAnalysis@. A
-- @JobId@ value is only valid for 7 days.
--
-- 'httpStatus', 'startDocumentAnalysisResponse_httpStatus' - The response's http status code.
newStartDocumentAnalysisResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartDocumentAnalysisResponse
newStartDocumentAnalysisResponse :: Int -> StartDocumentAnalysisResponse
newStartDocumentAnalysisResponse Int
pHttpStatus_ =
  StartDocumentAnalysisResponse' :: Maybe Text -> Int -> StartDocumentAnalysisResponse
StartDocumentAnalysisResponse'
    { $sel:jobId:StartDocumentAnalysisResponse' :: Maybe Text
jobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartDocumentAnalysisResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier for the document text detection job. Use @JobId@ to
-- identify the job in a subsequent call to @GetDocumentAnalysis@. A
-- @JobId@ value is only valid for 7 days.
startDocumentAnalysisResponse_jobId :: Lens.Lens' StartDocumentAnalysisResponse (Prelude.Maybe Prelude.Text)
startDocumentAnalysisResponse_jobId :: (Maybe Text -> f (Maybe Text))
-> StartDocumentAnalysisResponse -> f StartDocumentAnalysisResponse
startDocumentAnalysisResponse_jobId = (StartDocumentAnalysisResponse -> Maybe Text)
-> (StartDocumentAnalysisResponse
    -> Maybe Text -> StartDocumentAnalysisResponse)
-> Lens
     StartDocumentAnalysisResponse
     StartDocumentAnalysisResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDocumentAnalysisResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:StartDocumentAnalysisResponse' :: StartDocumentAnalysisResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: StartDocumentAnalysisResponse
s@StartDocumentAnalysisResponse' {} Maybe Text
a -> StartDocumentAnalysisResponse
s {$sel:jobId:StartDocumentAnalysisResponse' :: Maybe Text
jobId = Maybe Text
a} :: StartDocumentAnalysisResponse)

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

instance Prelude.NFData StartDocumentAnalysisResponse