{-# 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.DatasetDefinition
-- 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.DatasetDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.AthenaDatasetDefinition
import Amazonka.SageMaker.Types.DataDistributionType
import Amazonka.SageMaker.Types.InputMode
import Amazonka.SageMaker.Types.RedshiftDatasetDefinition

-- | Configuration for Dataset Definition inputs. The Dataset Definition
-- input must specify exactly one of either @AthenaDatasetDefinition@ or
-- @RedshiftDatasetDefinition@ types.
--
-- /See:/ 'newDatasetDefinition' smart constructor.
data DatasetDefinition = DatasetDefinition'
  { DatasetDefinition -> Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition :: Prelude.Maybe RedshiftDatasetDefinition,
    DatasetDefinition -> Maybe AthenaDatasetDefinition
athenaDatasetDefinition :: Prelude.Maybe AthenaDatasetDefinition,
    -- | The local path where you want Amazon SageMaker to download the Dataset
    -- Definition inputs to run a processing job. @LocalPath@ is an absolute
    -- path to the input data. This is a required parameter when @AppManaged@
    -- is @False@ (default).
    DatasetDefinition -> Maybe Text
localPath :: Prelude.Maybe Prelude.Text,
    -- | Whether the generated dataset is @FullyReplicated@ or @ShardedByS3Key@
    -- (default).
    DatasetDefinition -> Maybe DataDistributionType
dataDistributionType :: Prelude.Maybe DataDistributionType,
    -- | Whether to use @File@ or @Pipe@ input mode. In @File@ (default) mode,
    -- Amazon SageMaker copies the data from the input source onto the local
    -- Amazon Elastic Block Store (Amazon EBS) volumes before starting your
    -- training algorithm. This is the most commonly used input mode. In @Pipe@
    -- mode, Amazon SageMaker streams input data from the source directly to
    -- your algorithm without using the EBS volume.
    DatasetDefinition -> Maybe InputMode
inputMode :: Prelude.Maybe InputMode
  }
  deriving (DatasetDefinition -> DatasetDefinition -> Bool
(DatasetDefinition -> DatasetDefinition -> Bool)
-> (DatasetDefinition -> DatasetDefinition -> Bool)
-> Eq DatasetDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatasetDefinition -> DatasetDefinition -> Bool
$c/= :: DatasetDefinition -> DatasetDefinition -> Bool
== :: DatasetDefinition -> DatasetDefinition -> Bool
$c== :: DatasetDefinition -> DatasetDefinition -> Bool
Prelude.Eq, ReadPrec [DatasetDefinition]
ReadPrec DatasetDefinition
Int -> ReadS DatasetDefinition
ReadS [DatasetDefinition]
(Int -> ReadS DatasetDefinition)
-> ReadS [DatasetDefinition]
-> ReadPrec DatasetDefinition
-> ReadPrec [DatasetDefinition]
-> Read DatasetDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatasetDefinition]
$creadListPrec :: ReadPrec [DatasetDefinition]
readPrec :: ReadPrec DatasetDefinition
$creadPrec :: ReadPrec DatasetDefinition
readList :: ReadS [DatasetDefinition]
$creadList :: ReadS [DatasetDefinition]
readsPrec :: Int -> ReadS DatasetDefinition
$creadsPrec :: Int -> ReadS DatasetDefinition
Prelude.Read, Int -> DatasetDefinition -> ShowS
[DatasetDefinition] -> ShowS
DatasetDefinition -> String
(Int -> DatasetDefinition -> ShowS)
-> (DatasetDefinition -> String)
-> ([DatasetDefinition] -> ShowS)
-> Show DatasetDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatasetDefinition] -> ShowS
$cshowList :: [DatasetDefinition] -> ShowS
show :: DatasetDefinition -> String
$cshow :: DatasetDefinition -> String
showsPrec :: Int -> DatasetDefinition -> ShowS
$cshowsPrec :: Int -> DatasetDefinition -> ShowS
Prelude.Show, (forall x. DatasetDefinition -> Rep DatasetDefinition x)
-> (forall x. Rep DatasetDefinition x -> DatasetDefinition)
-> Generic DatasetDefinition
forall x. Rep DatasetDefinition x -> DatasetDefinition
forall x. DatasetDefinition -> Rep DatasetDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatasetDefinition x -> DatasetDefinition
$cfrom :: forall x. DatasetDefinition -> Rep DatasetDefinition x
Prelude.Generic)

-- |
-- Create a value of 'DatasetDefinition' 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:
--
-- 'redshiftDatasetDefinition', 'datasetDefinition_redshiftDatasetDefinition' - Undocumented member.
--
-- 'athenaDatasetDefinition', 'datasetDefinition_athenaDatasetDefinition' - Undocumented member.
--
-- 'localPath', 'datasetDefinition_localPath' - The local path where you want Amazon SageMaker to download the Dataset
-- Definition inputs to run a processing job. @LocalPath@ is an absolute
-- path to the input data. This is a required parameter when @AppManaged@
-- is @False@ (default).
--
-- 'dataDistributionType', 'datasetDefinition_dataDistributionType' - Whether the generated dataset is @FullyReplicated@ or @ShardedByS3Key@
-- (default).
--
-- 'inputMode', 'datasetDefinition_inputMode' - Whether to use @File@ or @Pipe@ input mode. In @File@ (default) mode,
-- Amazon SageMaker copies the data from the input source onto the local
-- Amazon Elastic Block Store (Amazon EBS) volumes before starting your
-- training algorithm. This is the most commonly used input mode. In @Pipe@
-- mode, Amazon SageMaker streams input data from the source directly to
-- your algorithm without using the EBS volume.
newDatasetDefinition ::
  DatasetDefinition
newDatasetDefinition :: DatasetDefinition
newDatasetDefinition =
  DatasetDefinition' :: Maybe RedshiftDatasetDefinition
-> Maybe AthenaDatasetDefinition
-> Maybe Text
-> Maybe DataDistributionType
-> Maybe InputMode
-> DatasetDefinition
DatasetDefinition'
    { $sel:redshiftDatasetDefinition:DatasetDefinition' :: Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition =
        Maybe RedshiftDatasetDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:athenaDatasetDefinition:DatasetDefinition' :: Maybe AthenaDatasetDefinition
athenaDatasetDefinition = Maybe AthenaDatasetDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:localPath:DatasetDefinition' :: Maybe Text
localPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dataDistributionType:DatasetDefinition' :: Maybe DataDistributionType
dataDistributionType = Maybe DataDistributionType
forall a. Maybe a
Prelude.Nothing,
      $sel:inputMode:DatasetDefinition' :: Maybe InputMode
inputMode = Maybe InputMode
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
datasetDefinition_redshiftDatasetDefinition :: Lens.Lens' DatasetDefinition (Prelude.Maybe RedshiftDatasetDefinition)
datasetDefinition_redshiftDatasetDefinition :: (Maybe RedshiftDatasetDefinition
 -> f (Maybe RedshiftDatasetDefinition))
-> DatasetDefinition -> f DatasetDefinition
datasetDefinition_redshiftDatasetDefinition = (DatasetDefinition -> Maybe RedshiftDatasetDefinition)
-> (DatasetDefinition
    -> Maybe RedshiftDatasetDefinition -> DatasetDefinition)
-> Lens
     DatasetDefinition
     DatasetDefinition
     (Maybe RedshiftDatasetDefinition)
     (Maybe RedshiftDatasetDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetDefinition' {Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition :: Maybe RedshiftDatasetDefinition
$sel:redshiftDatasetDefinition:DatasetDefinition' :: DatasetDefinition -> Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition} -> Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition) (\s :: DatasetDefinition
s@DatasetDefinition' {} Maybe RedshiftDatasetDefinition
a -> DatasetDefinition
s {$sel:redshiftDatasetDefinition:DatasetDefinition' :: Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition = Maybe RedshiftDatasetDefinition
a} :: DatasetDefinition)

-- | Undocumented member.
datasetDefinition_athenaDatasetDefinition :: Lens.Lens' DatasetDefinition (Prelude.Maybe AthenaDatasetDefinition)
datasetDefinition_athenaDatasetDefinition :: (Maybe AthenaDatasetDefinition
 -> f (Maybe AthenaDatasetDefinition))
-> DatasetDefinition -> f DatasetDefinition
datasetDefinition_athenaDatasetDefinition = (DatasetDefinition -> Maybe AthenaDatasetDefinition)
-> (DatasetDefinition
    -> Maybe AthenaDatasetDefinition -> DatasetDefinition)
-> Lens
     DatasetDefinition
     DatasetDefinition
     (Maybe AthenaDatasetDefinition)
     (Maybe AthenaDatasetDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetDefinition' {Maybe AthenaDatasetDefinition
athenaDatasetDefinition :: Maybe AthenaDatasetDefinition
$sel:athenaDatasetDefinition:DatasetDefinition' :: DatasetDefinition -> Maybe AthenaDatasetDefinition
athenaDatasetDefinition} -> Maybe AthenaDatasetDefinition
athenaDatasetDefinition) (\s :: DatasetDefinition
s@DatasetDefinition' {} Maybe AthenaDatasetDefinition
a -> DatasetDefinition
s {$sel:athenaDatasetDefinition:DatasetDefinition' :: Maybe AthenaDatasetDefinition
athenaDatasetDefinition = Maybe AthenaDatasetDefinition
a} :: DatasetDefinition)

-- | The local path where you want Amazon SageMaker to download the Dataset
-- Definition inputs to run a processing job. @LocalPath@ is an absolute
-- path to the input data. This is a required parameter when @AppManaged@
-- is @False@ (default).
datasetDefinition_localPath :: Lens.Lens' DatasetDefinition (Prelude.Maybe Prelude.Text)
datasetDefinition_localPath :: (Maybe Text -> f (Maybe Text))
-> DatasetDefinition -> f DatasetDefinition
datasetDefinition_localPath = (DatasetDefinition -> Maybe Text)
-> (DatasetDefinition -> Maybe Text -> DatasetDefinition)
-> Lens
     DatasetDefinition DatasetDefinition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetDefinition' {Maybe Text
localPath :: Maybe Text
$sel:localPath:DatasetDefinition' :: DatasetDefinition -> Maybe Text
localPath} -> Maybe Text
localPath) (\s :: DatasetDefinition
s@DatasetDefinition' {} Maybe Text
a -> DatasetDefinition
s {$sel:localPath:DatasetDefinition' :: Maybe Text
localPath = Maybe Text
a} :: DatasetDefinition)

-- | Whether the generated dataset is @FullyReplicated@ or @ShardedByS3Key@
-- (default).
datasetDefinition_dataDistributionType :: Lens.Lens' DatasetDefinition (Prelude.Maybe DataDistributionType)
datasetDefinition_dataDistributionType :: (Maybe DataDistributionType -> f (Maybe DataDistributionType))
-> DatasetDefinition -> f DatasetDefinition
datasetDefinition_dataDistributionType = (DatasetDefinition -> Maybe DataDistributionType)
-> (DatasetDefinition
    -> Maybe DataDistributionType -> DatasetDefinition)
-> Lens
     DatasetDefinition
     DatasetDefinition
     (Maybe DataDistributionType)
     (Maybe DataDistributionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetDefinition' {Maybe DataDistributionType
dataDistributionType :: Maybe DataDistributionType
$sel:dataDistributionType:DatasetDefinition' :: DatasetDefinition -> Maybe DataDistributionType
dataDistributionType} -> Maybe DataDistributionType
dataDistributionType) (\s :: DatasetDefinition
s@DatasetDefinition' {} Maybe DataDistributionType
a -> DatasetDefinition
s {$sel:dataDistributionType:DatasetDefinition' :: Maybe DataDistributionType
dataDistributionType = Maybe DataDistributionType
a} :: DatasetDefinition)

-- | Whether to use @File@ or @Pipe@ input mode. In @File@ (default) mode,
-- Amazon SageMaker copies the data from the input source onto the local
-- Amazon Elastic Block Store (Amazon EBS) volumes before starting your
-- training algorithm. This is the most commonly used input mode. In @Pipe@
-- mode, Amazon SageMaker streams input data from the source directly to
-- your algorithm without using the EBS volume.
datasetDefinition_inputMode :: Lens.Lens' DatasetDefinition (Prelude.Maybe InputMode)
datasetDefinition_inputMode :: (Maybe InputMode -> f (Maybe InputMode))
-> DatasetDefinition -> f DatasetDefinition
datasetDefinition_inputMode = (DatasetDefinition -> Maybe InputMode)
-> (DatasetDefinition -> Maybe InputMode -> DatasetDefinition)
-> Lens
     DatasetDefinition
     DatasetDefinition
     (Maybe InputMode)
     (Maybe InputMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetDefinition' {Maybe InputMode
inputMode :: Maybe InputMode
$sel:inputMode:DatasetDefinition' :: DatasetDefinition -> Maybe InputMode
inputMode} -> Maybe InputMode
inputMode) (\s :: DatasetDefinition
s@DatasetDefinition' {} Maybe InputMode
a -> DatasetDefinition
s {$sel:inputMode:DatasetDefinition' :: Maybe InputMode
inputMode = Maybe InputMode
a} :: DatasetDefinition)

instance Core.FromJSON DatasetDefinition where
  parseJSON :: Value -> Parser DatasetDefinition
parseJSON =
    String
-> (Object -> Parser DatasetDefinition)
-> Value
-> Parser DatasetDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DatasetDefinition"
      ( \Object
x ->
          Maybe RedshiftDatasetDefinition
-> Maybe AthenaDatasetDefinition
-> Maybe Text
-> Maybe DataDistributionType
-> Maybe InputMode
-> DatasetDefinition
DatasetDefinition'
            (Maybe RedshiftDatasetDefinition
 -> Maybe AthenaDatasetDefinition
 -> Maybe Text
 -> Maybe DataDistributionType
 -> Maybe InputMode
 -> DatasetDefinition)
-> Parser (Maybe RedshiftDatasetDefinition)
-> Parser
     (Maybe AthenaDatasetDefinition
      -> Maybe Text
      -> Maybe DataDistributionType
      -> Maybe InputMode
      -> DatasetDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RedshiftDatasetDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RedshiftDatasetDefinition")
            Parser
  (Maybe AthenaDatasetDefinition
   -> Maybe Text
   -> Maybe DataDistributionType
   -> Maybe InputMode
   -> DatasetDefinition)
-> Parser (Maybe AthenaDatasetDefinition)
-> Parser
     (Maybe Text
      -> Maybe DataDistributionType
      -> Maybe InputMode
      -> DatasetDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AthenaDatasetDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AthenaDatasetDefinition")
            Parser
  (Maybe Text
   -> Maybe DataDistributionType
   -> Maybe InputMode
   -> DatasetDefinition)
-> Parser (Maybe Text)
-> Parser
     (Maybe DataDistributionType
      -> Maybe InputMode -> DatasetDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LocalPath")
            Parser
  (Maybe DataDistributionType
   -> Maybe InputMode -> DatasetDefinition)
-> Parser (Maybe DataDistributionType)
-> Parser (Maybe InputMode -> DatasetDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DataDistributionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataDistributionType")
            Parser (Maybe InputMode -> DatasetDefinition)
-> Parser (Maybe InputMode) -> Parser DatasetDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InputMode")
      )

instance Prelude.Hashable DatasetDefinition

instance Prelude.NFData DatasetDefinition

instance Core.ToJSON DatasetDefinition where
  toJSON :: DatasetDefinition -> Value
toJSON DatasetDefinition' {Maybe Text
Maybe AthenaDatasetDefinition
Maybe DataDistributionType
Maybe InputMode
Maybe RedshiftDatasetDefinition
inputMode :: Maybe InputMode
dataDistributionType :: Maybe DataDistributionType
localPath :: Maybe Text
athenaDatasetDefinition :: Maybe AthenaDatasetDefinition
redshiftDatasetDefinition :: Maybe RedshiftDatasetDefinition
$sel:inputMode:DatasetDefinition' :: DatasetDefinition -> Maybe InputMode
$sel:dataDistributionType:DatasetDefinition' :: DatasetDefinition -> Maybe DataDistributionType
$sel:localPath:DatasetDefinition' :: DatasetDefinition -> Maybe Text
$sel:athenaDatasetDefinition:DatasetDefinition' :: DatasetDefinition -> Maybe AthenaDatasetDefinition
$sel:redshiftDatasetDefinition:DatasetDefinition' :: DatasetDefinition -> Maybe RedshiftDatasetDefinition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RedshiftDatasetDefinition" Text -> RedshiftDatasetDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RedshiftDatasetDefinition -> Pair)
-> Maybe RedshiftDatasetDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RedshiftDatasetDefinition
redshiftDatasetDefinition,
            (Text
"AthenaDatasetDefinition" Text -> AthenaDatasetDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AthenaDatasetDefinition -> Pair)
-> Maybe AthenaDatasetDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AthenaDatasetDefinition
athenaDatasetDefinition,
            (Text
"LocalPath" 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
localPath,
            (Text
"DataDistributionType" Text -> DataDistributionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DataDistributionType -> Pair)
-> Maybe DataDistributionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DataDistributionType
dataDistributionType,
            (Text
"InputMode" Text -> InputMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputMode -> Pair) -> Maybe InputMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputMode
inputMode
          ]
      )