{-# 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.QLDB.Types.S3ExportConfiguration
-- 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.QLDB.Types.S3ExportConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QLDB.Types.S3EncryptionConfiguration

-- | The Amazon Simple Storage Service (Amazon S3) bucket location in which a
-- journal export job writes the journal contents.
--
-- /See:/ 'newS3ExportConfiguration' smart constructor.
data S3ExportConfiguration = S3ExportConfiguration'
  { -- | The Amazon S3 bucket name in which a journal export job writes the
    -- journal contents.
    --
    -- The bucket name must comply with the Amazon S3 bucket naming
    -- conventions. For more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html Bucket Restrictions and Limitations>
    -- in the /Amazon S3 Developer Guide/.
    S3ExportConfiguration -> Text
bucket :: Prelude.Text,
    -- | The prefix for the Amazon S3 bucket in which a journal export job writes
    -- the journal contents.
    --
    -- The prefix must comply with Amazon S3 key naming rules and restrictions.
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html Object Key and Metadata>
    -- in the /Amazon S3 Developer Guide/.
    --
    -- The following are examples of valid @Prefix@ values:
    --
    -- -   @JournalExports-ForMyLedger\/Testing\/@
    --
    -- -   @JournalExports@
    --
    -- -   @My:Tests\/@
    S3ExportConfiguration -> Text
prefix :: Prelude.Text,
    -- | The encryption settings that are used by a journal export job to write
    -- data in an Amazon S3 bucket.
    S3ExportConfiguration -> S3EncryptionConfiguration
encryptionConfiguration :: S3EncryptionConfiguration
  }
  deriving (S3ExportConfiguration -> S3ExportConfiguration -> Bool
(S3ExportConfiguration -> S3ExportConfiguration -> Bool)
-> (S3ExportConfiguration -> S3ExportConfiguration -> Bool)
-> Eq S3ExportConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
$c/= :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
== :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
$c== :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
Prelude.Eq, ReadPrec [S3ExportConfiguration]
ReadPrec S3ExportConfiguration
Int -> ReadS S3ExportConfiguration
ReadS [S3ExportConfiguration]
(Int -> ReadS S3ExportConfiguration)
-> ReadS [S3ExportConfiguration]
-> ReadPrec S3ExportConfiguration
-> ReadPrec [S3ExportConfiguration]
-> Read S3ExportConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ExportConfiguration]
$creadListPrec :: ReadPrec [S3ExportConfiguration]
readPrec :: ReadPrec S3ExportConfiguration
$creadPrec :: ReadPrec S3ExportConfiguration
readList :: ReadS [S3ExportConfiguration]
$creadList :: ReadS [S3ExportConfiguration]
readsPrec :: Int -> ReadS S3ExportConfiguration
$creadsPrec :: Int -> ReadS S3ExportConfiguration
Prelude.Read, Int -> S3ExportConfiguration -> ShowS
[S3ExportConfiguration] -> ShowS
S3ExportConfiguration -> String
(Int -> S3ExportConfiguration -> ShowS)
-> (S3ExportConfiguration -> String)
-> ([S3ExportConfiguration] -> ShowS)
-> Show S3ExportConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ExportConfiguration] -> ShowS
$cshowList :: [S3ExportConfiguration] -> ShowS
show :: S3ExportConfiguration -> String
$cshow :: S3ExportConfiguration -> String
showsPrec :: Int -> S3ExportConfiguration -> ShowS
$cshowsPrec :: Int -> S3ExportConfiguration -> ShowS
Prelude.Show, (forall x. S3ExportConfiguration -> Rep S3ExportConfiguration x)
-> (forall x. Rep S3ExportConfiguration x -> S3ExportConfiguration)
-> Generic S3ExportConfiguration
forall x. Rep S3ExportConfiguration x -> S3ExportConfiguration
forall x. S3ExportConfiguration -> Rep S3ExportConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ExportConfiguration x -> S3ExportConfiguration
$cfrom :: forall x. S3ExportConfiguration -> Rep S3ExportConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'S3ExportConfiguration' 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:
--
-- 'bucket', 's3ExportConfiguration_bucket' - The Amazon S3 bucket name in which a journal export job writes the
-- journal contents.
--
-- The bucket name must comply with the Amazon S3 bucket naming
-- conventions. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html Bucket Restrictions and Limitations>
-- in the /Amazon S3 Developer Guide/.
--
-- 'prefix', 's3ExportConfiguration_prefix' - The prefix for the Amazon S3 bucket in which a journal export job writes
-- the journal contents.
--
-- The prefix must comply with Amazon S3 key naming rules and restrictions.
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html Object Key and Metadata>
-- in the /Amazon S3 Developer Guide/.
--
-- The following are examples of valid @Prefix@ values:
--
-- -   @JournalExports-ForMyLedger\/Testing\/@
--
-- -   @JournalExports@
--
-- -   @My:Tests\/@
--
-- 'encryptionConfiguration', 's3ExportConfiguration_encryptionConfiguration' - The encryption settings that are used by a journal export job to write
-- data in an Amazon S3 bucket.
newS3ExportConfiguration ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'prefix'
  Prelude.Text ->
  -- | 'encryptionConfiguration'
  S3EncryptionConfiguration ->
  S3ExportConfiguration
newS3ExportConfiguration :: Text -> Text -> S3EncryptionConfiguration -> S3ExportConfiguration
newS3ExportConfiguration
  Text
pBucket_
  Text
pPrefix_
  S3EncryptionConfiguration
pEncryptionConfiguration_ =
    S3ExportConfiguration' :: Text -> Text -> S3EncryptionConfiguration -> S3ExportConfiguration
S3ExportConfiguration'
      { $sel:bucket:S3ExportConfiguration' :: Text
bucket = Text
pBucket_,
        $sel:prefix:S3ExportConfiguration' :: Text
prefix = Text
pPrefix_,
        $sel:encryptionConfiguration:S3ExportConfiguration' :: S3EncryptionConfiguration
encryptionConfiguration = S3EncryptionConfiguration
pEncryptionConfiguration_
      }

-- | The Amazon S3 bucket name in which a journal export job writes the
-- journal contents.
--
-- The bucket name must comply with the Amazon S3 bucket naming
-- conventions. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html Bucket Restrictions and Limitations>
-- in the /Amazon S3 Developer Guide/.
s3ExportConfiguration_bucket :: Lens.Lens' S3ExportConfiguration Prelude.Text
s3ExportConfiguration_bucket :: (Text -> f Text)
-> S3ExportConfiguration -> f S3ExportConfiguration
s3ExportConfiguration_bucket = (S3ExportConfiguration -> Text)
-> (S3ExportConfiguration -> Text -> S3ExportConfiguration)
-> Lens S3ExportConfiguration S3ExportConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {Text
bucket :: Text
$sel:bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
bucket} -> Text
bucket) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} Text
a -> S3ExportConfiguration
s {$sel:bucket:S3ExportConfiguration' :: Text
bucket = Text
a} :: S3ExportConfiguration)

-- | The prefix for the Amazon S3 bucket in which a journal export job writes
-- the journal contents.
--
-- The prefix must comply with Amazon S3 key naming rules and restrictions.
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html Object Key and Metadata>
-- in the /Amazon S3 Developer Guide/.
--
-- The following are examples of valid @Prefix@ values:
--
-- -   @JournalExports-ForMyLedger\/Testing\/@
--
-- -   @JournalExports@
--
-- -   @My:Tests\/@
s3ExportConfiguration_prefix :: Lens.Lens' S3ExportConfiguration Prelude.Text
s3ExportConfiguration_prefix :: (Text -> f Text)
-> S3ExportConfiguration -> f S3ExportConfiguration
s3ExportConfiguration_prefix = (S3ExportConfiguration -> Text)
-> (S3ExportConfiguration -> Text -> S3ExportConfiguration)
-> Lens S3ExportConfiguration S3ExportConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {Text
prefix :: Text
$sel:prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Text
prefix} -> Text
prefix) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} Text
a -> S3ExportConfiguration
s {$sel:prefix:S3ExportConfiguration' :: Text
prefix = Text
a} :: S3ExportConfiguration)

-- | The encryption settings that are used by a journal export job to write
-- data in an Amazon S3 bucket.
s3ExportConfiguration_encryptionConfiguration :: Lens.Lens' S3ExportConfiguration S3EncryptionConfiguration
s3ExportConfiguration_encryptionConfiguration :: (S3EncryptionConfiguration -> f S3EncryptionConfiguration)
-> S3ExportConfiguration -> f S3ExportConfiguration
s3ExportConfiguration_encryptionConfiguration = (S3ExportConfiguration -> S3EncryptionConfiguration)
-> (S3ExportConfiguration
    -> S3EncryptionConfiguration -> S3ExportConfiguration)
-> Lens
     S3ExportConfiguration
     S3ExportConfiguration
     S3EncryptionConfiguration
     S3EncryptionConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {S3EncryptionConfiguration
encryptionConfiguration :: S3EncryptionConfiguration
$sel:encryptionConfiguration:S3ExportConfiguration' :: S3ExportConfiguration -> S3EncryptionConfiguration
encryptionConfiguration} -> S3EncryptionConfiguration
encryptionConfiguration) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} S3EncryptionConfiguration
a -> S3ExportConfiguration
s {$sel:encryptionConfiguration:S3ExportConfiguration' :: S3EncryptionConfiguration
encryptionConfiguration = S3EncryptionConfiguration
a} :: S3ExportConfiguration)

instance Core.FromJSON S3ExportConfiguration where
  parseJSON :: Value -> Parser S3ExportConfiguration
parseJSON =
    String
-> (Object -> Parser S3ExportConfiguration)
-> Value
-> Parser S3ExportConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3ExportConfiguration"
      ( \Object
x ->
          Text -> Text -> S3EncryptionConfiguration -> S3ExportConfiguration
S3ExportConfiguration'
            (Text
 -> Text -> S3EncryptionConfiguration -> S3ExportConfiguration)
-> Parser Text
-> Parser
     (Text -> S3EncryptionConfiguration -> S3ExportConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Bucket")
            Parser (Text -> S3EncryptionConfiguration -> S3ExportConfiguration)
-> Parser Text
-> Parser (S3EncryptionConfiguration -> S3ExportConfiguration)
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
"Prefix")
            Parser (S3EncryptionConfiguration -> S3ExportConfiguration)
-> Parser S3EncryptionConfiguration -> Parser S3ExportConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser S3EncryptionConfiguration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EncryptionConfiguration")
      )

instance Prelude.Hashable S3ExportConfiguration

instance Prelude.NFData S3ExportConfiguration

instance Core.ToJSON S3ExportConfiguration where
  toJSON :: S3ExportConfiguration -> Value
toJSON S3ExportConfiguration' {Text
S3EncryptionConfiguration
encryptionConfiguration :: S3EncryptionConfiguration
prefix :: Text
bucket :: Text
$sel:encryptionConfiguration:S3ExportConfiguration' :: S3ExportConfiguration -> S3EncryptionConfiguration
$sel:prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucket),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Prefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
prefix),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"EncryptionConfiguration"
                  Text -> S3EncryptionConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= S3EncryptionConfiguration
encryptionConfiguration
              )
          ]
      )