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

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

-- | Information about a data source.
--
-- /See:/ 'newDataSourceConfig' smart constructor.
data DataSourceConfig = DataSourceConfig'
  { -- | 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.
    DataSourceConfig -> Maybe Text
destination :: 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@.
    DataSourceConfig -> Maybe DataSourceType
type' :: Prelude.Maybe DataSourceType,
    -- | The name of the data source.
    DataSourceConfig -> Text
name :: Prelude.Text,
    -- | The S3 bucket where the data files are located.
    DataSourceConfig -> Text
s3Bucket :: Prelude.Text,
    -- | The list of S3 keys identifying the data source files.
    DataSourceConfig -> NonEmpty Text
s3Keys :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DataSourceConfig -> DataSourceConfig -> Bool
(DataSourceConfig -> DataSourceConfig -> Bool)
-> (DataSourceConfig -> DataSourceConfig -> Bool)
-> Eq DataSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSourceConfig -> DataSourceConfig -> Bool
$c/= :: DataSourceConfig -> DataSourceConfig -> Bool
== :: DataSourceConfig -> DataSourceConfig -> Bool
$c== :: DataSourceConfig -> DataSourceConfig -> Bool
Prelude.Eq, ReadPrec [DataSourceConfig]
ReadPrec DataSourceConfig
Int -> ReadS DataSourceConfig
ReadS [DataSourceConfig]
(Int -> ReadS DataSourceConfig)
-> ReadS [DataSourceConfig]
-> ReadPrec DataSourceConfig
-> ReadPrec [DataSourceConfig]
-> Read DataSourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSourceConfig]
$creadListPrec :: ReadPrec [DataSourceConfig]
readPrec :: ReadPrec DataSourceConfig
$creadPrec :: ReadPrec DataSourceConfig
readList :: ReadS [DataSourceConfig]
$creadList :: ReadS [DataSourceConfig]
readsPrec :: Int -> ReadS DataSourceConfig
$creadsPrec :: Int -> ReadS DataSourceConfig
Prelude.Read, Int -> DataSourceConfig -> ShowS
[DataSourceConfig] -> ShowS
DataSourceConfig -> String
(Int -> DataSourceConfig -> ShowS)
-> (DataSourceConfig -> String)
-> ([DataSourceConfig] -> ShowS)
-> Show DataSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSourceConfig] -> ShowS
$cshowList :: [DataSourceConfig] -> ShowS
show :: DataSourceConfig -> String
$cshow :: DataSourceConfig -> String
showsPrec :: Int -> DataSourceConfig -> ShowS
$cshowsPrec :: Int -> DataSourceConfig -> ShowS
Prelude.Show, (forall x. DataSourceConfig -> Rep DataSourceConfig x)
-> (forall x. Rep DataSourceConfig x -> DataSourceConfig)
-> Generic DataSourceConfig
forall x. Rep DataSourceConfig x -> DataSourceConfig
forall x. DataSourceConfig -> Rep DataSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSourceConfig x -> DataSourceConfig
$cfrom :: forall x. DataSourceConfig -> Rep DataSourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'DataSourceConfig' 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:
--
-- 'destination', 'dataSourceConfig_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.
--
-- 'type'', 'dataSourceConfig_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@.
--
-- 'name', 'dataSourceConfig_name' - The name of the data source.
--
-- 's3Bucket', 'dataSourceConfig_s3Bucket' - The S3 bucket where the data files are located.
--
-- 's3Keys', 'dataSourceConfig_s3Keys' - The list of S3 keys identifying the data source files.
newDataSourceConfig ::
  -- | 'name'
  Prelude.Text ->
  -- | 's3Bucket'
  Prelude.Text ->
  -- | 's3Keys'
  Prelude.NonEmpty Prelude.Text ->
  DataSourceConfig
newDataSourceConfig :: Text -> Text -> NonEmpty Text -> DataSourceConfig
newDataSourceConfig Text
pName_ Text
pS3Bucket_ NonEmpty Text
pS3Keys_ =
  DataSourceConfig' :: Maybe Text
-> Maybe DataSourceType
-> Text
-> Text
-> NonEmpty Text
-> DataSourceConfig
DataSourceConfig'
    { $sel:destination:DataSourceConfig' :: Maybe Text
destination = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DataSourceConfig' :: Maybe DataSourceType
type' = Maybe DataSourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DataSourceConfig' :: Text
name = Text
pName_,
      $sel:s3Bucket:DataSourceConfig' :: Text
s3Bucket = Text
pS3Bucket_,
      $sel:s3Keys:DataSourceConfig' :: NonEmpty Text
s3Keys = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pS3Keys_
    }

-- | 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.
dataSourceConfig_destination :: Lens.Lens' DataSourceConfig (Prelude.Maybe Prelude.Text)
dataSourceConfig_destination :: (Maybe Text -> f (Maybe Text))
-> DataSourceConfig -> f DataSourceConfig
dataSourceConfig_destination = (DataSourceConfig -> Maybe Text)
-> (DataSourceConfig -> Maybe Text -> DataSourceConfig)
-> Lens DataSourceConfig DataSourceConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceConfig' {Maybe Text
destination :: Maybe Text
$sel:destination:DataSourceConfig' :: DataSourceConfig -> Maybe Text
destination} -> Maybe Text
destination) (\s :: DataSourceConfig
s@DataSourceConfig' {} Maybe Text
a -> DataSourceConfig
s {$sel:destination:DataSourceConfig' :: Maybe Text
destination = Maybe Text
a} :: DataSourceConfig)

-- | 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@.
dataSourceConfig_type :: Lens.Lens' DataSourceConfig (Prelude.Maybe DataSourceType)
dataSourceConfig_type :: (Maybe DataSourceType -> f (Maybe DataSourceType))
-> DataSourceConfig -> f DataSourceConfig
dataSourceConfig_type = (DataSourceConfig -> Maybe DataSourceType)
-> (DataSourceConfig -> Maybe DataSourceType -> DataSourceConfig)
-> Lens
     DataSourceConfig
     DataSourceConfig
     (Maybe DataSourceType)
     (Maybe DataSourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceConfig' {Maybe DataSourceType
type' :: Maybe DataSourceType
$sel:type':DataSourceConfig' :: DataSourceConfig -> Maybe DataSourceType
type'} -> Maybe DataSourceType
type') (\s :: DataSourceConfig
s@DataSourceConfig' {} Maybe DataSourceType
a -> DataSourceConfig
s {$sel:type':DataSourceConfig' :: Maybe DataSourceType
type' = Maybe DataSourceType
a} :: DataSourceConfig)

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

-- | The S3 bucket where the data files are located.
dataSourceConfig_s3Bucket :: Lens.Lens' DataSourceConfig Prelude.Text
dataSourceConfig_s3Bucket :: (Text -> f Text) -> DataSourceConfig -> f DataSourceConfig
dataSourceConfig_s3Bucket = (DataSourceConfig -> Text)
-> (DataSourceConfig -> Text -> DataSourceConfig)
-> Lens DataSourceConfig DataSourceConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceConfig' {Text
s3Bucket :: Text
$sel:s3Bucket:DataSourceConfig' :: DataSourceConfig -> Text
s3Bucket} -> Text
s3Bucket) (\s :: DataSourceConfig
s@DataSourceConfig' {} Text
a -> DataSourceConfig
s {$sel:s3Bucket:DataSourceConfig' :: Text
s3Bucket = Text
a} :: DataSourceConfig)

-- | The list of S3 keys identifying the data source files.
dataSourceConfig_s3Keys :: Lens.Lens' DataSourceConfig (Prelude.NonEmpty Prelude.Text)
dataSourceConfig_s3Keys :: (NonEmpty Text -> f (NonEmpty Text))
-> DataSourceConfig -> f DataSourceConfig
dataSourceConfig_s3Keys = (DataSourceConfig -> NonEmpty Text)
-> (DataSourceConfig -> NonEmpty Text -> DataSourceConfig)
-> Lens
     DataSourceConfig DataSourceConfig (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceConfig' {NonEmpty Text
s3Keys :: NonEmpty Text
$sel:s3Keys:DataSourceConfig' :: DataSourceConfig -> NonEmpty Text
s3Keys} -> NonEmpty Text
s3Keys) (\s :: DataSourceConfig
s@DataSourceConfig' {} NonEmpty Text
a -> DataSourceConfig
s {$sel:s3Keys:DataSourceConfig' :: NonEmpty Text
s3Keys = NonEmpty Text
a} :: DataSourceConfig) ((NonEmpty Text -> f (NonEmpty Text))
 -> DataSourceConfig -> f DataSourceConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> DataSourceConfig
-> f DataSourceConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON DataSourceConfig where
  parseJSON :: Value -> Parser DataSourceConfig
parseJSON =
    String
-> (Object -> Parser DataSourceConfig)
-> Value
-> Parser DataSourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataSourceConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe DataSourceType
-> Text
-> Text
-> NonEmpty Text
-> DataSourceConfig
DataSourceConfig'
            (Maybe Text
 -> Maybe DataSourceType
 -> Text
 -> Text
 -> NonEmpty Text
 -> DataSourceConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe DataSourceType
      -> Text -> Text -> NonEmpty Text -> DataSourceConfig)
forall (f :: * -> *) a b. Functor 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 DataSourceType
   -> Text -> Text -> NonEmpty Text -> DataSourceConfig)
-> Parser (Maybe DataSourceType)
-> Parser (Text -> Text -> NonEmpty Text -> DataSourceConfig)
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 (Text -> Text -> NonEmpty Text -> DataSourceConfig)
-> Parser Text
-> Parser (Text -> NonEmpty Text -> DataSourceConfig)
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
"name")
            Parser (Text -> NonEmpty Text -> DataSourceConfig)
-> Parser Text -> Parser (NonEmpty Text -> DataSourceConfig)
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
"s3Bucket")
            Parser (NonEmpty Text -> DataSourceConfig)
-> Parser (NonEmpty Text) -> Parser DataSourceConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"s3Keys")
      )

instance Prelude.Hashable DataSourceConfig

instance Prelude.NFData DataSourceConfig

instance Core.ToJSON DataSourceConfig where
  toJSON :: DataSourceConfig -> Value
toJSON DataSourceConfig' {Maybe Text
Maybe DataSourceType
NonEmpty Text
Text
s3Keys :: NonEmpty Text
s3Bucket :: Text
name :: Text
type' :: Maybe DataSourceType
destination :: Maybe Text
$sel:s3Keys:DataSourceConfig' :: DataSourceConfig -> NonEmpty Text
$sel:s3Bucket:DataSourceConfig' :: DataSourceConfig -> Text
$sel:name:DataSourceConfig' :: DataSourceConfig -> Text
$sel:type':DataSourceConfig' :: DataSourceConfig -> Maybe DataSourceType
$sel:destination:DataSourceConfig' :: DataSourceConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"destination" 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
destination,
            (Text
"type" Text -> DataSourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DataSourceType -> Pair) -> Maybe DataSourceType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DataSourceType
type',
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"s3Bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3Bucket),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"s3Keys" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
s3Keys)
          ]
      )