{-# 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.Firehose.Types.KMSEncryptionConfig
-- 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.Firehose.Types.KMSEncryptionConfig 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

-- | Describes an encryption key for a destination in Amazon S3.
--
-- /See:/ 'newKMSEncryptionConfig' smart constructor.
data KMSEncryptionConfig = KMSEncryptionConfig'
  { -- | The Amazon Resource Name (ARN) of the encryption key. Must belong to the
    -- same Amazon Web Services Region as the destination Amazon S3 bucket. For
    -- more information, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>.
    KMSEncryptionConfig -> Text
aWSKMSKeyARN :: Prelude.Text
  }
  deriving (KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
$c/= :: KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
== :: KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
$c== :: KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
Prelude.Eq, ReadPrec [KMSEncryptionConfig]
ReadPrec KMSEncryptionConfig
Int -> ReadS KMSEncryptionConfig
ReadS [KMSEncryptionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KMSEncryptionConfig]
$creadListPrec :: ReadPrec [KMSEncryptionConfig]
readPrec :: ReadPrec KMSEncryptionConfig
$creadPrec :: ReadPrec KMSEncryptionConfig
readList :: ReadS [KMSEncryptionConfig]
$creadList :: ReadS [KMSEncryptionConfig]
readsPrec :: Int -> ReadS KMSEncryptionConfig
$creadsPrec :: Int -> ReadS KMSEncryptionConfig
Prelude.Read, Int -> KMSEncryptionConfig -> ShowS
[KMSEncryptionConfig] -> ShowS
KMSEncryptionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KMSEncryptionConfig] -> ShowS
$cshowList :: [KMSEncryptionConfig] -> ShowS
show :: KMSEncryptionConfig -> String
$cshow :: KMSEncryptionConfig -> String
showsPrec :: Int -> KMSEncryptionConfig -> ShowS
$cshowsPrec :: Int -> KMSEncryptionConfig -> ShowS
Prelude.Show, forall x. Rep KMSEncryptionConfig x -> KMSEncryptionConfig
forall x. KMSEncryptionConfig -> Rep KMSEncryptionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KMSEncryptionConfig x -> KMSEncryptionConfig
$cfrom :: forall x. KMSEncryptionConfig -> Rep KMSEncryptionConfig x
Prelude.Generic)

-- |
-- Create a value of 'KMSEncryptionConfig' 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:
--
-- 'aWSKMSKeyARN', 'kmsEncryptionConfig_aWSKMSKeyARN' - The Amazon Resource Name (ARN) of the encryption key. Must belong to the
-- same Amazon Web Services Region as the destination Amazon S3 bucket. For
-- more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>.
newKMSEncryptionConfig ::
  -- | 'aWSKMSKeyARN'
  Prelude.Text ->
  KMSEncryptionConfig
newKMSEncryptionConfig :: Text -> KMSEncryptionConfig
newKMSEncryptionConfig Text
pAWSKMSKeyARN_ =
  KMSEncryptionConfig' {$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: Text
aWSKMSKeyARN = Text
pAWSKMSKeyARN_}

-- | The Amazon Resource Name (ARN) of the encryption key. Must belong to the
-- same Amazon Web Services Region as the destination Amazon S3 bucket. For
-- more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>.
kmsEncryptionConfig_aWSKMSKeyARN :: Lens.Lens' KMSEncryptionConfig Prelude.Text
kmsEncryptionConfig_aWSKMSKeyARN :: Lens' KMSEncryptionConfig Text
kmsEncryptionConfig_aWSKMSKeyARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KMSEncryptionConfig' {Text
aWSKMSKeyARN :: Text
$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: KMSEncryptionConfig -> Text
aWSKMSKeyARN} -> Text
aWSKMSKeyARN) (\s :: KMSEncryptionConfig
s@KMSEncryptionConfig' {} Text
a -> KMSEncryptionConfig
s {$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: Text
aWSKMSKeyARN = Text
a} :: KMSEncryptionConfig)

instance Data.FromJSON KMSEncryptionConfig where
  parseJSON :: Value -> Parser KMSEncryptionConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"KMSEncryptionConfig"
      ( \Object
x ->
          Text -> KMSEncryptionConfig
KMSEncryptionConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AWSKMSKeyARN")
      )

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

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

instance Data.ToJSON KMSEncryptionConfig where
  toJSON :: KMSEncryptionConfig -> Value
toJSON KMSEncryptionConfig' {Text
aWSKMSKeyARN :: Text
$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: KMSEncryptionConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AWSKMSKeyARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
aWSKMSKeyARN)]
      )