{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Comprehend.Types.DocumentReaderConfig
-- 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)
module Amazonka.Comprehend.Types.DocumentReaderConfig where

import Amazonka.Comprehend.Types.DocumentReadAction
import Amazonka.Comprehend.Types.DocumentReadFeatureTypes
import Amazonka.Comprehend.Types.DocumentReadMode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The input properties for a topic detection job.
--
-- /See:/ 'newDocumentReaderConfig' smart constructor.
data DocumentReaderConfig = DocumentReaderConfig'
  { -- | Specifies how the text in an input file should be processed:
    DocumentReaderConfig -> Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes :: Prelude.Maybe (Prelude.NonEmpty DocumentReadFeatureTypes),
    -- | This enum field provides two values:
    --
    -- -   @SERVICE_DEFAULT@ - use service defaults for Document reading. For
    --     Digital PDF it would mean using an internal parser instead of
    --     Textract APIs
    --
    -- -   @FORCE_DOCUMENT_READ_ACTION@ - Always use specified action for
    --     DocumentReadAction, including Digital PDF.
    DocumentReaderConfig -> Maybe DocumentReadMode
documentReadMode :: Prelude.Maybe DocumentReadMode,
    -- | This enum field will start with two values which will apply to PDFs:
    --
    -- -   @TEXTRACT_DETECT_DOCUMENT_TEXT@ - The service calls
    --     DetectDocumentText for PDF documents per page.
    --
    -- -   @TEXTRACT_ANALYZE_DOCUMENT@ - The service calls AnalyzeDocument for
    --     PDF documents per page.
    DocumentReaderConfig -> DocumentReadAction
documentReadAction :: DocumentReadAction
  }
  deriving (DocumentReaderConfig -> DocumentReaderConfig -> Bool
(DocumentReaderConfig -> DocumentReaderConfig -> Bool)
-> (DocumentReaderConfig -> DocumentReaderConfig -> Bool)
-> Eq DocumentReaderConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentReaderConfig -> DocumentReaderConfig -> Bool
$c/= :: DocumentReaderConfig -> DocumentReaderConfig -> Bool
== :: DocumentReaderConfig -> DocumentReaderConfig -> Bool
$c== :: DocumentReaderConfig -> DocumentReaderConfig -> Bool
Prelude.Eq, ReadPrec [DocumentReaderConfig]
ReadPrec DocumentReaderConfig
Int -> ReadS DocumentReaderConfig
ReadS [DocumentReaderConfig]
(Int -> ReadS DocumentReaderConfig)
-> ReadS [DocumentReaderConfig]
-> ReadPrec DocumentReaderConfig
-> ReadPrec [DocumentReaderConfig]
-> Read DocumentReaderConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentReaderConfig]
$creadListPrec :: ReadPrec [DocumentReaderConfig]
readPrec :: ReadPrec DocumentReaderConfig
$creadPrec :: ReadPrec DocumentReaderConfig
readList :: ReadS [DocumentReaderConfig]
$creadList :: ReadS [DocumentReaderConfig]
readsPrec :: Int -> ReadS DocumentReaderConfig
$creadsPrec :: Int -> ReadS DocumentReaderConfig
Prelude.Read, Int -> DocumentReaderConfig -> ShowS
[DocumentReaderConfig] -> ShowS
DocumentReaderConfig -> String
(Int -> DocumentReaderConfig -> ShowS)
-> (DocumentReaderConfig -> String)
-> ([DocumentReaderConfig] -> ShowS)
-> Show DocumentReaderConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentReaderConfig] -> ShowS
$cshowList :: [DocumentReaderConfig] -> ShowS
show :: DocumentReaderConfig -> String
$cshow :: DocumentReaderConfig -> String
showsPrec :: Int -> DocumentReaderConfig -> ShowS
$cshowsPrec :: Int -> DocumentReaderConfig -> ShowS
Prelude.Show, (forall x. DocumentReaderConfig -> Rep DocumentReaderConfig x)
-> (forall x. Rep DocumentReaderConfig x -> DocumentReaderConfig)
-> Generic DocumentReaderConfig
forall x. Rep DocumentReaderConfig x -> DocumentReaderConfig
forall x. DocumentReaderConfig -> Rep DocumentReaderConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentReaderConfig x -> DocumentReaderConfig
$cfrom :: forall x. DocumentReaderConfig -> Rep DocumentReaderConfig x
Prelude.Generic)

-- |
-- Create a value of 'DocumentReaderConfig' 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:
--
-- 'featureTypes', 'documentReaderConfig_featureTypes' - Specifies how the text in an input file should be processed:
--
-- 'documentReadMode', 'documentReaderConfig_documentReadMode' - This enum field provides two values:
--
-- -   @SERVICE_DEFAULT@ - use service defaults for Document reading. For
--     Digital PDF it would mean using an internal parser instead of
--     Textract APIs
--
-- -   @FORCE_DOCUMENT_READ_ACTION@ - Always use specified action for
--     DocumentReadAction, including Digital PDF.
--
-- 'documentReadAction', 'documentReaderConfig_documentReadAction' - This enum field will start with two values which will apply to PDFs:
--
-- -   @TEXTRACT_DETECT_DOCUMENT_TEXT@ - The service calls
--     DetectDocumentText for PDF documents per page.
--
-- -   @TEXTRACT_ANALYZE_DOCUMENT@ - The service calls AnalyzeDocument for
--     PDF documents per page.
newDocumentReaderConfig ::
  -- | 'documentReadAction'
  DocumentReadAction ->
  DocumentReaderConfig
newDocumentReaderConfig :: DocumentReadAction -> DocumentReaderConfig
newDocumentReaderConfig DocumentReadAction
pDocumentReadAction_ =
  DocumentReaderConfig' :: Maybe (NonEmpty DocumentReadFeatureTypes)
-> Maybe DocumentReadMode
-> DocumentReadAction
-> DocumentReaderConfig
DocumentReaderConfig'
    { $sel:featureTypes:DocumentReaderConfig' :: Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes =
        Maybe (NonEmpty DocumentReadFeatureTypes)
forall a. Maybe a
Prelude.Nothing,
      $sel:documentReadMode:DocumentReaderConfig' :: Maybe DocumentReadMode
documentReadMode = Maybe DocumentReadMode
forall a. Maybe a
Prelude.Nothing,
      $sel:documentReadAction:DocumentReaderConfig' :: DocumentReadAction
documentReadAction = DocumentReadAction
pDocumentReadAction_
    }

-- | Specifies how the text in an input file should be processed:
documentReaderConfig_featureTypes :: Lens.Lens' DocumentReaderConfig (Prelude.Maybe (Prelude.NonEmpty DocumentReadFeatureTypes))
documentReaderConfig_featureTypes :: (Maybe (NonEmpty DocumentReadFeatureTypes)
 -> f (Maybe (NonEmpty DocumentReadFeatureTypes)))
-> DocumentReaderConfig -> f DocumentReaderConfig
documentReaderConfig_featureTypes = (DocumentReaderConfig -> Maybe (NonEmpty DocumentReadFeatureTypes))
-> (DocumentReaderConfig
    -> Maybe (NonEmpty DocumentReadFeatureTypes)
    -> DocumentReaderConfig)
-> Lens
     DocumentReaderConfig
     DocumentReaderConfig
     (Maybe (NonEmpty DocumentReadFeatureTypes))
     (Maybe (NonEmpty DocumentReadFeatureTypes))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReaderConfig' {Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes :: Maybe (NonEmpty DocumentReadFeatureTypes)
$sel:featureTypes:DocumentReaderConfig' :: DocumentReaderConfig -> Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes} -> Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes) (\s :: DocumentReaderConfig
s@DocumentReaderConfig' {} Maybe (NonEmpty DocumentReadFeatureTypes)
a -> DocumentReaderConfig
s {$sel:featureTypes:DocumentReaderConfig' :: Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes = Maybe (NonEmpty DocumentReadFeatureTypes)
a} :: DocumentReaderConfig) ((Maybe (NonEmpty DocumentReadFeatureTypes)
  -> f (Maybe (NonEmpty DocumentReadFeatureTypes)))
 -> DocumentReaderConfig -> f DocumentReaderConfig)
-> ((Maybe (NonEmpty DocumentReadFeatureTypes)
     -> f (Maybe (NonEmpty DocumentReadFeatureTypes)))
    -> Maybe (NonEmpty DocumentReadFeatureTypes)
    -> f (Maybe (NonEmpty DocumentReadFeatureTypes)))
-> (Maybe (NonEmpty DocumentReadFeatureTypes)
    -> f (Maybe (NonEmpty DocumentReadFeatureTypes)))
-> DocumentReaderConfig
-> f DocumentReaderConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
-> Iso
     (Maybe (NonEmpty DocumentReadFeatureTypes))
     (Maybe (NonEmpty DocumentReadFeatureTypes))
     (Maybe (NonEmpty DocumentReadFeatureTypes))
     (Maybe (NonEmpty DocumentReadFeatureTypes))
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
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
  (NonEmpty DocumentReadFeatureTypes)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This enum field provides two values:
--
-- -   @SERVICE_DEFAULT@ - use service defaults for Document reading. For
--     Digital PDF it would mean using an internal parser instead of
--     Textract APIs
--
-- -   @FORCE_DOCUMENT_READ_ACTION@ - Always use specified action for
--     DocumentReadAction, including Digital PDF.
documentReaderConfig_documentReadMode :: Lens.Lens' DocumentReaderConfig (Prelude.Maybe DocumentReadMode)
documentReaderConfig_documentReadMode :: (Maybe DocumentReadMode -> f (Maybe DocumentReadMode))
-> DocumentReaderConfig -> f DocumentReaderConfig
documentReaderConfig_documentReadMode = (DocumentReaderConfig -> Maybe DocumentReadMode)
-> (DocumentReaderConfig
    -> Maybe DocumentReadMode -> DocumentReaderConfig)
-> Lens
     DocumentReaderConfig
     DocumentReaderConfig
     (Maybe DocumentReadMode)
     (Maybe DocumentReadMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReaderConfig' {Maybe DocumentReadMode
documentReadMode :: Maybe DocumentReadMode
$sel:documentReadMode:DocumentReaderConfig' :: DocumentReaderConfig -> Maybe DocumentReadMode
documentReadMode} -> Maybe DocumentReadMode
documentReadMode) (\s :: DocumentReaderConfig
s@DocumentReaderConfig' {} Maybe DocumentReadMode
a -> DocumentReaderConfig
s {$sel:documentReadMode:DocumentReaderConfig' :: Maybe DocumentReadMode
documentReadMode = Maybe DocumentReadMode
a} :: DocumentReaderConfig)

-- | This enum field will start with two values which will apply to PDFs:
--
-- -   @TEXTRACT_DETECT_DOCUMENT_TEXT@ - The service calls
--     DetectDocumentText for PDF documents per page.
--
-- -   @TEXTRACT_ANALYZE_DOCUMENT@ - The service calls AnalyzeDocument for
--     PDF documents per page.
documentReaderConfig_documentReadAction :: Lens.Lens' DocumentReaderConfig DocumentReadAction
documentReaderConfig_documentReadAction :: (DocumentReadAction -> f DocumentReadAction)
-> DocumentReaderConfig -> f DocumentReaderConfig
documentReaderConfig_documentReadAction = (DocumentReaderConfig -> DocumentReadAction)
-> (DocumentReaderConfig
    -> DocumentReadAction -> DocumentReaderConfig)
-> Lens
     DocumentReaderConfig
     DocumentReaderConfig
     DocumentReadAction
     DocumentReadAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReaderConfig' {DocumentReadAction
documentReadAction :: DocumentReadAction
$sel:documentReadAction:DocumentReaderConfig' :: DocumentReaderConfig -> DocumentReadAction
documentReadAction} -> DocumentReadAction
documentReadAction) (\s :: DocumentReaderConfig
s@DocumentReaderConfig' {} DocumentReadAction
a -> DocumentReaderConfig
s {$sel:documentReadAction:DocumentReaderConfig' :: DocumentReadAction
documentReadAction = DocumentReadAction
a} :: DocumentReaderConfig)

instance Core.FromJSON DocumentReaderConfig where
  parseJSON :: Value -> Parser DocumentReaderConfig
parseJSON =
    String
-> (Object -> Parser DocumentReaderConfig)
-> Value
-> Parser DocumentReaderConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DocumentReaderConfig"
      ( \Object
x ->
          Maybe (NonEmpty DocumentReadFeatureTypes)
-> Maybe DocumentReadMode
-> DocumentReadAction
-> DocumentReaderConfig
DocumentReaderConfig'
            (Maybe (NonEmpty DocumentReadFeatureTypes)
 -> Maybe DocumentReadMode
 -> DocumentReadAction
 -> DocumentReaderConfig)
-> Parser (Maybe (NonEmpty DocumentReadFeatureTypes))
-> Parser
     (Maybe DocumentReadMode
      -> DocumentReadAction -> DocumentReaderConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (NonEmpty DocumentReadFeatureTypes))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FeatureTypes")
            Parser
  (Maybe DocumentReadMode
   -> DocumentReadAction -> DocumentReaderConfig)
-> Parser (Maybe DocumentReadMode)
-> Parser (DocumentReadAction -> DocumentReaderConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DocumentReadMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DocumentReadMode")
            Parser (DocumentReadAction -> DocumentReaderConfig)
-> Parser DocumentReadAction -> Parser DocumentReaderConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DocumentReadAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DocumentReadAction")
      )

instance Prelude.Hashable DocumentReaderConfig

instance Prelude.NFData DocumentReaderConfig

instance Core.ToJSON DocumentReaderConfig where
  toJSON :: DocumentReaderConfig -> Value
toJSON DocumentReaderConfig' {Maybe (NonEmpty DocumentReadFeatureTypes)
Maybe DocumentReadMode
DocumentReadAction
documentReadAction :: DocumentReadAction
documentReadMode :: Maybe DocumentReadMode
featureTypes :: Maybe (NonEmpty DocumentReadFeatureTypes)
$sel:documentReadAction:DocumentReaderConfig' :: DocumentReaderConfig -> DocumentReadAction
$sel:documentReadMode:DocumentReaderConfig' :: DocumentReaderConfig -> Maybe DocumentReadMode
$sel:featureTypes:DocumentReaderConfig' :: DocumentReaderConfig -> Maybe (NonEmpty DocumentReadFeatureTypes)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FeatureTypes" Text -> NonEmpty DocumentReadFeatureTypes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty DocumentReadFeatureTypes -> Pair)
-> Maybe (NonEmpty DocumentReadFeatureTypes) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty DocumentReadFeatureTypes)
featureTypes,
            (Text
"DocumentReadMode" Text -> DocumentReadMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DocumentReadMode -> Pair) -> Maybe DocumentReadMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentReadMode
documentReadMode,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DocumentReadAction" Text -> DocumentReadAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DocumentReadAction
documentReadAction)
          ]
      )