{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Personalize.Types.DataSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:dataLocation:DataSource' :: Maybe Text
dataLocation = 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 :: Lens' DataSource (Maybe Text)
dataSource_dataLocation = 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 Data.FromJSON DataSource where
  parseJSON :: Value -> Parser DataSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataSource"
      ( \Object
x ->
          Maybe Text -> DataSource
DataSource' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"dataLocation")
      )

instance Prelude.Hashable DataSource where
  hashWithSalt :: Int -> DataSource -> Int
hashWithSalt Int
_salt DataSource' {Maybe Text
dataLocation :: Maybe Text
$sel:dataLocation:DataSource' :: DataSource -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataLocation

instance Prelude.NFData DataSource where
  rnf :: DataSource -> ()
rnf DataSource' {Maybe Text
dataLocation :: Maybe Text
$sel:dataLocation:DataSource' :: DataSource -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataLocation

instance Data.ToJSON DataSource where
  toJSON :: DataSource -> Value
toJSON DataSource' {Maybe Text
dataLocation :: Maybe Text
$sel:dataLocation:DataSource' :: DataSource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"dataLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataLocation]
      )