{-# 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.EncryptionInTransit
-- 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.EncryptionInTransit where

import qualified Amazonka.Core as Core
import Amazonka.Kafka.Types.ClientBroker
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The settings for encrypting data in transit.
--
-- /See:/ 'newEncryptionInTransit' smart constructor.
data EncryptionInTransit = EncryptionInTransit'
  { -- | Indicates the encryption setting for data in transit between clients and
    -- brokers. The following are the possible values.
    --
    -- TLS means that client-broker communication is enabled with TLS only.
    --
    -- TLS_PLAINTEXT means that client-broker communication is enabled for both
    -- TLS-encrypted, as well as plaintext data.
    --
    -- PLAINTEXT means that client-broker communication is enabled in plaintext
    -- only.
    --
    -- The default value is TLS_PLAINTEXT.
    EncryptionInTransit -> Maybe ClientBroker
clientBroker :: Prelude.Maybe ClientBroker,
    -- | When set to true, it indicates that data communication among the broker
    -- nodes of the cluster is encrypted. When set to false, the communication
    -- happens in plaintext.
    --
    -- The default value is true.
    EncryptionInTransit -> Maybe Bool
inCluster :: Prelude.Maybe Prelude.Bool
  }
  deriving (EncryptionInTransit -> EncryptionInTransit -> Bool
(EncryptionInTransit -> EncryptionInTransit -> Bool)
-> (EncryptionInTransit -> EncryptionInTransit -> Bool)
-> Eq EncryptionInTransit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionInTransit -> EncryptionInTransit -> Bool
$c/= :: EncryptionInTransit -> EncryptionInTransit -> Bool
== :: EncryptionInTransit -> EncryptionInTransit -> Bool
$c== :: EncryptionInTransit -> EncryptionInTransit -> Bool
Prelude.Eq, ReadPrec [EncryptionInTransit]
ReadPrec EncryptionInTransit
Int -> ReadS EncryptionInTransit
ReadS [EncryptionInTransit]
(Int -> ReadS EncryptionInTransit)
-> ReadS [EncryptionInTransit]
-> ReadPrec EncryptionInTransit
-> ReadPrec [EncryptionInTransit]
-> Read EncryptionInTransit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionInTransit]
$creadListPrec :: ReadPrec [EncryptionInTransit]
readPrec :: ReadPrec EncryptionInTransit
$creadPrec :: ReadPrec EncryptionInTransit
readList :: ReadS [EncryptionInTransit]
$creadList :: ReadS [EncryptionInTransit]
readsPrec :: Int -> ReadS EncryptionInTransit
$creadsPrec :: Int -> ReadS EncryptionInTransit
Prelude.Read, Int -> EncryptionInTransit -> ShowS
[EncryptionInTransit] -> ShowS
EncryptionInTransit -> String
(Int -> EncryptionInTransit -> ShowS)
-> (EncryptionInTransit -> String)
-> ([EncryptionInTransit] -> ShowS)
-> Show EncryptionInTransit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionInTransit] -> ShowS
$cshowList :: [EncryptionInTransit] -> ShowS
show :: EncryptionInTransit -> String
$cshow :: EncryptionInTransit -> String
showsPrec :: Int -> EncryptionInTransit -> ShowS
$cshowsPrec :: Int -> EncryptionInTransit -> ShowS
Prelude.Show, (forall x. EncryptionInTransit -> Rep EncryptionInTransit x)
-> (forall x. Rep EncryptionInTransit x -> EncryptionInTransit)
-> Generic EncryptionInTransit
forall x. Rep EncryptionInTransit x -> EncryptionInTransit
forall x. EncryptionInTransit -> Rep EncryptionInTransit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionInTransit x -> EncryptionInTransit
$cfrom :: forall x. EncryptionInTransit -> Rep EncryptionInTransit x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionInTransit' 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:
--
-- 'clientBroker', 'encryptionInTransit_clientBroker' - Indicates the encryption setting for data in transit between clients and
-- brokers. The following are the possible values.
--
-- TLS means that client-broker communication is enabled with TLS only.
--
-- TLS_PLAINTEXT means that client-broker communication is enabled for both
-- TLS-encrypted, as well as plaintext data.
--
-- PLAINTEXT means that client-broker communication is enabled in plaintext
-- only.
--
-- The default value is TLS_PLAINTEXT.
--
-- 'inCluster', 'encryptionInTransit_inCluster' - When set to true, it indicates that data communication among the broker
-- nodes of the cluster is encrypted. When set to false, the communication
-- happens in plaintext.
--
-- The default value is true.
newEncryptionInTransit ::
  EncryptionInTransit
newEncryptionInTransit :: EncryptionInTransit
newEncryptionInTransit =
  EncryptionInTransit' :: Maybe ClientBroker -> Maybe Bool -> EncryptionInTransit
EncryptionInTransit'
    { $sel:clientBroker:EncryptionInTransit' :: Maybe ClientBroker
clientBroker =
        Maybe ClientBroker
forall a. Maybe a
Prelude.Nothing,
      $sel:inCluster:EncryptionInTransit' :: Maybe Bool
inCluster = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates the encryption setting for data in transit between clients and
-- brokers. The following are the possible values.
--
-- TLS means that client-broker communication is enabled with TLS only.
--
-- TLS_PLAINTEXT means that client-broker communication is enabled for both
-- TLS-encrypted, as well as plaintext data.
--
-- PLAINTEXT means that client-broker communication is enabled in plaintext
-- only.
--
-- The default value is TLS_PLAINTEXT.
encryptionInTransit_clientBroker :: Lens.Lens' EncryptionInTransit (Prelude.Maybe ClientBroker)
encryptionInTransit_clientBroker :: (Maybe ClientBroker -> f (Maybe ClientBroker))
-> EncryptionInTransit -> f EncryptionInTransit
encryptionInTransit_clientBroker = (EncryptionInTransit -> Maybe ClientBroker)
-> (EncryptionInTransit
    -> Maybe ClientBroker -> EncryptionInTransit)
-> Lens
     EncryptionInTransit
     EncryptionInTransit
     (Maybe ClientBroker)
     (Maybe ClientBroker)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionInTransit' {Maybe ClientBroker
clientBroker :: Maybe ClientBroker
$sel:clientBroker:EncryptionInTransit' :: EncryptionInTransit -> Maybe ClientBroker
clientBroker} -> Maybe ClientBroker
clientBroker) (\s :: EncryptionInTransit
s@EncryptionInTransit' {} Maybe ClientBroker
a -> EncryptionInTransit
s {$sel:clientBroker:EncryptionInTransit' :: Maybe ClientBroker
clientBroker = Maybe ClientBroker
a} :: EncryptionInTransit)

-- | When set to true, it indicates that data communication among the broker
-- nodes of the cluster is encrypted. When set to false, the communication
-- happens in plaintext.
--
-- The default value is true.
encryptionInTransit_inCluster :: Lens.Lens' EncryptionInTransit (Prelude.Maybe Prelude.Bool)
encryptionInTransit_inCluster :: (Maybe Bool -> f (Maybe Bool))
-> EncryptionInTransit -> f EncryptionInTransit
encryptionInTransit_inCluster = (EncryptionInTransit -> Maybe Bool)
-> (EncryptionInTransit -> Maybe Bool -> EncryptionInTransit)
-> Lens
     EncryptionInTransit EncryptionInTransit (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionInTransit' {Maybe Bool
inCluster :: Maybe Bool
$sel:inCluster:EncryptionInTransit' :: EncryptionInTransit -> Maybe Bool
inCluster} -> Maybe Bool
inCluster) (\s :: EncryptionInTransit
s@EncryptionInTransit' {} Maybe Bool
a -> EncryptionInTransit
s {$sel:inCluster:EncryptionInTransit' :: Maybe Bool
inCluster = Maybe Bool
a} :: EncryptionInTransit)

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

instance Prelude.Hashable EncryptionInTransit

instance Prelude.NFData EncryptionInTransit

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