{-# 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.NetworkFirewall.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.NetworkFirewall.Types.EncryptionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.EncryptionType
import qualified Amazonka.Prelude as Prelude

-- | A complex type that contains optional Amazon Web Services Key Management
-- Service (KMS) encryption settings for your Network Firewall resources.
-- Your data is encrypted by default with an Amazon Web Services owned key
-- that Amazon Web Services owns and manages for you. You can use either
-- the Amazon Web Services owned key, or provide your own customer managed
-- key. To learn more about KMS encryption of your Network Firewall
-- resources, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/kms-encryption-at-rest.html Encryption at rest with Amazon Web Services Key Managment Service>
-- in the /Network Firewall Developer Guide/.
--
-- /See:/ 'newEncryptionConfiguration' smart constructor.
data EncryptionConfiguration = EncryptionConfiguration'
  { -- | The ID of the Amazon Web Services Key Management Service (KMS) customer
    -- managed key. You can use any of the key identifiers that KMS supports,
    -- unless you\'re using a key that\'s managed by another account. If
    -- you\'re using a key managed by another account, then specify the key
    -- ARN. For more information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id Key ID>
    -- in the /Amazon Web Services KMS Developer Guide/.
    EncryptionConfiguration -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The type of Amazon Web Services KMS key to use for encryption of your
    -- Network Firewall resources.
    EncryptionConfiguration -> EncryptionType
type' :: EncryptionType
  }
  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:
--
-- 'keyId', 'encryptionConfiguration_keyId' - The ID of the Amazon Web Services Key Management Service (KMS) customer
-- managed key. You can use any of the key identifiers that KMS supports,
-- unless you\'re using a key that\'s managed by another account. If
-- you\'re using a key managed by another account, then specify the key
-- ARN. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id Key ID>
-- in the /Amazon Web Services KMS Developer Guide/.
--
-- 'type'', 'encryptionConfiguration_type' - The type of Amazon Web Services KMS key to use for encryption of your
-- Network Firewall resources.
newEncryptionConfiguration ::
  -- | 'type''
  EncryptionType ->
  EncryptionConfiguration
newEncryptionConfiguration :: EncryptionType -> EncryptionConfiguration
newEncryptionConfiguration EncryptionType
pType_ =
  EncryptionConfiguration'
    { $sel:keyId:EncryptionConfiguration' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':EncryptionConfiguration' :: EncryptionType
type' = EncryptionType
pType_
    }

-- | The ID of the Amazon Web Services Key Management Service (KMS) customer
-- managed key. You can use any of the key identifiers that KMS supports,
-- unless you\'re using a key that\'s managed by another account. If
-- you\'re using a key managed by another account, then specify the key
-- ARN. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id Key ID>
-- in the /Amazon Web Services KMS Developer Guide/.
encryptionConfiguration_keyId :: Lens.Lens' EncryptionConfiguration (Prelude.Maybe Prelude.Text)
encryptionConfiguration_keyId :: Lens' EncryptionConfiguration (Maybe Text)
encryptionConfiguration_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Maybe Text
keyId :: Maybe Text
$sel:keyId:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Maybe Text
a -> EncryptionConfiguration
s {$sel:keyId:EncryptionConfiguration' :: Maybe Text
keyId = Maybe Text
a} :: EncryptionConfiguration)

-- | The type of Amazon Web Services KMS key to use for encryption of your
-- Network Firewall resources.
encryptionConfiguration_type :: Lens.Lens' EncryptionConfiguration EncryptionType
encryptionConfiguration_type :: Lens' EncryptionConfiguration EncryptionType
encryptionConfiguration_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {EncryptionType
type' :: EncryptionType
$sel:type':EncryptionConfiguration' :: EncryptionConfiguration -> EncryptionType
type'} -> EncryptionType
type') (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} EncryptionType
a -> EncryptionConfiguration
s {$sel:type':EncryptionConfiguration' :: EncryptionType
type' = EncryptionType
a} :: EncryptionConfiguration)

instance Data.FromJSON EncryptionConfiguration where
  parseJSON :: Value -> Parser EncryptionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncryptionConfiguration"
      ( \Object
x ->
          Maybe Text -> EncryptionType -> EncryptionConfiguration
EncryptionConfiguration'
            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
"KeyId")
            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
"Type")
      )

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

instance Prelude.NFData EncryptionConfiguration where
  rnf :: EncryptionConfiguration -> ()
rnf EncryptionConfiguration' {Maybe Text
EncryptionType
type' :: EncryptionType
keyId :: Maybe Text
$sel:type':EncryptionConfiguration' :: EncryptionConfiguration -> EncryptionType
$sel:keyId:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EncryptionType
type'

instance Data.ToJSON EncryptionConfiguration where
  toJSON :: EncryptionConfiguration -> Value
toJSON EncryptionConfiguration' {Maybe Text
EncryptionType
type' :: EncryptionType
keyId :: Maybe Text
$sel:type':EncryptionConfiguration' :: EncryptionConfiguration -> EncryptionType
$sel:keyId:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KeyId" 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
keyId,
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EncryptionType
type')
          ]
      )