{-# 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.SageMaker.Types.ProcessingInput
-- 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.SageMaker.Types.ProcessingInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.DatasetDefinition
import Amazonka.SageMaker.Types.ProcessingS3Input

-- | The inputs for a processing job. The processing input must specify
-- exactly one of either @S3Input@ or @DatasetDefinition@ types.
--
-- /See:/ 'newProcessingInput' smart constructor.
data ProcessingInput = ProcessingInput'
  { -- | Configuration for a Dataset Definition input.
    ProcessingInput -> Maybe DatasetDefinition
datasetDefinition :: Prelude.Maybe DatasetDefinition,
    -- | When @True@, input operations such as data download are managed natively
    -- by the processing job application. When @False@ (default), input
    -- operations are managed by Amazon SageMaker.
    ProcessingInput -> Maybe Bool
appManaged :: Prelude.Maybe Prelude.Bool,
    -- | Configuration for downloading input data from Amazon S3 into the
    -- processing container.
    ProcessingInput -> Maybe ProcessingS3Input
s3Input :: Prelude.Maybe ProcessingS3Input,
    -- | The name for the processing job input.
    ProcessingInput -> Text
inputName :: Prelude.Text
  }
  deriving (ProcessingInput -> ProcessingInput -> Bool
(ProcessingInput -> ProcessingInput -> Bool)
-> (ProcessingInput -> ProcessingInput -> Bool)
-> Eq ProcessingInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingInput -> ProcessingInput -> Bool
$c/= :: ProcessingInput -> ProcessingInput -> Bool
== :: ProcessingInput -> ProcessingInput -> Bool
$c== :: ProcessingInput -> ProcessingInput -> Bool
Prelude.Eq, ReadPrec [ProcessingInput]
ReadPrec ProcessingInput
Int -> ReadS ProcessingInput
ReadS [ProcessingInput]
(Int -> ReadS ProcessingInput)
-> ReadS [ProcessingInput]
-> ReadPrec ProcessingInput
-> ReadPrec [ProcessingInput]
-> Read ProcessingInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingInput]
$creadListPrec :: ReadPrec [ProcessingInput]
readPrec :: ReadPrec ProcessingInput
$creadPrec :: ReadPrec ProcessingInput
readList :: ReadS [ProcessingInput]
$creadList :: ReadS [ProcessingInput]
readsPrec :: Int -> ReadS ProcessingInput
$creadsPrec :: Int -> ReadS ProcessingInput
Prelude.Read, Int -> ProcessingInput -> ShowS
[ProcessingInput] -> ShowS
ProcessingInput -> String
(Int -> ProcessingInput -> ShowS)
-> (ProcessingInput -> String)
-> ([ProcessingInput] -> ShowS)
-> Show ProcessingInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingInput] -> ShowS
$cshowList :: [ProcessingInput] -> ShowS
show :: ProcessingInput -> String
$cshow :: ProcessingInput -> String
showsPrec :: Int -> ProcessingInput -> ShowS
$cshowsPrec :: Int -> ProcessingInput -> ShowS
Prelude.Show, (forall x. ProcessingInput -> Rep ProcessingInput x)
-> (forall x. Rep ProcessingInput x -> ProcessingInput)
-> Generic ProcessingInput
forall x. Rep ProcessingInput x -> ProcessingInput
forall x. ProcessingInput -> Rep ProcessingInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessingInput x -> ProcessingInput
$cfrom :: forall x. ProcessingInput -> Rep ProcessingInput x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingInput' 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:
--
-- 'datasetDefinition', 'processingInput_datasetDefinition' - Configuration for a Dataset Definition input.
--
-- 'appManaged', 'processingInput_appManaged' - When @True@, input operations such as data download are managed natively
-- by the processing job application. When @False@ (default), input
-- operations are managed by Amazon SageMaker.
--
-- 's3Input', 'processingInput_s3Input' - Configuration for downloading input data from Amazon S3 into the
-- processing container.
--
-- 'inputName', 'processingInput_inputName' - The name for the processing job input.
newProcessingInput ::
  -- | 'inputName'
  Prelude.Text ->
  ProcessingInput
newProcessingInput :: Text -> ProcessingInput
newProcessingInput Text
pInputName_ =
  ProcessingInput' :: Maybe DatasetDefinition
-> Maybe Bool -> Maybe ProcessingS3Input -> Text -> ProcessingInput
ProcessingInput'
    { $sel:datasetDefinition:ProcessingInput' :: Maybe DatasetDefinition
datasetDefinition =
        Maybe DatasetDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:appManaged:ProcessingInput' :: Maybe Bool
appManaged = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Input:ProcessingInput' :: Maybe ProcessingS3Input
s3Input = Maybe ProcessingS3Input
forall a. Maybe a
Prelude.Nothing,
      $sel:inputName:ProcessingInput' :: Text
inputName = Text
pInputName_
    }

-- | Configuration for a Dataset Definition input.
processingInput_datasetDefinition :: Lens.Lens' ProcessingInput (Prelude.Maybe DatasetDefinition)
processingInput_datasetDefinition :: (Maybe DatasetDefinition -> f (Maybe DatasetDefinition))
-> ProcessingInput -> f ProcessingInput
processingInput_datasetDefinition = (ProcessingInput -> Maybe DatasetDefinition)
-> (ProcessingInput -> Maybe DatasetDefinition -> ProcessingInput)
-> Lens
     ProcessingInput
     ProcessingInput
     (Maybe DatasetDefinition)
     (Maybe DatasetDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingInput' {Maybe DatasetDefinition
datasetDefinition :: Maybe DatasetDefinition
$sel:datasetDefinition:ProcessingInput' :: ProcessingInput -> Maybe DatasetDefinition
datasetDefinition} -> Maybe DatasetDefinition
datasetDefinition) (\s :: ProcessingInput
s@ProcessingInput' {} Maybe DatasetDefinition
a -> ProcessingInput
s {$sel:datasetDefinition:ProcessingInput' :: Maybe DatasetDefinition
datasetDefinition = Maybe DatasetDefinition
a} :: ProcessingInput)

-- | When @True@, input operations such as data download are managed natively
-- by the processing job application. When @False@ (default), input
-- operations are managed by Amazon SageMaker.
processingInput_appManaged :: Lens.Lens' ProcessingInput (Prelude.Maybe Prelude.Bool)
processingInput_appManaged :: (Maybe Bool -> f (Maybe Bool))
-> ProcessingInput -> f ProcessingInput
processingInput_appManaged = (ProcessingInput -> Maybe Bool)
-> (ProcessingInput -> Maybe Bool -> ProcessingInput)
-> Lens ProcessingInput ProcessingInput (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingInput' {Maybe Bool
appManaged :: Maybe Bool
$sel:appManaged:ProcessingInput' :: ProcessingInput -> Maybe Bool
appManaged} -> Maybe Bool
appManaged) (\s :: ProcessingInput
s@ProcessingInput' {} Maybe Bool
a -> ProcessingInput
s {$sel:appManaged:ProcessingInput' :: Maybe Bool
appManaged = Maybe Bool
a} :: ProcessingInput)

-- | Configuration for downloading input data from Amazon S3 into the
-- processing container.
processingInput_s3Input :: Lens.Lens' ProcessingInput (Prelude.Maybe ProcessingS3Input)
processingInput_s3Input :: (Maybe ProcessingS3Input -> f (Maybe ProcessingS3Input))
-> ProcessingInput -> f ProcessingInput
processingInput_s3Input = (ProcessingInput -> Maybe ProcessingS3Input)
-> (ProcessingInput -> Maybe ProcessingS3Input -> ProcessingInput)
-> Lens
     ProcessingInput
     ProcessingInput
     (Maybe ProcessingS3Input)
     (Maybe ProcessingS3Input)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingInput' {Maybe ProcessingS3Input
s3Input :: Maybe ProcessingS3Input
$sel:s3Input:ProcessingInput' :: ProcessingInput -> Maybe ProcessingS3Input
s3Input} -> Maybe ProcessingS3Input
s3Input) (\s :: ProcessingInput
s@ProcessingInput' {} Maybe ProcessingS3Input
a -> ProcessingInput
s {$sel:s3Input:ProcessingInput' :: Maybe ProcessingS3Input
s3Input = Maybe ProcessingS3Input
a} :: ProcessingInput)

-- | The name for the processing job input.
processingInput_inputName :: Lens.Lens' ProcessingInput Prelude.Text
processingInput_inputName :: (Text -> f Text) -> ProcessingInput -> f ProcessingInput
processingInput_inputName = (ProcessingInput -> Text)
-> (ProcessingInput -> Text -> ProcessingInput)
-> Lens ProcessingInput ProcessingInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingInput' {Text
inputName :: Text
$sel:inputName:ProcessingInput' :: ProcessingInput -> Text
inputName} -> Text
inputName) (\s :: ProcessingInput
s@ProcessingInput' {} Text
a -> ProcessingInput
s {$sel:inputName:ProcessingInput' :: Text
inputName = Text
a} :: ProcessingInput)

instance Core.FromJSON ProcessingInput where
  parseJSON :: Value -> Parser ProcessingInput
parseJSON =
    String
-> (Object -> Parser ProcessingInput)
-> Value
-> Parser ProcessingInput
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessingInput"
      ( \Object
x ->
          Maybe DatasetDefinition
-> Maybe Bool -> Maybe ProcessingS3Input -> Text -> ProcessingInput
ProcessingInput'
            (Maybe DatasetDefinition
 -> Maybe Bool
 -> Maybe ProcessingS3Input
 -> Text
 -> ProcessingInput)
-> Parser (Maybe DatasetDefinition)
-> Parser
     (Maybe Bool -> Maybe ProcessingS3Input -> Text -> ProcessingInput)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DatasetDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DatasetDefinition")
            Parser
  (Maybe Bool -> Maybe ProcessingS3Input -> Text -> ProcessingInput)
-> Parser (Maybe Bool)
-> Parser (Maybe ProcessingS3Input -> Text -> ProcessingInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AppManaged")
            Parser (Maybe ProcessingS3Input -> Text -> ProcessingInput)
-> Parser (Maybe ProcessingS3Input)
-> Parser (Text -> ProcessingInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ProcessingS3Input)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3Input")
            Parser (Text -> ProcessingInput)
-> Parser Text -> Parser ProcessingInput
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InputName")
      )

instance Prelude.Hashable ProcessingInput

instance Prelude.NFData ProcessingInput

instance Core.ToJSON ProcessingInput where
  toJSON :: ProcessingInput -> Value
toJSON ProcessingInput' {Maybe Bool
Maybe ProcessingS3Input
Maybe DatasetDefinition
Text
inputName :: Text
s3Input :: Maybe ProcessingS3Input
appManaged :: Maybe Bool
datasetDefinition :: Maybe DatasetDefinition
$sel:inputName:ProcessingInput' :: ProcessingInput -> Text
$sel:s3Input:ProcessingInput' :: ProcessingInput -> Maybe ProcessingS3Input
$sel:appManaged:ProcessingInput' :: ProcessingInput -> Maybe Bool
$sel:datasetDefinition:ProcessingInput' :: ProcessingInput -> Maybe DatasetDefinition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DatasetDefinition" Text -> DatasetDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DatasetDefinition -> Pair)
-> Maybe DatasetDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatasetDefinition
datasetDefinition,
            (Text
"AppManaged" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
appManaged,
            (Text
"S3Input" Text -> ProcessingS3Input -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ProcessingS3Input -> Pair)
-> Maybe ProcessingS3Input -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProcessingS3Input
s3Input,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InputName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputName)
          ]
      )