{-# 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 #-}
module Amazonka.SageMaker.Types.DataSource where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.FileSystemDataSource
import Amazonka.SageMaker.Types.S3DataSource
data DataSource = DataSource'
{
DataSource -> Maybe S3DataSource
s3DataSource :: Prelude.Maybe S3DataSource,
DataSource -> Maybe FileSystemDataSource
fileSystemDataSource :: Prelude.Maybe FileSystemDataSource
}
deriving (DataSource -> DataSource -> Bool
(DataSource -> DataSource -> Bool)
-> (DataSource -> DataSource -> Bool) -> Eq DataSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSource -> DataSource -> Bool
$c/= :: DataSource -> DataSource -> Bool
== :: DataSource -> DataSource -> Bool
$c== :: DataSource -> DataSource -> Bool
Prelude.Eq, ReadPrec [DataSource]
ReadPrec DataSource
Int -> ReadS DataSource
ReadS [DataSource]
(Int -> ReadS DataSource)
-> ReadS [DataSource]
-> ReadPrec DataSource
-> ReadPrec [DataSource]
-> Read DataSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSource]
$creadListPrec :: ReadPrec [DataSource]
readPrec :: ReadPrec DataSource
$creadPrec :: ReadPrec DataSource
readList :: ReadS [DataSource]
$creadList :: ReadS [DataSource]
readsPrec :: Int -> ReadS DataSource
$creadsPrec :: Int -> ReadS DataSource
Prelude.Read, Int -> DataSource -> ShowS
[DataSource] -> ShowS
DataSource -> String
(Int -> DataSource -> ShowS)
-> (DataSource -> String)
-> ([DataSource] -> ShowS)
-> Show DataSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSource] -> ShowS
$cshowList :: [DataSource] -> ShowS
show :: DataSource -> String
$cshow :: DataSource -> String
showsPrec :: Int -> DataSource -> ShowS
$cshowsPrec :: Int -> DataSource -> ShowS
Prelude.Show, (forall x. DataSource -> Rep DataSource x)
-> (forall x. Rep DataSource x -> DataSource) -> Generic DataSource
forall x. Rep DataSource x -> DataSource
forall x. DataSource -> Rep DataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSource x -> DataSource
$cfrom :: forall x. DataSource -> Rep DataSource x
Prelude.Generic)
newDataSource ::
DataSource
newDataSource :: DataSource
newDataSource =
DataSource' :: Maybe S3DataSource -> Maybe FileSystemDataSource -> DataSource
DataSource'
{ $sel:s3DataSource:DataSource' :: Maybe S3DataSource
s3DataSource = Maybe S3DataSource
forall a. Maybe a
Prelude.Nothing,
$sel:fileSystemDataSource:DataSource' :: Maybe FileSystemDataSource
fileSystemDataSource = Maybe FileSystemDataSource
forall a. Maybe a
Prelude.Nothing
}
dataSource_s3DataSource :: Lens.Lens' DataSource (Prelude.Maybe S3DataSource)
dataSource_s3DataSource :: (Maybe S3DataSource -> f (Maybe S3DataSource))
-> DataSource -> f DataSource
dataSource_s3DataSource = (DataSource -> Maybe S3DataSource)
-> (DataSource -> Maybe S3DataSource -> DataSource)
-> Lens
DataSource DataSource (Maybe S3DataSource) (Maybe S3DataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe S3DataSource
s3DataSource :: Maybe S3DataSource
$sel:s3DataSource:DataSource' :: DataSource -> Maybe S3DataSource
s3DataSource} -> Maybe S3DataSource
s3DataSource) (\s :: DataSource
s@DataSource' {} Maybe S3DataSource
a -> DataSource
s {$sel:s3DataSource:DataSource' :: Maybe S3DataSource
s3DataSource = Maybe S3DataSource
a} :: DataSource)
dataSource_fileSystemDataSource :: Lens.Lens' DataSource (Prelude.Maybe FileSystemDataSource)
dataSource_fileSystemDataSource :: (Maybe FileSystemDataSource -> f (Maybe FileSystemDataSource))
-> DataSource -> f DataSource
dataSource_fileSystemDataSource = (DataSource -> Maybe FileSystemDataSource)
-> (DataSource -> Maybe FileSystemDataSource -> DataSource)
-> Lens
DataSource
DataSource
(Maybe FileSystemDataSource)
(Maybe FileSystemDataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe FileSystemDataSource
fileSystemDataSource :: Maybe FileSystemDataSource
$sel:fileSystemDataSource:DataSource' :: DataSource -> Maybe FileSystemDataSource
fileSystemDataSource} -> Maybe FileSystemDataSource
fileSystemDataSource) (\s :: DataSource
s@DataSource' {} Maybe FileSystemDataSource
a -> DataSource
s {$sel:fileSystemDataSource:DataSource' :: Maybe FileSystemDataSource
fileSystemDataSource = Maybe FileSystemDataSource
a} :: DataSource)
instance Core.FromJSON DataSource where
parseJSON :: Value -> Parser DataSource
parseJSON =
String
-> (Object -> Parser DataSource) -> Value -> Parser DataSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DataSource"
( \Object
x ->
Maybe S3DataSource -> Maybe FileSystemDataSource -> DataSource
DataSource'
(Maybe S3DataSource -> Maybe FileSystemDataSource -> DataSource)
-> Parser (Maybe S3DataSource)
-> Parser (Maybe FileSystemDataSource -> DataSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe S3DataSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3DataSource")
Parser (Maybe FileSystemDataSource -> DataSource)
-> Parser (Maybe FileSystemDataSource) -> Parser DataSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileSystemDataSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FileSystemDataSource")
)
instance Prelude.Hashable DataSource
instance Prelude.NFData DataSource
instance Core.ToJSON DataSource where
toJSON :: DataSource -> Value
toJSON DataSource' {Maybe FileSystemDataSource
Maybe S3DataSource
fileSystemDataSource :: Maybe FileSystemDataSource
s3DataSource :: Maybe S3DataSource
$sel:fileSystemDataSource:DataSource' :: DataSource -> Maybe FileSystemDataSource
$sel:s3DataSource:DataSource' :: DataSource -> Maybe S3DataSource
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"S3DataSource" Text -> S3DataSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3DataSource -> Pair) -> Maybe S3DataSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3DataSource
s3DataSource,
(Text
"FileSystemDataSource" Text -> FileSystemDataSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(FileSystemDataSource -> Pair)
-> Maybe FileSystemDataSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileSystemDataSource
fileSystemDataSource
]
)