{-# 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.AppFlow.Types.RedshiftDestinationProperties
-- 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.AppFlow.Types.RedshiftDestinationProperties where

import Amazonka.AppFlow.Types.ErrorHandlingConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The properties that are applied when Amazon Redshift is being used as a
-- destination.
--
-- /See:/ 'newRedshiftDestinationProperties' smart constructor.
data RedshiftDestinationProperties = RedshiftDestinationProperties'
  { -- | The object key for the bucket in which Amazon AppFlow places the
    -- destination files.
    RedshiftDestinationProperties -> Maybe Text
bucketPrefix :: Prelude.Maybe Prelude.Text,
    -- | The settings that determine how Amazon AppFlow handles an error when
    -- placing data in the Amazon Redshift destination. For example, this
    -- setting would determine if the flow should fail after one insertion
    -- error, or continue and attempt to insert every record regardless of the
    -- initial failure. @ErrorHandlingConfig@ is a part of the destination
    -- connector details.
    RedshiftDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig :: Prelude.Maybe ErrorHandlingConfig,
    -- | The object specified in the Amazon Redshift flow destination.
    RedshiftDestinationProperties -> Text
object' :: Prelude.Text,
    -- | The intermediate bucket that Amazon AppFlow uses when moving data into
    -- Amazon Redshift.
    RedshiftDestinationProperties -> Text
intermediateBucketName :: Prelude.Text
  }
  deriving (RedshiftDestinationProperties
-> RedshiftDestinationProperties -> Bool
(RedshiftDestinationProperties
 -> RedshiftDestinationProperties -> Bool)
-> (RedshiftDestinationProperties
    -> RedshiftDestinationProperties -> Bool)
-> Eq RedshiftDestinationProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftDestinationProperties
-> RedshiftDestinationProperties -> Bool
$c/= :: RedshiftDestinationProperties
-> RedshiftDestinationProperties -> Bool
== :: RedshiftDestinationProperties
-> RedshiftDestinationProperties -> Bool
$c== :: RedshiftDestinationProperties
-> RedshiftDestinationProperties -> Bool
Prelude.Eq, ReadPrec [RedshiftDestinationProperties]
ReadPrec RedshiftDestinationProperties
Int -> ReadS RedshiftDestinationProperties
ReadS [RedshiftDestinationProperties]
(Int -> ReadS RedshiftDestinationProperties)
-> ReadS [RedshiftDestinationProperties]
-> ReadPrec RedshiftDestinationProperties
-> ReadPrec [RedshiftDestinationProperties]
-> Read RedshiftDestinationProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftDestinationProperties]
$creadListPrec :: ReadPrec [RedshiftDestinationProperties]
readPrec :: ReadPrec RedshiftDestinationProperties
$creadPrec :: ReadPrec RedshiftDestinationProperties
readList :: ReadS [RedshiftDestinationProperties]
$creadList :: ReadS [RedshiftDestinationProperties]
readsPrec :: Int -> ReadS RedshiftDestinationProperties
$creadsPrec :: Int -> ReadS RedshiftDestinationProperties
Prelude.Read, Int -> RedshiftDestinationProperties -> ShowS
[RedshiftDestinationProperties] -> ShowS
RedshiftDestinationProperties -> String
(Int -> RedshiftDestinationProperties -> ShowS)
-> (RedshiftDestinationProperties -> String)
-> ([RedshiftDestinationProperties] -> ShowS)
-> Show RedshiftDestinationProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftDestinationProperties] -> ShowS
$cshowList :: [RedshiftDestinationProperties] -> ShowS
show :: RedshiftDestinationProperties -> String
$cshow :: RedshiftDestinationProperties -> String
showsPrec :: Int -> RedshiftDestinationProperties -> ShowS
$cshowsPrec :: Int -> RedshiftDestinationProperties -> ShowS
Prelude.Show, (forall x.
 RedshiftDestinationProperties
 -> Rep RedshiftDestinationProperties x)
-> (forall x.
    Rep RedshiftDestinationProperties x
    -> RedshiftDestinationProperties)
-> Generic RedshiftDestinationProperties
forall x.
Rep RedshiftDestinationProperties x
-> RedshiftDestinationProperties
forall x.
RedshiftDestinationProperties
-> Rep RedshiftDestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RedshiftDestinationProperties x
-> RedshiftDestinationProperties
$cfrom :: forall x.
RedshiftDestinationProperties
-> Rep RedshiftDestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftDestinationProperties' 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:
--
-- 'bucketPrefix', 'redshiftDestinationProperties_bucketPrefix' - The object key for the bucket in which Amazon AppFlow places the
-- destination files.
--
-- 'errorHandlingConfig', 'redshiftDestinationProperties_errorHandlingConfig' - The settings that determine how Amazon AppFlow handles an error when
-- placing data in the Amazon Redshift destination. For example, this
-- setting would determine if the flow should fail after one insertion
-- error, or continue and attempt to insert every record regardless of the
-- initial failure. @ErrorHandlingConfig@ is a part of the destination
-- connector details.
--
-- 'object'', 'redshiftDestinationProperties_object' - The object specified in the Amazon Redshift flow destination.
--
-- 'intermediateBucketName', 'redshiftDestinationProperties_intermediateBucketName' - The intermediate bucket that Amazon AppFlow uses when moving data into
-- Amazon Redshift.
newRedshiftDestinationProperties ::
  -- | 'object''
  Prelude.Text ->
  -- | 'intermediateBucketName'
  Prelude.Text ->
  RedshiftDestinationProperties
newRedshiftDestinationProperties :: Text -> Text -> RedshiftDestinationProperties
newRedshiftDestinationProperties
  Text
pObject_
  Text
pIntermediateBucketName_ =
    RedshiftDestinationProperties' :: Maybe Text
-> Maybe ErrorHandlingConfig
-> Text
-> Text
-> RedshiftDestinationProperties
RedshiftDestinationProperties'
      { $sel:bucketPrefix:RedshiftDestinationProperties' :: Maybe Text
bucketPrefix =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:errorHandlingConfig:RedshiftDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:object':RedshiftDestinationProperties' :: Text
object' = Text
pObject_,
        $sel:intermediateBucketName:RedshiftDestinationProperties' :: Text
intermediateBucketName =
          Text
pIntermediateBucketName_
      }

-- | The object key for the bucket in which Amazon AppFlow places the
-- destination files.
redshiftDestinationProperties_bucketPrefix :: Lens.Lens' RedshiftDestinationProperties (Prelude.Maybe Prelude.Text)
redshiftDestinationProperties_bucketPrefix :: (Maybe Text -> f (Maybe Text))
-> RedshiftDestinationProperties -> f RedshiftDestinationProperties
redshiftDestinationProperties_bucketPrefix = (RedshiftDestinationProperties -> Maybe Text)
-> (RedshiftDestinationProperties
    -> Maybe Text -> RedshiftDestinationProperties)
-> Lens
     RedshiftDestinationProperties
     RedshiftDestinationProperties
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDestinationProperties' {Maybe Text
bucketPrefix :: Maybe Text
$sel:bucketPrefix:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Maybe Text
bucketPrefix} -> Maybe Text
bucketPrefix) (\s :: RedshiftDestinationProperties
s@RedshiftDestinationProperties' {} Maybe Text
a -> RedshiftDestinationProperties
s {$sel:bucketPrefix:RedshiftDestinationProperties' :: Maybe Text
bucketPrefix = Maybe Text
a} :: RedshiftDestinationProperties)

-- | The settings that determine how Amazon AppFlow handles an error when
-- placing data in the Amazon Redshift destination. For example, this
-- setting would determine if the flow should fail after one insertion
-- error, or continue and attempt to insert every record regardless of the
-- initial failure. @ErrorHandlingConfig@ is a part of the destination
-- connector details.
redshiftDestinationProperties_errorHandlingConfig :: Lens.Lens' RedshiftDestinationProperties (Prelude.Maybe ErrorHandlingConfig)
redshiftDestinationProperties_errorHandlingConfig :: (Maybe ErrorHandlingConfig -> f (Maybe ErrorHandlingConfig))
-> RedshiftDestinationProperties -> f RedshiftDestinationProperties
redshiftDestinationProperties_errorHandlingConfig = (RedshiftDestinationProperties -> Maybe ErrorHandlingConfig)
-> (RedshiftDestinationProperties
    -> Maybe ErrorHandlingConfig -> RedshiftDestinationProperties)
-> Lens
     RedshiftDestinationProperties
     RedshiftDestinationProperties
     (Maybe ErrorHandlingConfig)
     (Maybe ErrorHandlingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDestinationProperties' {Maybe ErrorHandlingConfig
errorHandlingConfig :: Maybe ErrorHandlingConfig
$sel:errorHandlingConfig:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig} -> Maybe ErrorHandlingConfig
errorHandlingConfig) (\s :: RedshiftDestinationProperties
s@RedshiftDestinationProperties' {} Maybe ErrorHandlingConfig
a -> RedshiftDestinationProperties
s {$sel:errorHandlingConfig:RedshiftDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
a} :: RedshiftDestinationProperties)

-- | The object specified in the Amazon Redshift flow destination.
redshiftDestinationProperties_object :: Lens.Lens' RedshiftDestinationProperties Prelude.Text
redshiftDestinationProperties_object :: (Text -> f Text)
-> RedshiftDestinationProperties -> f RedshiftDestinationProperties
redshiftDestinationProperties_object = (RedshiftDestinationProperties -> Text)
-> (RedshiftDestinationProperties
    -> Text -> RedshiftDestinationProperties)
-> Lens
     RedshiftDestinationProperties
     RedshiftDestinationProperties
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDestinationProperties' {Text
object' :: Text
$sel:object':RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Text
object'} -> Text
object') (\s :: RedshiftDestinationProperties
s@RedshiftDestinationProperties' {} Text
a -> RedshiftDestinationProperties
s {$sel:object':RedshiftDestinationProperties' :: Text
object' = Text
a} :: RedshiftDestinationProperties)

-- | The intermediate bucket that Amazon AppFlow uses when moving data into
-- Amazon Redshift.
redshiftDestinationProperties_intermediateBucketName :: Lens.Lens' RedshiftDestinationProperties Prelude.Text
redshiftDestinationProperties_intermediateBucketName :: (Text -> f Text)
-> RedshiftDestinationProperties -> f RedshiftDestinationProperties
redshiftDestinationProperties_intermediateBucketName = (RedshiftDestinationProperties -> Text)
-> (RedshiftDestinationProperties
    -> Text -> RedshiftDestinationProperties)
-> Lens
     RedshiftDestinationProperties
     RedshiftDestinationProperties
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDestinationProperties' {Text
intermediateBucketName :: Text
$sel:intermediateBucketName:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Text
intermediateBucketName} -> Text
intermediateBucketName) (\s :: RedshiftDestinationProperties
s@RedshiftDestinationProperties' {} Text
a -> RedshiftDestinationProperties
s {$sel:intermediateBucketName:RedshiftDestinationProperties' :: Text
intermediateBucketName = Text
a} :: RedshiftDestinationProperties)

instance Core.FromJSON RedshiftDestinationProperties where
  parseJSON :: Value -> Parser RedshiftDestinationProperties
parseJSON =
    String
-> (Object -> Parser RedshiftDestinationProperties)
-> Value
-> Parser RedshiftDestinationProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RedshiftDestinationProperties"
      ( \Object
x ->
          Maybe Text
-> Maybe ErrorHandlingConfig
-> Text
-> Text
-> RedshiftDestinationProperties
RedshiftDestinationProperties'
            (Maybe Text
 -> Maybe ErrorHandlingConfig
 -> Text
 -> Text
 -> RedshiftDestinationProperties)
-> Parser (Maybe Text)
-> Parser
     (Maybe ErrorHandlingConfig
      -> Text -> Text -> RedshiftDestinationProperties)
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
"bucketPrefix")
            Parser
  (Maybe ErrorHandlingConfig
   -> Text -> Text -> RedshiftDestinationProperties)
-> Parser (Maybe ErrorHandlingConfig)
-> Parser (Text -> Text -> RedshiftDestinationProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ErrorHandlingConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorHandlingConfig")
            Parser (Text -> Text -> RedshiftDestinationProperties)
-> Parser Text -> Parser (Text -> RedshiftDestinationProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"object")
            Parser (Text -> RedshiftDestinationProperties)
-> Parser Text -> Parser RedshiftDestinationProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"intermediateBucketName")
      )

instance
  Prelude.Hashable
    RedshiftDestinationProperties

instance Prelude.NFData RedshiftDestinationProperties

instance Core.ToJSON RedshiftDestinationProperties where
  toJSON :: RedshiftDestinationProperties -> Value
toJSON RedshiftDestinationProperties' {Maybe Text
Maybe ErrorHandlingConfig
Text
intermediateBucketName :: Text
object' :: Text
errorHandlingConfig :: Maybe ErrorHandlingConfig
bucketPrefix :: Maybe Text
$sel:intermediateBucketName:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Text
$sel:object':RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Text
$sel:errorHandlingConfig:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Maybe ErrorHandlingConfig
$sel:bucketPrefix:RedshiftDestinationProperties' :: RedshiftDestinationProperties -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bucketPrefix" 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
bucketPrefix,
            (Text
"errorHandlingConfig" Text -> ErrorHandlingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ErrorHandlingConfig -> Pair)
-> Maybe ErrorHandlingConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ErrorHandlingConfig
errorHandlingConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"object" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
object'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"intermediateBucketName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
intermediateBucketName
              )
          ]
      )