{-# 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.DataDestination
-- 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.DataDestination 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 destination for an export job. Provide an S3 path, an AWS Identity
-- and Access Management (IAM) role that allows Amazon Forecast to access
-- the location, and an AWS Key Management Service (KMS) key (optional).
--
-- /See:/ 'newDataDestination' smart constructor.
data DataDestination = DataDestination'
  { -- | The path to an Amazon Simple Storage Service (Amazon S3) bucket along
    -- with the credentials to access the bucket.
    DataDestination -> S3Config
s3Config :: S3Config
  }
  deriving (DataDestination -> DataDestination -> Bool
(DataDestination -> DataDestination -> Bool)
-> (DataDestination -> DataDestination -> Bool)
-> Eq DataDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataDestination -> DataDestination -> Bool
$c/= :: DataDestination -> DataDestination -> Bool
== :: DataDestination -> DataDestination -> Bool
$c== :: DataDestination -> DataDestination -> Bool
Prelude.Eq, ReadPrec [DataDestination]
ReadPrec DataDestination
Int -> ReadS DataDestination
ReadS [DataDestination]
(Int -> ReadS DataDestination)
-> ReadS [DataDestination]
-> ReadPrec DataDestination
-> ReadPrec [DataDestination]
-> Read DataDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataDestination]
$creadListPrec :: ReadPrec [DataDestination]
readPrec :: ReadPrec DataDestination
$creadPrec :: ReadPrec DataDestination
readList :: ReadS [DataDestination]
$creadList :: ReadS [DataDestination]
readsPrec :: Int -> ReadS DataDestination
$creadsPrec :: Int -> ReadS DataDestination
Prelude.Read, Int -> DataDestination -> ShowS
[DataDestination] -> ShowS
DataDestination -> String
(Int -> DataDestination -> ShowS)
-> (DataDestination -> String)
-> ([DataDestination] -> ShowS)
-> Show DataDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataDestination] -> ShowS
$cshowList :: [DataDestination] -> ShowS
show :: DataDestination -> String
$cshow :: DataDestination -> String
showsPrec :: Int -> DataDestination -> ShowS
$cshowsPrec :: Int -> DataDestination -> ShowS
Prelude.Show, (forall x. DataDestination -> Rep DataDestination x)
-> (forall x. Rep DataDestination x -> DataDestination)
-> Generic DataDestination
forall x. Rep DataDestination x -> DataDestination
forall x. DataDestination -> Rep DataDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataDestination x -> DataDestination
$cfrom :: forall x. DataDestination -> Rep DataDestination x
Prelude.Generic)

-- |
-- Create a value of 'DataDestination' 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', 'dataDestination_s3Config' - The path to an Amazon Simple Storage Service (Amazon S3) bucket along
-- with the credentials to access the bucket.
newDataDestination ::
  -- | 's3Config'
  S3Config ->
  DataDestination
newDataDestination :: S3Config -> DataDestination
newDataDestination S3Config
pS3Config_ =
  DataDestination' :: S3Config -> DataDestination
DataDestination' {$sel:s3Config:DataDestination' :: S3Config
s3Config = S3Config
pS3Config_}

-- | The path to an Amazon Simple Storage Service (Amazon S3) bucket along
-- with the credentials to access the bucket.
dataDestination_s3Config :: Lens.Lens' DataDestination S3Config
dataDestination_s3Config :: (S3Config -> f S3Config) -> DataDestination -> f DataDestination
dataDestination_s3Config = (DataDestination -> S3Config)
-> (DataDestination -> S3Config -> DataDestination)
-> Lens DataDestination DataDestination S3Config S3Config
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataDestination' {S3Config
s3Config :: S3Config
$sel:s3Config:DataDestination' :: DataDestination -> S3Config
s3Config} -> S3Config
s3Config) (\s :: DataDestination
s@DataDestination' {} S3Config
a -> DataDestination
s {$sel:s3Config:DataDestination' :: S3Config
s3Config = S3Config
a} :: DataDestination)

instance Core.FromJSON DataDestination where
  parseJSON :: Value -> Parser DataDestination
parseJSON =
    String
-> (Object -> Parser DataDestination)
-> Value
-> Parser DataDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataDestination"
      ( \Object
x ->
          S3Config -> DataDestination
DataDestination' (S3Config -> DataDestination)
-> Parser S3Config -> Parser DataDestination
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 DataDestination

instance Prelude.NFData DataDestination

instance Core.ToJSON DataDestination where
  toJSON :: DataDestination -> Value
toJSON DataDestination' {S3Config
s3Config :: S3Config
$sel:s3Config:DataDestination' :: DataDestination -> 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)]
      )