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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Determines how Amazon AppFlow handles the success response that it gets
-- from the connector after placing data.
--
-- For example, this setting would determine where to write the response
-- from the destination connector upon a successful insert operation.
--
-- /See:/ 'newSuccessResponseHandlingConfig' smart constructor.
data SuccessResponseHandlingConfig = SuccessResponseHandlingConfig'
  { -- | The name of the Amazon S3 bucket.
    SuccessResponseHandlingConfig -> Maybe Text
bucketName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 bucket prefix.
    SuccessResponseHandlingConfig -> Maybe Text
bucketPrefix :: Prelude.Maybe Prelude.Text
  }
  deriving (SuccessResponseHandlingConfig
-> SuccessResponseHandlingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuccessResponseHandlingConfig
-> SuccessResponseHandlingConfig -> Bool
$c/= :: SuccessResponseHandlingConfig
-> SuccessResponseHandlingConfig -> Bool
== :: SuccessResponseHandlingConfig
-> SuccessResponseHandlingConfig -> Bool
$c== :: SuccessResponseHandlingConfig
-> SuccessResponseHandlingConfig -> Bool
Prelude.Eq, ReadPrec [SuccessResponseHandlingConfig]
ReadPrec SuccessResponseHandlingConfig
Int -> ReadS SuccessResponseHandlingConfig
ReadS [SuccessResponseHandlingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuccessResponseHandlingConfig]
$creadListPrec :: ReadPrec [SuccessResponseHandlingConfig]
readPrec :: ReadPrec SuccessResponseHandlingConfig
$creadPrec :: ReadPrec SuccessResponseHandlingConfig
readList :: ReadS [SuccessResponseHandlingConfig]
$creadList :: ReadS [SuccessResponseHandlingConfig]
readsPrec :: Int -> ReadS SuccessResponseHandlingConfig
$creadsPrec :: Int -> ReadS SuccessResponseHandlingConfig
Prelude.Read, Int -> SuccessResponseHandlingConfig -> ShowS
[SuccessResponseHandlingConfig] -> ShowS
SuccessResponseHandlingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuccessResponseHandlingConfig] -> ShowS
$cshowList :: [SuccessResponseHandlingConfig] -> ShowS
show :: SuccessResponseHandlingConfig -> String
$cshow :: SuccessResponseHandlingConfig -> String
showsPrec :: Int -> SuccessResponseHandlingConfig -> ShowS
$cshowsPrec :: Int -> SuccessResponseHandlingConfig -> ShowS
Prelude.Show, forall x.
Rep SuccessResponseHandlingConfig x
-> SuccessResponseHandlingConfig
forall x.
SuccessResponseHandlingConfig
-> Rep SuccessResponseHandlingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SuccessResponseHandlingConfig x
-> SuccessResponseHandlingConfig
$cfrom :: forall x.
SuccessResponseHandlingConfig
-> Rep SuccessResponseHandlingConfig x
Prelude.Generic)

-- |
-- Create a value of 'SuccessResponseHandlingConfig' 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:
--
-- 'bucketName', 'successResponseHandlingConfig_bucketName' - The name of the Amazon S3 bucket.
--
-- 'bucketPrefix', 'successResponseHandlingConfig_bucketPrefix' - The Amazon S3 bucket prefix.
newSuccessResponseHandlingConfig ::
  SuccessResponseHandlingConfig
newSuccessResponseHandlingConfig :: SuccessResponseHandlingConfig
newSuccessResponseHandlingConfig =
  SuccessResponseHandlingConfig'
    { $sel:bucketName:SuccessResponseHandlingConfig' :: Maybe Text
bucketName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucketPrefix:SuccessResponseHandlingConfig' :: Maybe Text
bucketPrefix = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the Amazon S3 bucket.
successResponseHandlingConfig_bucketName :: Lens.Lens' SuccessResponseHandlingConfig (Prelude.Maybe Prelude.Text)
successResponseHandlingConfig_bucketName :: Lens' SuccessResponseHandlingConfig (Maybe Text)
successResponseHandlingConfig_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuccessResponseHandlingConfig' {Maybe Text
bucketName :: Maybe Text
$sel:bucketName:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
bucketName} -> Maybe Text
bucketName) (\s :: SuccessResponseHandlingConfig
s@SuccessResponseHandlingConfig' {} Maybe Text
a -> SuccessResponseHandlingConfig
s {$sel:bucketName:SuccessResponseHandlingConfig' :: Maybe Text
bucketName = Maybe Text
a} :: SuccessResponseHandlingConfig)

-- | The Amazon S3 bucket prefix.
successResponseHandlingConfig_bucketPrefix :: Lens.Lens' SuccessResponseHandlingConfig (Prelude.Maybe Prelude.Text)
successResponseHandlingConfig_bucketPrefix :: Lens' SuccessResponseHandlingConfig (Maybe Text)
successResponseHandlingConfig_bucketPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuccessResponseHandlingConfig' {Maybe Text
bucketPrefix :: Maybe Text
$sel:bucketPrefix:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
bucketPrefix} -> Maybe Text
bucketPrefix) (\s :: SuccessResponseHandlingConfig
s@SuccessResponseHandlingConfig' {} Maybe Text
a -> SuccessResponseHandlingConfig
s {$sel:bucketPrefix:SuccessResponseHandlingConfig' :: Maybe Text
bucketPrefix = Maybe Text
a} :: SuccessResponseHandlingConfig)

instance Data.FromJSON SuccessResponseHandlingConfig where
  parseJSON :: Value -> Parser SuccessResponseHandlingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SuccessResponseHandlingConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SuccessResponseHandlingConfig
SuccessResponseHandlingConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bucketName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bucketPrefix")
      )

instance
  Prelude.Hashable
    SuccessResponseHandlingConfig
  where
  hashWithSalt :: Int -> SuccessResponseHandlingConfig -> Int
hashWithSalt Int
_salt SuccessResponseHandlingConfig' {Maybe Text
bucketPrefix :: Maybe Text
bucketName :: Maybe Text
$sel:bucketPrefix:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
$sel:bucketName:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucketPrefix

instance Prelude.NFData SuccessResponseHandlingConfig where
  rnf :: SuccessResponseHandlingConfig -> ()
rnf SuccessResponseHandlingConfig' {Maybe Text
bucketPrefix :: Maybe Text
bucketName :: Maybe Text
$sel:bucketPrefix:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
$sel:bucketName:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucketPrefix

instance Data.ToJSON SuccessResponseHandlingConfig where
  toJSON :: SuccessResponseHandlingConfig -> Value
toJSON SuccessResponseHandlingConfig' {Maybe Text
bucketPrefix :: Maybe Text
bucketName :: Maybe Text
$sel:bucketPrefix:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
$sel:bucketName:SuccessResponseHandlingConfig' :: SuccessResponseHandlingConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucketName,
            (Key
"bucketPrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucketPrefix
          ]
      )