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

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 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,
    -- | The Amazon S3 bucket name where the source files are stored.
    S3SourceProperties -> Text
bucketName :: Prelude.Text
  }
  deriving (S3SourceProperties -> S3SourceProperties -> Bool
(S3SourceProperties -> S3SourceProperties -> Bool)
-> (S3SourceProperties -> S3SourceProperties -> Bool)
-> Eq S3SourceProperties
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]
(Int -> ReadS S3SourceProperties)
-> ReadS [S3SourceProperties]
-> ReadPrec S3SourceProperties
-> ReadPrec [S3SourceProperties]
-> Read 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
(Int -> S3SourceProperties -> ShowS)
-> (S3SourceProperties -> String)
-> ([S3SourceProperties] -> ShowS)
-> Show S3SourceProperties
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. S3SourceProperties -> Rep S3SourceProperties x)
-> (forall x. Rep S3SourceProperties x -> S3SourceProperties)
-> Generic S3SourceProperties
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.
--
-- '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' :: Maybe Text -> Text -> S3SourceProperties
S3SourceProperties'
    { $sel:bucketPrefix:S3SourceProperties' :: Maybe Text
bucketPrefix = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> S3SourceProperties -> f S3SourceProperties
s3SourceProperties_bucketPrefix = (S3SourceProperties -> Maybe Text)
-> (S3SourceProperties -> Maybe Text -> S3SourceProperties)
-> Lens
     S3SourceProperties S3SourceProperties (Maybe Text) (Maybe Text)
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)

-- | The Amazon S3 bucket name where the source files are stored.
s3SourceProperties_bucketName :: Lens.Lens' S3SourceProperties Prelude.Text
s3SourceProperties_bucketName :: (Text -> f Text) -> S3SourceProperties -> f S3SourceProperties
s3SourceProperties_bucketName = (S3SourceProperties -> Text)
-> (S3SourceProperties -> Text -> S3SourceProperties)
-> Lens S3SourceProperties S3SourceProperties Text Text
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 Prelude.Hashable S3SourceProperties

instance Prelude.NFData S3SourceProperties

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