{-# 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.S3EncryptionConfiguration
-- 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.QLDB.Types.S3EncryptionConfiguration 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
import Amazonka.QLDB.Types.S3ObjectEncryptionType

-- | The encryption settings that are used by a journal export job to write
-- data in an Amazon Simple Storage Service (Amazon S3) bucket.
--
-- /See:/ 'newS3EncryptionConfiguration' smart constructor.
data S3EncryptionConfiguration = S3EncryptionConfiguration'
  { -- | The Amazon Resource Name (ARN) of a symmetric key in Key Management
    -- Service (KMS). Amazon S3 does not support asymmetric KMS keys.
    --
    -- You must provide a @KmsKeyArn@ if you specify @SSE_KMS@ as the
    -- @ObjectEncryptionType@.
    --
    -- @KmsKeyArn@ is not required if you specify @SSE_S3@ as the
    -- @ObjectEncryptionType@.
    S3EncryptionConfiguration -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 object encryption type.
    --
    -- To learn more about server-side encryption options in Amazon S3, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html Protecting Data Using Server-Side Encryption>
    -- in the /Amazon S3 Developer Guide/.
    S3EncryptionConfiguration -> S3ObjectEncryptionType
objectEncryptionType :: S3ObjectEncryptionType
  }
  deriving (S3EncryptionConfiguration -> S3EncryptionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3EncryptionConfiguration -> S3EncryptionConfiguration -> Bool
$c/= :: S3EncryptionConfiguration -> S3EncryptionConfiguration -> Bool
== :: S3EncryptionConfiguration -> S3EncryptionConfiguration -> Bool
$c== :: S3EncryptionConfiguration -> S3EncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [S3EncryptionConfiguration]
ReadPrec S3EncryptionConfiguration
Int -> ReadS S3EncryptionConfiguration
ReadS [S3EncryptionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3EncryptionConfiguration]
$creadListPrec :: ReadPrec [S3EncryptionConfiguration]
readPrec :: ReadPrec S3EncryptionConfiguration
$creadPrec :: ReadPrec S3EncryptionConfiguration
readList :: ReadS [S3EncryptionConfiguration]
$creadList :: ReadS [S3EncryptionConfiguration]
readsPrec :: Int -> ReadS S3EncryptionConfiguration
$creadsPrec :: Int -> ReadS S3EncryptionConfiguration
Prelude.Read, Int -> S3EncryptionConfiguration -> ShowS
[S3EncryptionConfiguration] -> ShowS
S3EncryptionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3EncryptionConfiguration] -> ShowS
$cshowList :: [S3EncryptionConfiguration] -> ShowS
show :: S3EncryptionConfiguration -> String
$cshow :: S3EncryptionConfiguration -> String
showsPrec :: Int -> S3EncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> S3EncryptionConfiguration -> ShowS
Prelude.Show, forall x.
Rep S3EncryptionConfiguration x -> S3EncryptionConfiguration
forall x.
S3EncryptionConfiguration -> Rep S3EncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep S3EncryptionConfiguration x -> S3EncryptionConfiguration
$cfrom :: forall x.
S3EncryptionConfiguration -> Rep S3EncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'S3EncryptionConfiguration' 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:
--
-- 'kmsKeyArn', 's3EncryptionConfiguration_kmsKeyArn' - The Amazon Resource Name (ARN) of a symmetric key in Key Management
-- Service (KMS). Amazon S3 does not support asymmetric KMS keys.
--
-- You must provide a @KmsKeyArn@ if you specify @SSE_KMS@ as the
-- @ObjectEncryptionType@.
--
-- @KmsKeyArn@ is not required if you specify @SSE_S3@ as the
-- @ObjectEncryptionType@.
--
-- 'objectEncryptionType', 's3EncryptionConfiguration_objectEncryptionType' - The Amazon S3 object encryption type.
--
-- To learn more about server-side encryption options in Amazon S3, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html Protecting Data Using Server-Side Encryption>
-- in the /Amazon S3 Developer Guide/.
newS3EncryptionConfiguration ::
  -- | 'objectEncryptionType'
  S3ObjectEncryptionType ->
  S3EncryptionConfiguration
newS3EncryptionConfiguration :: S3ObjectEncryptionType -> S3EncryptionConfiguration
newS3EncryptionConfiguration S3ObjectEncryptionType
pObjectEncryptionType_ =
  S3EncryptionConfiguration'
    { $sel:kmsKeyArn:S3EncryptionConfiguration' :: Maybe Text
kmsKeyArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:objectEncryptionType:S3EncryptionConfiguration' :: S3ObjectEncryptionType
objectEncryptionType = S3ObjectEncryptionType
pObjectEncryptionType_
    }

-- | The Amazon Resource Name (ARN) of a symmetric key in Key Management
-- Service (KMS). Amazon S3 does not support asymmetric KMS keys.
--
-- You must provide a @KmsKeyArn@ if you specify @SSE_KMS@ as the
-- @ObjectEncryptionType@.
--
-- @KmsKeyArn@ is not required if you specify @SSE_S3@ as the
-- @ObjectEncryptionType@.
s3EncryptionConfiguration_kmsKeyArn :: Lens.Lens' S3EncryptionConfiguration (Prelude.Maybe Prelude.Text)
s3EncryptionConfiguration_kmsKeyArn :: Lens' S3EncryptionConfiguration (Maybe Text)
s3EncryptionConfiguration_kmsKeyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3EncryptionConfiguration' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: S3EncryptionConfiguration
s@S3EncryptionConfiguration' {} Maybe Text
a -> S3EncryptionConfiguration
s {$sel:kmsKeyArn:S3EncryptionConfiguration' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: S3EncryptionConfiguration)

-- | The Amazon S3 object encryption type.
--
-- To learn more about server-side encryption options in Amazon S3, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html Protecting Data Using Server-Side Encryption>
-- in the /Amazon S3 Developer Guide/.
s3EncryptionConfiguration_objectEncryptionType :: Lens.Lens' S3EncryptionConfiguration S3ObjectEncryptionType
s3EncryptionConfiguration_objectEncryptionType :: Lens' S3EncryptionConfiguration S3ObjectEncryptionType
s3EncryptionConfiguration_objectEncryptionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3EncryptionConfiguration' {S3ObjectEncryptionType
objectEncryptionType :: S3ObjectEncryptionType
$sel:objectEncryptionType:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> S3ObjectEncryptionType
objectEncryptionType} -> S3ObjectEncryptionType
objectEncryptionType) (\s :: S3EncryptionConfiguration
s@S3EncryptionConfiguration' {} S3ObjectEncryptionType
a -> S3EncryptionConfiguration
s {$sel:objectEncryptionType:S3EncryptionConfiguration' :: S3ObjectEncryptionType
objectEncryptionType = S3ObjectEncryptionType
a} :: S3EncryptionConfiguration)

instance Data.FromJSON S3EncryptionConfiguration where
  parseJSON :: Value -> Parser S3EncryptionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3EncryptionConfiguration"
      ( \Object
x ->
          Maybe Text -> S3ObjectEncryptionType -> S3EncryptionConfiguration
S3EncryptionConfiguration'
            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
"KmsKeyArn")
            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
"ObjectEncryptionType")
      )

instance Prelude.Hashable S3EncryptionConfiguration where
  hashWithSalt :: Int -> S3EncryptionConfiguration -> Int
hashWithSalt Int
_salt S3EncryptionConfiguration' {Maybe Text
S3ObjectEncryptionType
objectEncryptionType :: S3ObjectEncryptionType
kmsKeyArn :: Maybe Text
$sel:objectEncryptionType:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> S3ObjectEncryptionType
$sel:kmsKeyArn:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` S3ObjectEncryptionType
objectEncryptionType

instance Prelude.NFData S3EncryptionConfiguration where
  rnf :: S3EncryptionConfiguration -> ()
rnf S3EncryptionConfiguration' {Maybe Text
S3ObjectEncryptionType
objectEncryptionType :: S3ObjectEncryptionType
kmsKeyArn :: Maybe Text
$sel:objectEncryptionType:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> S3ObjectEncryptionType
$sel:kmsKeyArn:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf S3ObjectEncryptionType
objectEncryptionType

instance Data.ToJSON S3EncryptionConfiguration where
  toJSON :: S3EncryptionConfiguration -> Value
toJSON S3EncryptionConfiguration' {Maybe Text
S3ObjectEncryptionType
objectEncryptionType :: S3ObjectEncryptionType
kmsKeyArn :: Maybe Text
$sel:objectEncryptionType:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> S3ObjectEncryptionType
$sel:kmsKeyArn:S3EncryptionConfiguration' :: S3EncryptionConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KmsKeyArn" 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
kmsKeyArn,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ObjectEncryptionType"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= S3ObjectEncryptionType
objectEncryptionType
              )
          ]
      )