{-# 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.Kafka.Types.EncryptionInfo
-- 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.Kafka.Types.EncryptionInfo where

import qualified Amazonka.Core as Core
import Amazonka.Kafka.Types.EncryptionAtRest
import Amazonka.Kafka.Types.EncryptionInTransit
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Includes encryption-related information, such as the AWS KMS key used
-- for encrypting data at rest and whether you want MSK to encrypt your
-- data in transit.
--
-- /See:/ 'newEncryptionInfo' smart constructor.
data EncryptionInfo = EncryptionInfo'
  { -- | The data-volume encryption details.
    EncryptionInfo -> Maybe EncryptionAtRest
encryptionAtRest :: Prelude.Maybe EncryptionAtRest,
    -- | The details for encryption in transit.
    EncryptionInfo -> Maybe EncryptionInTransit
encryptionInTransit :: Prelude.Maybe EncryptionInTransit
  }
  deriving (EncryptionInfo -> EncryptionInfo -> Bool
(EncryptionInfo -> EncryptionInfo -> Bool)
-> (EncryptionInfo -> EncryptionInfo -> Bool) -> Eq EncryptionInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionInfo -> EncryptionInfo -> Bool
$c/= :: EncryptionInfo -> EncryptionInfo -> Bool
== :: EncryptionInfo -> EncryptionInfo -> Bool
$c== :: EncryptionInfo -> EncryptionInfo -> Bool
Prelude.Eq, ReadPrec [EncryptionInfo]
ReadPrec EncryptionInfo
Int -> ReadS EncryptionInfo
ReadS [EncryptionInfo]
(Int -> ReadS EncryptionInfo)
-> ReadS [EncryptionInfo]
-> ReadPrec EncryptionInfo
-> ReadPrec [EncryptionInfo]
-> Read EncryptionInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionInfo]
$creadListPrec :: ReadPrec [EncryptionInfo]
readPrec :: ReadPrec EncryptionInfo
$creadPrec :: ReadPrec EncryptionInfo
readList :: ReadS [EncryptionInfo]
$creadList :: ReadS [EncryptionInfo]
readsPrec :: Int -> ReadS EncryptionInfo
$creadsPrec :: Int -> ReadS EncryptionInfo
Prelude.Read, Int -> EncryptionInfo -> ShowS
[EncryptionInfo] -> ShowS
EncryptionInfo -> String
(Int -> EncryptionInfo -> ShowS)
-> (EncryptionInfo -> String)
-> ([EncryptionInfo] -> ShowS)
-> Show EncryptionInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionInfo] -> ShowS
$cshowList :: [EncryptionInfo] -> ShowS
show :: EncryptionInfo -> String
$cshow :: EncryptionInfo -> String
showsPrec :: Int -> EncryptionInfo -> ShowS
$cshowsPrec :: Int -> EncryptionInfo -> ShowS
Prelude.Show, (forall x. EncryptionInfo -> Rep EncryptionInfo x)
-> (forall x. Rep EncryptionInfo x -> EncryptionInfo)
-> Generic EncryptionInfo
forall x. Rep EncryptionInfo x -> EncryptionInfo
forall x. EncryptionInfo -> Rep EncryptionInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionInfo x -> EncryptionInfo
$cfrom :: forall x. EncryptionInfo -> Rep EncryptionInfo x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionInfo' 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:
--
-- 'encryptionAtRest', 'encryptionInfo_encryptionAtRest' - The data-volume encryption details.
--
-- 'encryptionInTransit', 'encryptionInfo_encryptionInTransit' - The details for encryption in transit.
newEncryptionInfo ::
  EncryptionInfo
newEncryptionInfo :: EncryptionInfo
newEncryptionInfo =
  EncryptionInfo' :: Maybe EncryptionAtRest
-> Maybe EncryptionInTransit -> EncryptionInfo
EncryptionInfo'
    { $sel:encryptionAtRest:EncryptionInfo' :: Maybe EncryptionAtRest
encryptionAtRest = Maybe EncryptionAtRest
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionInTransit:EncryptionInfo' :: Maybe EncryptionInTransit
encryptionInTransit = Maybe EncryptionInTransit
forall a. Maybe a
Prelude.Nothing
    }

-- | The data-volume encryption details.
encryptionInfo_encryptionAtRest :: Lens.Lens' EncryptionInfo (Prelude.Maybe EncryptionAtRest)
encryptionInfo_encryptionAtRest :: (Maybe EncryptionAtRest -> f (Maybe EncryptionAtRest))
-> EncryptionInfo -> f EncryptionInfo
encryptionInfo_encryptionAtRest = (EncryptionInfo -> Maybe EncryptionAtRest)
-> (EncryptionInfo -> Maybe EncryptionAtRest -> EncryptionInfo)
-> Lens
     EncryptionInfo
     EncryptionInfo
     (Maybe EncryptionAtRest)
     (Maybe EncryptionAtRest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionInfo' {Maybe EncryptionAtRest
encryptionAtRest :: Maybe EncryptionAtRest
$sel:encryptionAtRest:EncryptionInfo' :: EncryptionInfo -> Maybe EncryptionAtRest
encryptionAtRest} -> Maybe EncryptionAtRest
encryptionAtRest) (\s :: EncryptionInfo
s@EncryptionInfo' {} Maybe EncryptionAtRest
a -> EncryptionInfo
s {$sel:encryptionAtRest:EncryptionInfo' :: Maybe EncryptionAtRest
encryptionAtRest = Maybe EncryptionAtRest
a} :: EncryptionInfo)

-- | The details for encryption in transit.
encryptionInfo_encryptionInTransit :: Lens.Lens' EncryptionInfo (Prelude.Maybe EncryptionInTransit)
encryptionInfo_encryptionInTransit :: (Maybe EncryptionInTransit -> f (Maybe EncryptionInTransit))
-> EncryptionInfo -> f EncryptionInfo
encryptionInfo_encryptionInTransit = (EncryptionInfo -> Maybe EncryptionInTransit)
-> (EncryptionInfo -> Maybe EncryptionInTransit -> EncryptionInfo)
-> Lens
     EncryptionInfo
     EncryptionInfo
     (Maybe EncryptionInTransit)
     (Maybe EncryptionInTransit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionInfo' {Maybe EncryptionInTransit
encryptionInTransit :: Maybe EncryptionInTransit
$sel:encryptionInTransit:EncryptionInfo' :: EncryptionInfo -> Maybe EncryptionInTransit
encryptionInTransit} -> Maybe EncryptionInTransit
encryptionInTransit) (\s :: EncryptionInfo
s@EncryptionInfo' {} Maybe EncryptionInTransit
a -> EncryptionInfo
s {$sel:encryptionInTransit:EncryptionInfo' :: Maybe EncryptionInTransit
encryptionInTransit = Maybe EncryptionInTransit
a} :: EncryptionInfo)

instance Core.FromJSON EncryptionInfo where
  parseJSON :: Value -> Parser EncryptionInfo
parseJSON =
    String
-> (Object -> Parser EncryptionInfo)
-> Value
-> Parser EncryptionInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EncryptionInfo"
      ( \Object
x ->
          Maybe EncryptionAtRest
-> Maybe EncryptionInTransit -> EncryptionInfo
EncryptionInfo'
            (Maybe EncryptionAtRest
 -> Maybe EncryptionInTransit -> EncryptionInfo)
-> Parser (Maybe EncryptionAtRest)
-> Parser (Maybe EncryptionInTransit -> EncryptionInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionAtRest)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryptionAtRest")
            Parser (Maybe EncryptionInTransit -> EncryptionInfo)
-> Parser (Maybe EncryptionInTransit) -> Parser EncryptionInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EncryptionInTransit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryptionInTransit")
      )

instance Prelude.Hashable EncryptionInfo

instance Prelude.NFData EncryptionInfo

instance Core.ToJSON EncryptionInfo where
  toJSON :: EncryptionInfo -> Value
toJSON EncryptionInfo' {Maybe EncryptionAtRest
Maybe EncryptionInTransit
encryptionInTransit :: Maybe EncryptionInTransit
encryptionAtRest :: Maybe EncryptionAtRest
$sel:encryptionInTransit:EncryptionInfo' :: EncryptionInfo -> Maybe EncryptionInTransit
$sel:encryptionAtRest:EncryptionInfo' :: EncryptionInfo -> Maybe EncryptionAtRest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"encryptionAtRest" Text -> EncryptionAtRest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EncryptionAtRest -> Pair) -> Maybe EncryptionAtRest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionAtRest
encryptionAtRest,
            (Text
"encryptionInTransit" Text -> EncryptionInTransit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EncryptionInTransit -> Pair)
-> Maybe EncryptionInTransit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionInTransit
encryptionInTransit
          ]
      )