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

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.S3Config
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The source of your training data, an AWS Identity and Access Management
-- (IAM) role that allows Amazon Forecast to access the data and,
-- optionally, an AWS Key Management Service (KMS) key. This object is
-- submitted in the CreateDatasetImportJob request.
--
-- /See:/ 'newDataSource' smart constructor.
data DataSource = DataSource'
  { -- | The path to the training data stored in an Amazon Simple Storage Service
    -- (Amazon S3) bucket along with the credentials to access the data.
    DataSource -> S3Config
s3Config :: S3Config
  }
  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:
--
-- 's3Config', 'dataSource_s3Config' - The path to the training data stored in an Amazon Simple Storage Service
-- (Amazon S3) bucket along with the credentials to access the data.
newDataSource ::
  -- | 's3Config'
  S3Config ->
  DataSource
newDataSource :: S3Config -> DataSource
newDataSource S3Config
pS3Config_ =
  DataSource' :: S3Config -> DataSource
DataSource' {$sel:s3Config:DataSource' :: S3Config
s3Config = S3Config
pS3Config_}

-- | The path to the training data stored in an Amazon Simple Storage Service
-- (Amazon S3) bucket along with the credentials to access the data.
dataSource_s3Config :: Lens.Lens' DataSource S3Config
dataSource_s3Config :: (S3Config -> f S3Config) -> DataSource -> f DataSource
dataSource_s3Config = (DataSource -> S3Config)
-> (DataSource -> S3Config -> DataSource)
-> Lens DataSource DataSource S3Config S3Config
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSource' {S3Config
s3Config :: S3Config
$sel:s3Config:DataSource' :: DataSource -> S3Config
s3Config} -> S3Config
s3Config) (\s :: DataSource
s@DataSource' {} S3Config
a -> DataSource
s {$sel:s3Config:DataSource' :: S3Config
s3Config = S3Config
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 ->
          S3Config -> DataSource
DataSource' (S3Config -> DataSource) -> Parser S3Config -> Parser DataSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser S3Config
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3Config")
      )

instance Prelude.Hashable DataSource

instance Prelude.NFData DataSource

instance Core.ToJSON DataSource where
  toJSON :: DataSource -> Value
toJSON DataSource' {S3Config
s3Config :: S3Config
$sel:s3Config:DataSource' :: DataSource -> S3Config
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3Config" Text -> S3Config -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= S3Config
s3Config)]
      )