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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the data source that contains the data to upload to a dataset.
--
-- /See:/ 'newDataSource' smart constructor.
data DataSource = DataSource'
  { -- | The path to the Amazon S3 bucket where the data that you want to upload
    -- to your dataset is stored. For example:
    --
    -- @s3:\/\/bucket-name\/folder-name\/@
    DataSource -> Maybe Text
dataLocation :: 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:
--
-- 'dataLocation', 'dataSource_dataLocation' - The path to the Amazon S3 bucket where the data that you want to upload
-- to your dataset is stored. For example:
--
-- @s3:\/\/bucket-name\/folder-name\/@
newDataSource ::
  DataSource
newDataSource :: DataSource
newDataSource =
  DataSource' :: Maybe Text -> DataSource
DataSource' {$sel:dataLocation:DataSource' :: Maybe Text
dataLocation = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The path to the Amazon S3 bucket where the data that you want to upload
-- to your dataset is stored. For example:
--
-- @s3:\/\/bucket-name\/folder-name\/@
dataSource_dataLocation :: Lens.Lens' DataSource (Prelude.Maybe Prelude.Text)
dataSource_dataLocation :: (Maybe Text -> f (Maybe Text)) -> DataSource -> f DataSource
dataSource_dataLocation = (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
dataLocation :: Maybe Text
$sel:dataLocation:DataSource' :: DataSource -> Maybe Text
dataLocation} -> Maybe Text
dataLocation) (\s :: DataSource
s@DataSource' {} Maybe Text
a -> DataSource
s {$sel:dataLocation:DataSource' :: Maybe Text
dataLocation = 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 Text -> DataSource
DataSource' (Maybe Text -> DataSource)
-> Parser (Maybe Text) -> Parser DataSource
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
"dataLocation")
      )

instance Prelude.Hashable DataSource

instance Prelude.NFData DataSource

instance Core.ToJSON DataSource where
  toJSON :: DataSource -> Value
toJSON DataSource' {Maybe Text
dataLocation :: Maybe Text
$sel:dataLocation:DataSource' :: DataSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"dataLocation" 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
dataLocation]
      )