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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 AWS 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 AWS Service Namespaces>.
    KMSEncryptionConfig -> Text
aWSKMSKeyARN :: Prelude.Text
  }
  deriving (KMSEncryptionConfig -> KMSEncryptionConfig -> Bool
(KMSEncryptionConfig -> KMSEncryptionConfig -> Bool)
-> (KMSEncryptionConfig -> KMSEncryptionConfig -> Bool)
-> Eq KMSEncryptionConfig
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]
(Int -> ReadS KMSEncryptionConfig)
-> ReadS [KMSEncryptionConfig]
-> ReadPrec KMSEncryptionConfig
-> ReadPrec [KMSEncryptionConfig]
-> Read 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
(Int -> KMSEncryptionConfig -> ShowS)
-> (KMSEncryptionConfig -> String)
-> ([KMSEncryptionConfig] -> ShowS)
-> Show KMSEncryptionConfig
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. KMSEncryptionConfig -> Rep KMSEncryptionConfig x)
-> (forall x. Rep KMSEncryptionConfig x -> KMSEncryptionConfig)
-> Generic KMSEncryptionConfig
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 AWS 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 AWS Service Namespaces>.
newKMSEncryptionConfig ::
  -- | 'aWSKMSKeyARN'
  Prelude.Text ->
  KMSEncryptionConfig
newKMSEncryptionConfig :: Text -> KMSEncryptionConfig
newKMSEncryptionConfig Text
pAWSKMSKeyARN_ =
  KMSEncryptionConfig' :: Text -> KMSEncryptionConfig
KMSEncryptionConfig' {$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: Text
aWSKMSKeyARN = Text
pAWSKMSKeyARN_}

-- | The Amazon Resource Name (ARN) of the encryption key. Must belong to the
-- same AWS 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 AWS Service Namespaces>.
kmsEncryptionConfig_aWSKMSKeyARN :: Lens.Lens' KMSEncryptionConfig Prelude.Text
kmsEncryptionConfig_aWSKMSKeyARN :: (Text -> f Text) -> KMSEncryptionConfig -> f KMSEncryptionConfig
kmsEncryptionConfig_aWSKMSKeyARN = (KMSEncryptionConfig -> Text)
-> (KMSEncryptionConfig -> Text -> KMSEncryptionConfig)
-> Lens KMSEncryptionConfig KMSEncryptionConfig Text Text
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 Core.FromJSON KMSEncryptionConfig where
  parseJSON :: Value -> Parser KMSEncryptionConfig
parseJSON =
    String
-> (Object -> Parser KMSEncryptionConfig)
-> Value
-> Parser KMSEncryptionConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KMSEncryptionConfig"
      ( \Object
x ->
          Text -> KMSEncryptionConfig
KMSEncryptionConfig'
            (Text -> KMSEncryptionConfig)
-> Parser Text -> Parser KMSEncryptionConfig
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
"AWSKMSKeyARN")
      )

instance Prelude.Hashable KMSEncryptionConfig

instance Prelude.NFData KMSEncryptionConfig

instance Core.ToJSON KMSEncryptionConfig where
  toJSON :: KMSEncryptionConfig -> Value
toJSON KMSEncryptionConfig' {Text
aWSKMSKeyARN :: Text
$sel:aWSKMSKeyARN:KMSEncryptionConfig' :: KMSEncryptionConfig -> 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
"AWSKMSKeyARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
aWSKMSKeyARN)]
      )