{-# 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.SnowflakeDestinationProperties
-- 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.SnowflakeDestinationProperties 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 Snowflake is being used as a
-- destination.
--
-- /See:/ 'newSnowflakeDestinationProperties' smart constructor.
data SnowflakeDestinationProperties = SnowflakeDestinationProperties'
  { -- | The object key for the destination bucket in which Amazon AppFlow places
    -- the files.
    SnowflakeDestinationProperties -> Maybe Text
bucketPrefix :: Prelude.Maybe Prelude.Text,
    -- | The settings that determine how Amazon AppFlow handles an error when
    -- placing data in the Snowflake 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.
    SnowflakeDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig :: Prelude.Maybe ErrorHandlingConfig,
    -- | The object specified in the Snowflake flow destination.
    SnowflakeDestinationProperties -> Text
object' :: Prelude.Text,
    -- | The intermediate bucket that Amazon AppFlow uses when moving data into
    -- Snowflake.
    SnowflakeDestinationProperties -> Text
intermediateBucketName :: Prelude.Text
  }
  deriving (SnowflakeDestinationProperties
-> SnowflakeDestinationProperties -> Bool
(SnowflakeDestinationProperties
 -> SnowflakeDestinationProperties -> Bool)
-> (SnowflakeDestinationProperties
    -> SnowflakeDestinationProperties -> Bool)
-> Eq SnowflakeDestinationProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnowflakeDestinationProperties
-> SnowflakeDestinationProperties -> Bool
$c/= :: SnowflakeDestinationProperties
-> SnowflakeDestinationProperties -> Bool
== :: SnowflakeDestinationProperties
-> SnowflakeDestinationProperties -> Bool
$c== :: SnowflakeDestinationProperties
-> SnowflakeDestinationProperties -> Bool
Prelude.Eq, ReadPrec [SnowflakeDestinationProperties]
ReadPrec SnowflakeDestinationProperties
Int -> ReadS SnowflakeDestinationProperties
ReadS [SnowflakeDestinationProperties]
(Int -> ReadS SnowflakeDestinationProperties)
-> ReadS [SnowflakeDestinationProperties]
-> ReadPrec SnowflakeDestinationProperties
-> ReadPrec [SnowflakeDestinationProperties]
-> Read SnowflakeDestinationProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnowflakeDestinationProperties]
$creadListPrec :: ReadPrec [SnowflakeDestinationProperties]
readPrec :: ReadPrec SnowflakeDestinationProperties
$creadPrec :: ReadPrec SnowflakeDestinationProperties
readList :: ReadS [SnowflakeDestinationProperties]
$creadList :: ReadS [SnowflakeDestinationProperties]
readsPrec :: Int -> ReadS SnowflakeDestinationProperties
$creadsPrec :: Int -> ReadS SnowflakeDestinationProperties
Prelude.Read, Int -> SnowflakeDestinationProperties -> ShowS
[SnowflakeDestinationProperties] -> ShowS
SnowflakeDestinationProperties -> String
(Int -> SnowflakeDestinationProperties -> ShowS)
-> (SnowflakeDestinationProperties -> String)
-> ([SnowflakeDestinationProperties] -> ShowS)
-> Show SnowflakeDestinationProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnowflakeDestinationProperties] -> ShowS
$cshowList :: [SnowflakeDestinationProperties] -> ShowS
show :: SnowflakeDestinationProperties -> String
$cshow :: SnowflakeDestinationProperties -> String
showsPrec :: Int -> SnowflakeDestinationProperties -> ShowS
$cshowsPrec :: Int -> SnowflakeDestinationProperties -> ShowS
Prelude.Show, (forall x.
 SnowflakeDestinationProperties
 -> Rep SnowflakeDestinationProperties x)
-> (forall x.
    Rep SnowflakeDestinationProperties x
    -> SnowflakeDestinationProperties)
-> Generic SnowflakeDestinationProperties
forall x.
Rep SnowflakeDestinationProperties x
-> SnowflakeDestinationProperties
forall x.
SnowflakeDestinationProperties
-> Rep SnowflakeDestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SnowflakeDestinationProperties x
-> SnowflakeDestinationProperties
$cfrom :: forall x.
SnowflakeDestinationProperties
-> Rep SnowflakeDestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'SnowflakeDestinationProperties' 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', 'snowflakeDestinationProperties_bucketPrefix' - The object key for the destination bucket in which Amazon AppFlow places
-- the files.
--
-- 'errorHandlingConfig', 'snowflakeDestinationProperties_errorHandlingConfig' - The settings that determine how Amazon AppFlow handles an error when
-- placing data in the Snowflake 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'', 'snowflakeDestinationProperties_object' - The object specified in the Snowflake flow destination.
--
-- 'intermediateBucketName', 'snowflakeDestinationProperties_intermediateBucketName' - The intermediate bucket that Amazon AppFlow uses when moving data into
-- Snowflake.
newSnowflakeDestinationProperties ::
  -- | 'object''
  Prelude.Text ->
  -- | 'intermediateBucketName'
  Prelude.Text ->
  SnowflakeDestinationProperties
newSnowflakeDestinationProperties :: Text -> Text -> SnowflakeDestinationProperties
newSnowflakeDestinationProperties
  Text
pObject_
  Text
pIntermediateBucketName_ =
    SnowflakeDestinationProperties' :: Maybe Text
-> Maybe ErrorHandlingConfig
-> Text
-> Text
-> SnowflakeDestinationProperties
SnowflakeDestinationProperties'
      { $sel:bucketPrefix:SnowflakeDestinationProperties' :: Maybe Text
bucketPrefix =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:errorHandlingConfig:SnowflakeDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:object':SnowflakeDestinationProperties' :: Text
object' = Text
pObject_,
        $sel:intermediateBucketName:SnowflakeDestinationProperties' :: Text
intermediateBucketName =
          Text
pIntermediateBucketName_
      }

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

-- | The settings that determine how Amazon AppFlow handles an error when
-- placing data in the Snowflake 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.
snowflakeDestinationProperties_errorHandlingConfig :: Lens.Lens' SnowflakeDestinationProperties (Prelude.Maybe ErrorHandlingConfig)
snowflakeDestinationProperties_errorHandlingConfig :: (Maybe ErrorHandlingConfig -> f (Maybe ErrorHandlingConfig))
-> SnowflakeDestinationProperties
-> f SnowflakeDestinationProperties
snowflakeDestinationProperties_errorHandlingConfig = (SnowflakeDestinationProperties -> Maybe ErrorHandlingConfig)
-> (SnowflakeDestinationProperties
    -> Maybe ErrorHandlingConfig -> SnowflakeDestinationProperties)
-> Lens
     SnowflakeDestinationProperties
     SnowflakeDestinationProperties
     (Maybe ErrorHandlingConfig)
     (Maybe ErrorHandlingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnowflakeDestinationProperties' {Maybe ErrorHandlingConfig
errorHandlingConfig :: Maybe ErrorHandlingConfig
$sel:errorHandlingConfig:SnowflakeDestinationProperties' :: SnowflakeDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig} -> Maybe ErrorHandlingConfig
errorHandlingConfig) (\s :: SnowflakeDestinationProperties
s@SnowflakeDestinationProperties' {} Maybe ErrorHandlingConfig
a -> SnowflakeDestinationProperties
s {$sel:errorHandlingConfig:SnowflakeDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
a} :: SnowflakeDestinationProperties)

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

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

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

instance
  Prelude.NFData
    SnowflakeDestinationProperties

instance Core.ToJSON SnowflakeDestinationProperties where
  toJSON :: SnowflakeDestinationProperties -> Value
toJSON SnowflakeDestinationProperties' {Maybe Text
Maybe ErrorHandlingConfig
Text
intermediateBucketName :: Text
object' :: Text
errorHandlingConfig :: Maybe ErrorHandlingConfig
bucketPrefix :: Maybe Text
$sel:intermediateBucketName:SnowflakeDestinationProperties' :: SnowflakeDestinationProperties -> Text
$sel:object':SnowflakeDestinationProperties' :: SnowflakeDestinationProperties -> Text
$sel:errorHandlingConfig:SnowflakeDestinationProperties' :: SnowflakeDestinationProperties -> Maybe ErrorHandlingConfig
$sel:bucketPrefix:SnowflakeDestinationProperties' :: SnowflakeDestinationProperties -> 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
              )
          ]
      )