{-# 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.RobOMaker.Types.DataSource
-- 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.RobOMaker.Types.DataSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.DataSourceType
import Amazonka.RobOMaker.Types.S3KeyOutput

-- | Information about a data source.
--
-- /See:/ 'newDataSource' smart constructor.
data DataSource = DataSource'
  { -- | The list of S3 keys identifying the data source files.
    DataSource -> Maybe [S3KeyOutput]
s3Keys :: Prelude.Maybe [S3KeyOutput],
    -- | The location where your files are mounted in the container image.
    --
    -- If you\'ve specified the @type@ of the data source as an @Archive@, you
    -- must provide an Amazon S3 object key to your archive. The object key
    -- must point to either a @.zip@ or @.tar.gz@ file.
    --
    -- If you\'ve specified the @type@ of the data source as a @Prefix@, you
    -- provide the Amazon S3 prefix that points to the files that you are using
    -- for your data source.
    --
    -- If you\'ve specified the @type@ of the data source as a @File@, you
    -- provide the Amazon S3 path to the file that you\'re using as your data
    -- source.
    DataSource -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | The name of the data source.
    DataSource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The data type for the data source that you\'re using for your container
    -- image or simulation job. You can use this field to specify whether your
    -- data source is an Archive, an Amazon S3 prefix, or a file.
    --
    -- If you don\'t specify a field, the default value is @File@.
    DataSource -> Maybe DataSourceType
type' :: Prelude.Maybe DataSourceType,
    -- | The S3 bucket where the data files are located.
    DataSource -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text
  }
  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)

-- |
-- Create a value of 'DataSource' 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:
--
-- 's3Keys', 'dataSource_s3Keys' - The list of S3 keys identifying the data source files.
--
-- 'destination', 'dataSource_destination' - The location where your files are mounted in the container image.
--
-- If you\'ve specified the @type@ of the data source as an @Archive@, you
-- must provide an Amazon S3 object key to your archive. The object key
-- must point to either a @.zip@ or @.tar.gz@ file.
--
-- If you\'ve specified the @type@ of the data source as a @Prefix@, you
-- provide the Amazon S3 prefix that points to the files that you are using
-- for your data source.
--
-- If you\'ve specified the @type@ of the data source as a @File@, you
-- provide the Amazon S3 path to the file that you\'re using as your data
-- source.
--
-- 'name', 'dataSource_name' - The name of the data source.
--
-- 'type'', 'dataSource_type' - The data type for the data source that you\'re using for your container
-- image or simulation job. You can use this field to specify whether your
-- data source is an Archive, an Amazon S3 prefix, or a file.
--
-- If you don\'t specify a field, the default value is @File@.
--
-- 's3Bucket', 'dataSource_s3Bucket' - The S3 bucket where the data files are located.
newDataSource ::
  DataSource
newDataSource :: DataSource
newDataSource =
  DataSource' :: Maybe [S3KeyOutput]
-> Maybe Text
-> Maybe Text
-> Maybe DataSourceType
-> Maybe Text
-> DataSource
DataSource'
    { $sel:s3Keys:DataSource' :: Maybe [S3KeyOutput]
s3Keys = Maybe [S3KeyOutput]
forall a. Maybe a
Prelude.Nothing,
      $sel:destination:DataSource' :: Maybe Text
destination = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DataSource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DataSource' :: Maybe DataSourceType
type' = Maybe DataSourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:DataSource' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of S3 keys identifying the data source files.
dataSource_s3Keys :: Lens.Lens' DataSource (Prelude.Maybe [S3KeyOutput])
dataSource_s3Keys :: (Maybe [S3KeyOutput] -> f (Maybe [S3KeyOutput]))
-> DataSource -> f DataSource
dataSource_s3Keys = (DataSource -> Maybe [S3KeyOutput])
-> (DataSource -> Maybe [S3KeyOutput] -> DataSource)
-> Lens
     DataSource DataSource (Maybe [S3KeyOutput]) (Maybe [S3KeyOutput])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe [S3KeyOutput]
s3Keys :: Maybe [S3KeyOutput]
$sel:s3Keys:DataSource' :: DataSource -> Maybe [S3KeyOutput]
s3Keys} -> Maybe [S3KeyOutput]
s3Keys) (\s :: DataSource
s@DataSource' {} Maybe [S3KeyOutput]
a -> DataSource
s {$sel:s3Keys:DataSource' :: Maybe [S3KeyOutput]
s3Keys = Maybe [S3KeyOutput]
a} :: DataSource) ((Maybe [S3KeyOutput] -> f (Maybe [S3KeyOutput]))
 -> DataSource -> f DataSource)
-> ((Maybe [S3KeyOutput] -> f (Maybe [S3KeyOutput]))
    -> Maybe [S3KeyOutput] -> f (Maybe [S3KeyOutput]))
-> (Maybe [S3KeyOutput] -> f (Maybe [S3KeyOutput]))
-> DataSource
-> f DataSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [S3KeyOutput] [S3KeyOutput] [S3KeyOutput] [S3KeyOutput]
-> Iso
     (Maybe [S3KeyOutput])
     (Maybe [S3KeyOutput])
     (Maybe [S3KeyOutput])
     (Maybe [S3KeyOutput])
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 [S3KeyOutput] [S3KeyOutput] [S3KeyOutput] [S3KeyOutput]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The location where your files are mounted in the container image.
--
-- If you\'ve specified the @type@ of the data source as an @Archive@, you
-- must provide an Amazon S3 object key to your archive. The object key
-- must point to either a @.zip@ or @.tar.gz@ file.
--
-- If you\'ve specified the @type@ of the data source as a @Prefix@, you
-- provide the Amazon S3 prefix that points to the files that you are using
-- for your data source.
--
-- If you\'ve specified the @type@ of the data source as a @File@, you
-- provide the Amazon S3 path to the file that you\'re using as your data
-- source.
dataSource_destination :: Lens.Lens' DataSource (Prelude.Maybe Prelude.Text)
dataSource_destination :: (Maybe Text -> f (Maybe Text)) -> DataSource -> f DataSource
dataSource_destination = (DataSource -> Maybe Text)
-> (DataSource -> Maybe Text -> DataSource)
-> Lens DataSource DataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe Text
destination :: Maybe Text
$sel:destination:DataSource' :: DataSource -> Maybe Text
destination} -> Maybe Text
destination) (\s :: DataSource
s@DataSource' {} Maybe Text
a -> DataSource
s {$sel:destination:DataSource' :: Maybe Text
destination = Maybe Text
a} :: DataSource)

-- | The name of the data source.
dataSource_name :: Lens.Lens' DataSource (Prelude.Maybe Prelude.Text)
dataSource_name :: (Maybe Text -> f (Maybe Text)) -> DataSource -> f DataSource
dataSource_name = (DataSource -> Maybe Text)
-> (DataSource -> Maybe Text -> DataSource)
-> Lens DataSource DataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe Text
name :: Maybe Text
$sel:name:DataSource' :: DataSource -> Maybe Text
name} -> Maybe Text
name) (\s :: DataSource
s@DataSource' {} Maybe Text
a -> DataSource
s {$sel:name:DataSource' :: Maybe Text
name = Maybe Text
a} :: DataSource)

-- | The data type for the data source that you\'re using for your container
-- image or simulation job. You can use this field to specify whether your
-- data source is an Archive, an Amazon S3 prefix, or a file.
--
-- If you don\'t specify a field, the default value is @File@.
dataSource_type :: Lens.Lens' DataSource (Prelude.Maybe DataSourceType)
dataSource_type :: (Maybe DataSourceType -> f (Maybe DataSourceType))
-> DataSource -> f DataSource
dataSource_type = (DataSource -> Maybe DataSourceType)
-> (DataSource -> Maybe DataSourceType -> DataSource)
-> Lens
     DataSource DataSource (Maybe DataSourceType) (Maybe DataSourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe DataSourceType
type' :: Maybe DataSourceType
$sel:type':DataSource' :: DataSource -> Maybe DataSourceType
type'} -> Maybe DataSourceType
type') (\s :: DataSource
s@DataSource' {} Maybe DataSourceType
a -> DataSource
s {$sel:type':DataSource' :: Maybe DataSourceType
type' = Maybe DataSourceType
a} :: DataSource)

-- | The S3 bucket where the data files are located.
dataSource_s3Bucket :: Lens.Lens' DataSource (Prelude.Maybe Prelude.Text)
dataSource_s3Bucket :: (Maybe Text -> f (Maybe Text)) -> DataSource -> f DataSource
dataSource_s3Bucket = (DataSource -> Maybe Text)
-> (DataSource -> Maybe Text -> DataSource)
-> Lens DataSource DataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:DataSource' :: DataSource -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: DataSource
s@DataSource' {} Maybe Text
a -> DataSource
s {$sel:s3Bucket:DataSource' :: Maybe Text
s3Bucket = Maybe Text
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 [S3KeyOutput]
-> Maybe Text
-> Maybe Text
-> Maybe DataSourceType
-> Maybe Text
-> DataSource
DataSource'
            (Maybe [S3KeyOutput]
 -> Maybe Text
 -> Maybe Text
 -> Maybe DataSourceType
 -> Maybe Text
 -> DataSource)
-> Parser (Maybe [S3KeyOutput])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe DataSourceType -> Maybe Text -> DataSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [S3KeyOutput]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Keys" Parser (Maybe (Maybe [S3KeyOutput]))
-> Maybe [S3KeyOutput] -> Parser (Maybe [S3KeyOutput])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [S3KeyOutput]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe DataSourceType -> Maybe Text -> DataSource)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe DataSourceType -> Maybe Text -> DataSource)
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
"destination")
            Parser
  (Maybe Text -> Maybe DataSourceType -> Maybe Text -> DataSource)
-> Parser (Maybe Text)
-> Parser (Maybe DataSourceType -> Maybe Text -> DataSource)
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
"name")
            Parser (Maybe DataSourceType -> Maybe Text -> DataSource)
-> Parser (Maybe DataSourceType)
-> Parser (Maybe Text -> DataSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DataSourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
            Parser (Maybe Text -> DataSource)
-> Parser (Maybe Text) -> Parser DataSource
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
"s3Bucket")
      )

instance Prelude.Hashable DataSource

instance Prelude.NFData DataSource