{-# 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.S3.Types.EncryptionConfiguration
-- 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.S3.Types.EncryptionConfiguration 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.S3.Internal

-- | Specifies encryption-related information for an Amazon S3 bucket that is
-- a destination for replicated objects.
--
-- /See:/ 'newEncryptionConfiguration' smart constructor.
data EncryptionConfiguration = EncryptionConfiguration'
  { -- | Specifies the ID (Key ARN or Alias ARN) of the customer managed Amazon
    -- Web Services KMS key stored in Amazon Web Services Key Management
    -- Service (KMS) for the destination bucket. Amazon S3 uses this key to
    -- encrypt replica objects. Amazon S3 only supports symmetric, customer
    -- managed KMS keys. For more information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
    -- in the /Amazon Web Services Key Management Service Developer Guide/.
    EncryptionConfiguration -> Maybe Text
replicaKmsKeyID :: Prelude.Maybe Prelude.Text
  }
  deriving (EncryptionConfiguration -> EncryptionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
$c/= :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
== :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
$c== :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [EncryptionConfiguration]
ReadPrec EncryptionConfiguration
Int -> ReadS EncryptionConfiguration
ReadS [EncryptionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionConfiguration]
$creadListPrec :: ReadPrec [EncryptionConfiguration]
readPrec :: ReadPrec EncryptionConfiguration
$creadPrec :: ReadPrec EncryptionConfiguration
readList :: ReadS [EncryptionConfiguration]
$creadList :: ReadS [EncryptionConfiguration]
readsPrec :: Int -> ReadS EncryptionConfiguration
$creadsPrec :: Int -> ReadS EncryptionConfiguration
Prelude.Read, Int -> EncryptionConfiguration -> ShowS
[EncryptionConfiguration] -> ShowS
EncryptionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionConfiguration] -> ShowS
$cshowList :: [EncryptionConfiguration] -> ShowS
show :: EncryptionConfiguration -> String
$cshow :: EncryptionConfiguration -> String
showsPrec :: Int -> EncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> EncryptionConfiguration -> ShowS
Prelude.Show, forall x. Rep EncryptionConfiguration x -> EncryptionConfiguration
forall x. EncryptionConfiguration -> Rep EncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionConfiguration x -> EncryptionConfiguration
$cfrom :: forall x. EncryptionConfiguration -> Rep EncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionConfiguration' 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:
--
-- 'replicaKmsKeyID', 'encryptionConfiguration_replicaKmsKeyID' - Specifies the ID (Key ARN or Alias ARN) of the customer managed Amazon
-- Web Services KMS key stored in Amazon Web Services Key Management
-- Service (KMS) for the destination bucket. Amazon S3 uses this key to
-- encrypt replica objects. Amazon S3 only supports symmetric, customer
-- managed KMS keys. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
-- in the /Amazon Web Services Key Management Service Developer Guide/.
newEncryptionConfiguration ::
  EncryptionConfiguration
newEncryptionConfiguration :: EncryptionConfiguration
newEncryptionConfiguration =
  EncryptionConfiguration'
    { $sel:replicaKmsKeyID:EncryptionConfiguration' :: Maybe Text
replicaKmsKeyID =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the ID (Key ARN or Alias ARN) of the customer managed Amazon
-- Web Services KMS key stored in Amazon Web Services Key Management
-- Service (KMS) for the destination bucket. Amazon S3 uses this key to
-- encrypt replica objects. Amazon S3 only supports symmetric, customer
-- managed KMS keys. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
-- in the /Amazon Web Services Key Management Service Developer Guide/.
encryptionConfiguration_replicaKmsKeyID :: Lens.Lens' EncryptionConfiguration (Prelude.Maybe Prelude.Text)
encryptionConfiguration_replicaKmsKeyID :: Lens' EncryptionConfiguration (Maybe Text)
encryptionConfiguration_replicaKmsKeyID = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Maybe Text
replicaKmsKeyID :: Maybe Text
$sel:replicaKmsKeyID:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
replicaKmsKeyID} -> Maybe Text
replicaKmsKeyID) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Maybe Text
a -> EncryptionConfiguration
s {$sel:replicaKmsKeyID:EncryptionConfiguration' :: Maybe Text
replicaKmsKeyID = Maybe Text
a} :: EncryptionConfiguration)

instance Data.FromXML EncryptionConfiguration where
  parseXML :: [Node] -> Either String EncryptionConfiguration
parseXML [Node]
x =
    Maybe Text -> EncryptionConfiguration
EncryptionConfiguration'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ReplicaKmsKeyID")

instance Prelude.Hashable EncryptionConfiguration where
  hashWithSalt :: Int -> EncryptionConfiguration -> Int
hashWithSalt Int
_salt EncryptionConfiguration' {Maybe Text
replicaKmsKeyID :: Maybe Text
$sel:replicaKmsKeyID:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
replicaKmsKeyID

instance Prelude.NFData EncryptionConfiguration where
  rnf :: EncryptionConfiguration -> ()
rnf EncryptionConfiguration' {Maybe Text
replicaKmsKeyID :: Maybe Text
$sel:replicaKmsKeyID:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
replicaKmsKeyID

instance Data.ToXML EncryptionConfiguration where
  toXML :: EncryptionConfiguration -> XML
toXML EncryptionConfiguration' {Maybe Text
replicaKmsKeyID :: Maybe Text
$sel:replicaKmsKeyID:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"ReplicaKmsKeyID" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
replicaKmsKeyID]