{-# 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.InputDataConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Comprehend.Types.InputDataConfig where

import Amazonka.Comprehend.Types.DocumentReaderConfig
import Amazonka.Comprehend.Types.InputFormat
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The input properties for an inference job. The document reader config
-- field applies only to non-text inputs for custom analysis.
--
-- /See:/ 'newInputDataConfig' smart constructor.
data InputDataConfig = InputDataConfig'
  { -- | Provides configuration parameters to override the default actions for
    -- extracting text from PDF documents and image files.
    InputDataConfig -> Maybe DocumentReaderConfig
documentReaderConfig :: Prelude.Maybe DocumentReaderConfig,
    -- | Specifies how the text in an input file should be processed:
    --
    -- -   @ONE_DOC_PER_FILE@ - Each file is considered a separate document.
    --     Use this option when you are processing large documents, such as
    --     newspaper articles or scientific papers.
    --
    -- -   @ONE_DOC_PER_LINE@ - Each line in a file is considered a separate
    --     document. Use this option when you are processing many short
    --     documents, such as text messages.
    InputDataConfig -> Maybe InputFormat
inputFormat :: Prelude.Maybe InputFormat,
    -- | The Amazon S3 URI for the input data. The URI must be in same region as
    -- the API endpoint that you are calling. The URI can point to a single
    -- input file or it can provide the prefix for a collection of data files.
    --
    -- For example, if you use the URI @S3:\/\/bucketName\/prefix@, if the
    -- prefix is a single file, Amazon Comprehend uses that file as input. If
    -- more than one file begins with the prefix, Amazon Comprehend uses all of
    -- them as input.
    InputDataConfig -> Text
s3Uri :: Prelude.Text
  }
  deriving (InputDataConfig -> InputDataConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputDataConfig -> InputDataConfig -> Bool
$c/= :: InputDataConfig -> InputDataConfig -> Bool
== :: InputDataConfig -> InputDataConfig -> Bool
$c== :: InputDataConfig -> InputDataConfig -> Bool
Prelude.Eq, ReadPrec [InputDataConfig]
ReadPrec InputDataConfig
Int -> ReadS InputDataConfig
ReadS [InputDataConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputDataConfig]
$creadListPrec :: ReadPrec [InputDataConfig]
readPrec :: ReadPrec InputDataConfig
$creadPrec :: ReadPrec InputDataConfig
readList :: ReadS [InputDataConfig]
$creadList :: ReadS [InputDataConfig]
readsPrec :: Int -> ReadS InputDataConfig
$creadsPrec :: Int -> ReadS InputDataConfig
Prelude.Read, Int -> InputDataConfig -> ShowS
[InputDataConfig] -> ShowS
InputDataConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputDataConfig] -> ShowS
$cshowList :: [InputDataConfig] -> ShowS
show :: InputDataConfig -> String
$cshow :: InputDataConfig -> String
showsPrec :: Int -> InputDataConfig -> ShowS
$cshowsPrec :: Int -> InputDataConfig -> ShowS
Prelude.Show, forall x. Rep InputDataConfig x -> InputDataConfig
forall x. InputDataConfig -> Rep InputDataConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputDataConfig x -> InputDataConfig
$cfrom :: forall x. InputDataConfig -> Rep InputDataConfig x
Prelude.Generic)

-- |
-- Create a value of 'InputDataConfig' 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:
--
-- 'documentReaderConfig', 'inputDataConfig_documentReaderConfig' - Provides configuration parameters to override the default actions for
-- extracting text from PDF documents and image files.
--
-- 'inputFormat', 'inputDataConfig_inputFormat' - Specifies how the text in an input file should be processed:
--
-- -   @ONE_DOC_PER_FILE@ - Each file is considered a separate document.
--     Use this option when you are processing large documents, such as
--     newspaper articles or scientific papers.
--
-- -   @ONE_DOC_PER_LINE@ - Each line in a file is considered a separate
--     document. Use this option when you are processing many short
--     documents, such as text messages.
--
-- 's3Uri', 'inputDataConfig_s3Uri' - The Amazon S3 URI for the input data. The URI must be in same region as
-- the API endpoint that you are calling. The URI can point to a single
-- input file or it can provide the prefix for a collection of data files.
--
-- For example, if you use the URI @S3:\/\/bucketName\/prefix@, if the
-- prefix is a single file, Amazon Comprehend uses that file as input. If
-- more than one file begins with the prefix, Amazon Comprehend uses all of
-- them as input.
newInputDataConfig ::
  -- | 's3Uri'
  Prelude.Text ->
  InputDataConfig
newInputDataConfig :: Text -> InputDataConfig
newInputDataConfig Text
pS3Uri_ =
  InputDataConfig'
    { $sel:documentReaderConfig:InputDataConfig' :: Maybe DocumentReaderConfig
documentReaderConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:inputFormat:InputDataConfig' :: Maybe InputFormat
inputFormat = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Uri:InputDataConfig' :: Text
s3Uri = Text
pS3Uri_
    }

-- | Provides configuration parameters to override the default actions for
-- extracting text from PDF documents and image files.
inputDataConfig_documentReaderConfig :: Lens.Lens' InputDataConfig (Prelude.Maybe DocumentReaderConfig)
inputDataConfig_documentReaderConfig :: Lens' InputDataConfig (Maybe DocumentReaderConfig)
inputDataConfig_documentReaderConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDataConfig' {Maybe DocumentReaderConfig
documentReaderConfig :: Maybe DocumentReaderConfig
$sel:documentReaderConfig:InputDataConfig' :: InputDataConfig -> Maybe DocumentReaderConfig
documentReaderConfig} -> Maybe DocumentReaderConfig
documentReaderConfig) (\s :: InputDataConfig
s@InputDataConfig' {} Maybe DocumentReaderConfig
a -> InputDataConfig
s {$sel:documentReaderConfig:InputDataConfig' :: Maybe DocumentReaderConfig
documentReaderConfig = Maybe DocumentReaderConfig
a} :: InputDataConfig)

-- | Specifies how the text in an input file should be processed:
--
-- -   @ONE_DOC_PER_FILE@ - Each file is considered a separate document.
--     Use this option when you are processing large documents, such as
--     newspaper articles or scientific papers.
--
-- -   @ONE_DOC_PER_LINE@ - Each line in a file is considered a separate
--     document. Use this option when you are processing many short
--     documents, such as text messages.
inputDataConfig_inputFormat :: Lens.Lens' InputDataConfig (Prelude.Maybe InputFormat)
inputDataConfig_inputFormat :: Lens' InputDataConfig (Maybe InputFormat)
inputDataConfig_inputFormat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDataConfig' {Maybe InputFormat
inputFormat :: Maybe InputFormat
$sel:inputFormat:InputDataConfig' :: InputDataConfig -> Maybe InputFormat
inputFormat} -> Maybe InputFormat
inputFormat) (\s :: InputDataConfig
s@InputDataConfig' {} Maybe InputFormat
a -> InputDataConfig
s {$sel:inputFormat:InputDataConfig' :: Maybe InputFormat
inputFormat = Maybe InputFormat
a} :: InputDataConfig)

-- | The Amazon S3 URI for the input data. The URI must be in same region as
-- the API endpoint that you are calling. The URI can point to a single
-- input file or it can provide the prefix for a collection of data files.
--
-- For example, if you use the URI @S3:\/\/bucketName\/prefix@, if the
-- prefix is a single file, Amazon Comprehend uses that file as input. If
-- more than one file begins with the prefix, Amazon Comprehend uses all of
-- them as input.
inputDataConfig_s3Uri :: Lens.Lens' InputDataConfig Prelude.Text
inputDataConfig_s3Uri :: Lens' InputDataConfig Text
inputDataConfig_s3Uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDataConfig' {Text
s3Uri :: Text
$sel:s3Uri:InputDataConfig' :: InputDataConfig -> Text
s3Uri} -> Text
s3Uri) (\s :: InputDataConfig
s@InputDataConfig' {} Text
a -> InputDataConfig
s {$sel:s3Uri:InputDataConfig' :: Text
s3Uri = Text
a} :: InputDataConfig)

instance Data.FromJSON InputDataConfig where
  parseJSON :: Value -> Parser InputDataConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputDataConfig"
      ( \Object
x ->
          Maybe DocumentReaderConfig
-> Maybe InputFormat -> Text -> InputDataConfig
InputDataConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DocumentReaderConfig")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InputFormat")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"S3Uri")
      )

instance Prelude.Hashable InputDataConfig where
  hashWithSalt :: Int -> InputDataConfig -> Int
hashWithSalt Int
_salt InputDataConfig' {Maybe DocumentReaderConfig
Maybe InputFormat
Text
s3Uri :: Text
inputFormat :: Maybe InputFormat
documentReaderConfig :: Maybe DocumentReaderConfig
$sel:s3Uri:InputDataConfig' :: InputDataConfig -> Text
$sel:inputFormat:InputDataConfig' :: InputDataConfig -> Maybe InputFormat
$sel:documentReaderConfig:InputDataConfig' :: InputDataConfig -> Maybe DocumentReaderConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentReaderConfig
documentReaderConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputFormat
inputFormat
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Uri

instance Prelude.NFData InputDataConfig where
  rnf :: InputDataConfig -> ()
rnf InputDataConfig' {Maybe DocumentReaderConfig
Maybe InputFormat
Text
s3Uri :: Text
inputFormat :: Maybe InputFormat
documentReaderConfig :: Maybe DocumentReaderConfig
$sel:s3Uri:InputDataConfig' :: InputDataConfig -> Text
$sel:inputFormat:InputDataConfig' :: InputDataConfig -> Maybe InputFormat
$sel:documentReaderConfig:InputDataConfig' :: InputDataConfig -> Maybe DocumentReaderConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentReaderConfig
documentReaderConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputFormat
inputFormat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3Uri

instance Data.ToJSON InputDataConfig where
  toJSON :: InputDataConfig -> Value
toJSON InputDataConfig' {Maybe DocumentReaderConfig
Maybe InputFormat
Text
s3Uri :: Text
inputFormat :: Maybe InputFormat
documentReaderConfig :: Maybe DocumentReaderConfig
$sel:s3Uri:InputDataConfig' :: InputDataConfig -> Text
$sel:inputFormat:InputDataConfig' :: InputDataConfig -> Maybe InputFormat
$sel:documentReaderConfig:InputDataConfig' :: InputDataConfig -> Maybe DocumentReaderConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DocumentReaderConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentReaderConfig
documentReaderConfig,
            (Key
"InputFormat" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputFormat
inputFormat,
            forall a. a -> Maybe a
Prelude.Just (Key
"S3Uri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Uri)
          ]
      )