{-# 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.S3DestinationProperties
-- 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.S3DestinationProperties where

import Amazonka.AppFlow.Types.S3OutputFormatConfig
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

-- | The properties that are applied when Amazon S3 is used as a destination.
--
-- /See:/ 'newS3DestinationProperties' smart constructor.
data S3DestinationProperties = S3DestinationProperties'
  { -- | The object key for the destination bucket in which Amazon AppFlow places
    -- the files.
    S3DestinationProperties -> Maybe Text
bucketPrefix :: Prelude.Maybe Prelude.Text,
    S3DestinationProperties -> Maybe S3OutputFormatConfig
s3OutputFormatConfig :: Prelude.Maybe S3OutputFormatConfig,
    -- | The Amazon S3 bucket name in which Amazon AppFlow places the transferred
    -- data.
    S3DestinationProperties -> Text
bucketName :: Prelude.Text
  }
  deriving (S3DestinationProperties -> S3DestinationProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3DestinationProperties -> S3DestinationProperties -> Bool
$c/= :: S3DestinationProperties -> S3DestinationProperties -> Bool
== :: S3DestinationProperties -> S3DestinationProperties -> Bool
$c== :: S3DestinationProperties -> S3DestinationProperties -> Bool
Prelude.Eq, ReadPrec [S3DestinationProperties]
ReadPrec S3DestinationProperties
Int -> ReadS S3DestinationProperties
ReadS [S3DestinationProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3DestinationProperties]
$creadListPrec :: ReadPrec [S3DestinationProperties]
readPrec :: ReadPrec S3DestinationProperties
$creadPrec :: ReadPrec S3DestinationProperties
readList :: ReadS [S3DestinationProperties]
$creadList :: ReadS [S3DestinationProperties]
readsPrec :: Int -> ReadS S3DestinationProperties
$creadsPrec :: Int -> ReadS S3DestinationProperties
Prelude.Read, Int -> S3DestinationProperties -> ShowS
[S3DestinationProperties] -> ShowS
S3DestinationProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3DestinationProperties] -> ShowS
$cshowList :: [S3DestinationProperties] -> ShowS
show :: S3DestinationProperties -> String
$cshow :: S3DestinationProperties -> String
showsPrec :: Int -> S3DestinationProperties -> ShowS
$cshowsPrec :: Int -> S3DestinationProperties -> ShowS
Prelude.Show, forall x. Rep S3DestinationProperties x -> S3DestinationProperties
forall x. S3DestinationProperties -> Rep S3DestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3DestinationProperties x -> S3DestinationProperties
$cfrom :: forall x. S3DestinationProperties -> Rep S3DestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'S3DestinationProperties' 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', 's3DestinationProperties_bucketPrefix' - The object key for the destination bucket in which Amazon AppFlow places
-- the files.
--
-- 's3OutputFormatConfig', 's3DestinationProperties_s3OutputFormatConfig' - Undocumented member.
--
-- 'bucketName', 's3DestinationProperties_bucketName' - The Amazon S3 bucket name in which Amazon AppFlow places the transferred
-- data.
newS3DestinationProperties ::
  -- | 'bucketName'
  Prelude.Text ->
  S3DestinationProperties
newS3DestinationProperties :: Text -> S3DestinationProperties
newS3DestinationProperties Text
pBucketName_ =
  S3DestinationProperties'
    { $sel:bucketPrefix:S3DestinationProperties' :: Maybe Text
bucketPrefix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputFormatConfig:S3DestinationProperties' :: Maybe S3OutputFormatConfig
s3OutputFormatConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3DestinationProperties' :: Text
bucketName = Text
pBucketName_
    }

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

-- | Undocumented member.
s3DestinationProperties_s3OutputFormatConfig :: Lens.Lens' S3DestinationProperties (Prelude.Maybe S3OutputFormatConfig)
s3DestinationProperties_s3OutputFormatConfig :: Lens' S3DestinationProperties (Maybe S3OutputFormatConfig)
s3DestinationProperties_s3OutputFormatConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationProperties' {Maybe S3OutputFormatConfig
s3OutputFormatConfig :: Maybe S3OutputFormatConfig
$sel:s3OutputFormatConfig:S3DestinationProperties' :: S3DestinationProperties -> Maybe S3OutputFormatConfig
s3OutputFormatConfig} -> Maybe S3OutputFormatConfig
s3OutputFormatConfig) (\s :: S3DestinationProperties
s@S3DestinationProperties' {} Maybe S3OutputFormatConfig
a -> S3DestinationProperties
s {$sel:s3OutputFormatConfig:S3DestinationProperties' :: Maybe S3OutputFormatConfig
s3OutputFormatConfig = Maybe S3OutputFormatConfig
a} :: S3DestinationProperties)

-- | The Amazon S3 bucket name in which Amazon AppFlow places the transferred
-- data.
s3DestinationProperties_bucketName :: Lens.Lens' S3DestinationProperties Prelude.Text
s3DestinationProperties_bucketName :: Lens' S3DestinationProperties Text
s3DestinationProperties_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationProperties' {Text
bucketName :: Text
$sel:bucketName:S3DestinationProperties' :: S3DestinationProperties -> Text
bucketName} -> Text
bucketName) (\s :: S3DestinationProperties
s@S3DestinationProperties' {} Text
a -> S3DestinationProperties
s {$sel:bucketName:S3DestinationProperties' :: Text
bucketName = Text
a} :: S3DestinationProperties)

instance Data.FromJSON S3DestinationProperties where
  parseJSON :: Value -> Parser S3DestinationProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3DestinationProperties"
      ( \Object
x ->
          Maybe Text
-> Maybe S3OutputFormatConfig -> Text -> S3DestinationProperties
S3DestinationProperties'
            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
"bucketPrefix")
            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
"s3OutputFormatConfig")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"bucketName")
      )

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

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

instance Data.ToJSON S3DestinationProperties where
  toJSON :: S3DestinationProperties -> Value
toJSON S3DestinationProperties' {Maybe Text
Maybe S3OutputFormatConfig
Text
bucketName :: Text
s3OutputFormatConfig :: Maybe S3OutputFormatConfig
bucketPrefix :: Maybe Text
$sel:bucketName:S3DestinationProperties' :: S3DestinationProperties -> Text
$sel:s3OutputFormatConfig:S3DestinationProperties' :: S3DestinationProperties -> Maybe S3OutputFormatConfig
$sel:bucketPrefix:S3DestinationProperties' :: S3DestinationProperties -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            (Key
"s3OutputFormatConfig" 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 S3OutputFormatConfig
s3OutputFormatConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName)
          ]
      )