{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kafka.Types.EncryptionInTransit where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kafka.Types.ClientBroker
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
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]
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
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. 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'
    { $sel:clientBroker:EncryptionInTransit' :: Maybe ClientBroker
clientBroker =
        forall a. Maybe a
Prelude.Nothing,
      $sel:inCluster:EncryptionInTransit' :: Maybe Bool
inCluster = 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 :: Lens' EncryptionInTransit (Maybe ClientBroker)
encryptionInTransit_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 :: Lens' EncryptionInTransit (Maybe Bool)
encryptionInTransit_inCluster = 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 Data.FromJSON EncryptionInTransit where
  parseJSON :: Value -> Parser EncryptionInTransit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncryptionInTransit"
      ( \Object
x ->
          Maybe ClientBroker -> Maybe Bool -> EncryptionInTransit
EncryptionInTransit'
            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
"clientBroker")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"inCluster")
      )

instance Prelude.Hashable EncryptionInTransit where
  hashWithSalt :: Int -> EncryptionInTransit -> Int
hashWithSalt Int
_salt EncryptionInTransit' {Maybe Bool
Maybe ClientBroker
inCluster :: Maybe Bool
clientBroker :: Maybe ClientBroker
$sel:inCluster:EncryptionInTransit' :: EncryptionInTransit -> Maybe Bool
$sel:clientBroker:EncryptionInTransit' :: EncryptionInTransit -> Maybe ClientBroker
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClientBroker
clientBroker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
inCluster

instance Prelude.NFData EncryptionInTransit where
  rnf :: EncryptionInTransit -> ()
rnf EncryptionInTransit' {Maybe Bool
Maybe ClientBroker
inCluster :: Maybe Bool
clientBroker :: Maybe ClientBroker
$sel:inCluster:EncryptionInTransit' :: EncryptionInTransit -> Maybe Bool
$sel:clientBroker:EncryptionInTransit' :: EncryptionInTransit -> Maybe ClientBroker
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ClientBroker
clientBroker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
inCluster

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientBroker" 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 ClientBroker
clientBroker,
            (Key
"inCluster" 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 Bool
inCluster
          ]
      )