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

import Amazonka.AppFlow.Types.S3InputFormatConfig
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 being used as the flow
-- source.
--
-- /See:/ 'newS3SourceProperties' smart constructor.
data S3SourceProperties = S3SourceProperties'
  { -- | The object key for the Amazon S3 bucket in which the source files are
    -- stored.
    S3SourceProperties -> Maybe Text
bucketPrefix :: Prelude.Maybe Prelude.Text,
    S3SourceProperties -> Maybe S3InputFormatConfig
s3InputFormatConfig :: Prelude.Maybe S3InputFormatConfig,
    -- | The Amazon S3 bucket name where the source files are stored.
    S3SourceProperties -> Text
bucketName :: Prelude.Text
  }
  deriving (S3SourceProperties -> S3SourceProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3SourceProperties -> S3SourceProperties -> Bool
$c/= :: S3SourceProperties -> S3SourceProperties -> Bool
== :: S3SourceProperties -> S3SourceProperties -> Bool
$c== :: S3SourceProperties -> S3SourceProperties -> Bool
Prelude.Eq, ReadPrec [S3SourceProperties]
ReadPrec S3SourceProperties
Int -> ReadS S3SourceProperties
ReadS [S3SourceProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3SourceProperties]
$creadListPrec :: ReadPrec [S3SourceProperties]
readPrec :: ReadPrec S3SourceProperties
$creadPrec :: ReadPrec S3SourceProperties
readList :: ReadS [S3SourceProperties]
$creadList :: ReadS [S3SourceProperties]
readsPrec :: Int -> ReadS S3SourceProperties
$creadsPrec :: Int -> ReadS S3SourceProperties
Prelude.Read, Int -> S3SourceProperties -> ShowS
[S3SourceProperties] -> ShowS
S3SourceProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3SourceProperties] -> ShowS
$cshowList :: [S3SourceProperties] -> ShowS
show :: S3SourceProperties -> String
$cshow :: S3SourceProperties -> String
showsPrec :: Int -> S3SourceProperties -> ShowS
$cshowsPrec :: Int -> S3SourceProperties -> ShowS
Prelude.Show, forall x. Rep S3SourceProperties x -> S3SourceProperties
forall x. S3SourceProperties -> Rep S3SourceProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3SourceProperties x -> S3SourceProperties
$cfrom :: forall x. S3SourceProperties -> Rep S3SourceProperties x
Prelude.Generic)

-- |
-- Create a value of 'S3SourceProperties' 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', 's3SourceProperties_bucketPrefix' - The object key for the Amazon S3 bucket in which the source files are
-- stored.
--
-- 's3InputFormatConfig', 's3SourceProperties_s3InputFormatConfig' - Undocumented member.
--
-- 'bucketName', 's3SourceProperties_bucketName' - The Amazon S3 bucket name where the source files are stored.
newS3SourceProperties ::
  -- | 'bucketName'
  Prelude.Text ->
  S3SourceProperties
newS3SourceProperties :: Text -> S3SourceProperties
newS3SourceProperties Text
pBucketName_ =
  S3SourceProperties'
    { $sel:bucketPrefix:S3SourceProperties' :: Maybe Text
bucketPrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:s3InputFormatConfig:S3SourceProperties' :: Maybe S3InputFormatConfig
s3InputFormatConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3SourceProperties' :: Text
bucketName = Text
pBucketName_
    }

-- | The object key for the Amazon S3 bucket in which the source files are
-- stored.
s3SourceProperties_bucketPrefix :: Lens.Lens' S3SourceProperties (Prelude.Maybe Prelude.Text)
s3SourceProperties_bucketPrefix :: Lens' S3SourceProperties (Maybe Text)
s3SourceProperties_bucketPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceProperties' {Maybe Text
bucketPrefix :: Maybe Text
$sel:bucketPrefix:S3SourceProperties' :: S3SourceProperties -> Maybe Text
bucketPrefix} -> Maybe Text
bucketPrefix) (\s :: S3SourceProperties
s@S3SourceProperties' {} Maybe Text
a -> S3SourceProperties
s {$sel:bucketPrefix:S3SourceProperties' :: Maybe Text
bucketPrefix = Maybe Text
a} :: S3SourceProperties)

-- | Undocumented member.
s3SourceProperties_s3InputFormatConfig :: Lens.Lens' S3SourceProperties (Prelude.Maybe S3InputFormatConfig)
s3SourceProperties_s3InputFormatConfig :: Lens' S3SourceProperties (Maybe S3InputFormatConfig)
s3SourceProperties_s3InputFormatConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceProperties' {Maybe S3InputFormatConfig
s3InputFormatConfig :: Maybe S3InputFormatConfig
$sel:s3InputFormatConfig:S3SourceProperties' :: S3SourceProperties -> Maybe S3InputFormatConfig
s3InputFormatConfig} -> Maybe S3InputFormatConfig
s3InputFormatConfig) (\s :: S3SourceProperties
s@S3SourceProperties' {} Maybe S3InputFormatConfig
a -> S3SourceProperties
s {$sel:s3InputFormatConfig:S3SourceProperties' :: Maybe S3InputFormatConfig
s3InputFormatConfig = Maybe S3InputFormatConfig
a} :: S3SourceProperties)

-- | The Amazon S3 bucket name where the source files are stored.
s3SourceProperties_bucketName :: Lens.Lens' S3SourceProperties Prelude.Text
s3SourceProperties_bucketName :: Lens' S3SourceProperties Text
s3SourceProperties_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceProperties' {Text
bucketName :: Text
$sel:bucketName:S3SourceProperties' :: S3SourceProperties -> Text
bucketName} -> Text
bucketName) (\s :: S3SourceProperties
s@S3SourceProperties' {} Text
a -> S3SourceProperties
s {$sel:bucketName:S3SourceProperties' :: Text
bucketName = Text
a} :: S3SourceProperties)

instance Data.FromJSON S3SourceProperties where
  parseJSON :: Value -> Parser S3SourceProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3SourceProperties"
      ( \Object
x ->
          Maybe Text
-> Maybe S3InputFormatConfig -> Text -> S3SourceProperties
S3SourceProperties'
            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
"s3InputFormatConfig")
            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 S3SourceProperties where
  hashWithSalt :: Int -> S3SourceProperties -> Int
hashWithSalt Int
_salt S3SourceProperties' {Maybe Text
Maybe S3InputFormatConfig
Text
bucketName :: Text
s3InputFormatConfig :: Maybe S3InputFormatConfig
bucketPrefix :: Maybe Text
$sel:bucketName:S3SourceProperties' :: S3SourceProperties -> Text
$sel:s3InputFormatConfig:S3SourceProperties' :: S3SourceProperties -> Maybe S3InputFormatConfig
$sel:bucketPrefix:S3SourceProperties' :: S3SourceProperties -> 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 S3InputFormatConfig
s3InputFormatConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketName

instance Prelude.NFData S3SourceProperties where
  rnf :: S3SourceProperties -> ()
rnf S3SourceProperties' {Maybe Text
Maybe S3InputFormatConfig
Text
bucketName :: Text
s3InputFormatConfig :: Maybe S3InputFormatConfig
bucketPrefix :: Maybe Text
$sel:bucketName:S3SourceProperties' :: S3SourceProperties -> Text
$sel:s3InputFormatConfig:S3SourceProperties' :: S3SourceProperties -> Maybe S3InputFormatConfig
$sel:bucketPrefix:S3SourceProperties' :: S3SourceProperties -> 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 S3InputFormatConfig
s3InputFormatConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucketName

instance Data.ToJSON S3SourceProperties where
  toJSON :: S3SourceProperties -> Value
toJSON S3SourceProperties' {Maybe Text
Maybe S3InputFormatConfig
Text
bucketName :: Text
s3InputFormatConfig :: Maybe S3InputFormatConfig
bucketPrefix :: Maybe Text
$sel:bucketName:S3SourceProperties' :: S3SourceProperties -> Text
$sel:s3InputFormatConfig:S3SourceProperties' :: S3SourceProperties -> Maybe S3InputFormatConfig
$sel:bucketPrefix:S3SourceProperties' :: S3SourceProperties -> 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
"s3InputFormatConfig" 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 S3InputFormatConfig
s3InputFormatConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName)
          ]
      )