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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.S3Config
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
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]
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
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. 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' {$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 :: Lens' DataDestination S3Config
dataDestination_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 Data.FromJSON DataDestination where
  parseJSON :: Value -> Parser DataDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataDestination"
      ( \Object
x ->
          S3Config -> DataDestination
DataDestination' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"S3Config")
      )

instance Prelude.Hashable DataDestination where
  hashWithSalt :: Int -> DataDestination -> Int
hashWithSalt Int
_salt DataDestination' {S3Config
s3Config :: S3Config
$sel:s3Config:DataDestination' :: DataDestination -> S3Config
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` S3Config
s3Config

instance Prelude.NFData DataDestination where
  rnf :: DataDestination -> ()
rnf DataDestination' {S3Config
s3Config :: S3Config
$sel:s3Config:DataDestination' :: DataDestination -> S3Config
..} = forall a. NFData a => a -> ()
Prelude.rnf S3Config
s3Config

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