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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details for client authentication using TLS.
--
-- /See:/ 'newTls' smart constructor.
data Tls = Tls'
  { -- | Specifies whether you want to enable or disable TLS authentication.
    Tls -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | List of ACM Certificate Authority ARNs.
    Tls -> Maybe [Text]
certificateAuthorityArnList :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Tls -> Tls -> Bool
(Tls -> Tls -> Bool) -> (Tls -> Tls -> Bool) -> Eq Tls
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tls -> Tls -> Bool
$c/= :: Tls -> Tls -> Bool
== :: Tls -> Tls -> Bool
$c== :: Tls -> Tls -> Bool
Prelude.Eq, ReadPrec [Tls]
ReadPrec Tls
Int -> ReadS Tls
ReadS [Tls]
(Int -> ReadS Tls)
-> ReadS [Tls] -> ReadPrec Tls -> ReadPrec [Tls] -> Read Tls
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tls]
$creadListPrec :: ReadPrec [Tls]
readPrec :: ReadPrec Tls
$creadPrec :: ReadPrec Tls
readList :: ReadS [Tls]
$creadList :: ReadS [Tls]
readsPrec :: Int -> ReadS Tls
$creadsPrec :: Int -> ReadS Tls
Prelude.Read, Int -> Tls -> ShowS
[Tls] -> ShowS
Tls -> String
(Int -> Tls -> ShowS)
-> (Tls -> String) -> ([Tls] -> ShowS) -> Show Tls
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tls] -> ShowS
$cshowList :: [Tls] -> ShowS
show :: Tls -> String
$cshow :: Tls -> String
showsPrec :: Int -> Tls -> ShowS
$cshowsPrec :: Int -> Tls -> ShowS
Prelude.Show, (forall x. Tls -> Rep Tls x)
-> (forall x. Rep Tls x -> Tls) -> Generic Tls
forall x. Rep Tls x -> Tls
forall x. Tls -> Rep Tls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tls x -> Tls
$cfrom :: forall x. Tls -> Rep Tls x
Prelude.Generic)

-- |
-- Create a value of 'Tls' 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:
--
-- 'enabled', 'tls_enabled' - Specifies whether you want to enable or disable TLS authentication.
--
-- 'certificateAuthorityArnList', 'tls_certificateAuthorityArnList' - List of ACM Certificate Authority ARNs.
newTls ::
  Tls
newTls :: Tls
newTls =
  Tls' :: Maybe Bool -> Maybe [Text] -> Tls
Tls'
    { $sel:enabled:Tls' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateAuthorityArnList:Tls' :: Maybe [Text]
certificateAuthorityArnList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether you want to enable or disable TLS authentication.
tls_enabled :: Lens.Lens' Tls (Prelude.Maybe Prelude.Bool)
tls_enabled :: (Maybe Bool -> f (Maybe Bool)) -> Tls -> f Tls
tls_enabled = (Tls -> Maybe Bool)
-> (Tls -> Maybe Bool -> Tls)
-> Lens Tls Tls (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tls' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Tls' :: Tls -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: Tls
s@Tls' {} Maybe Bool
a -> Tls
s {$sel:enabled:Tls' :: Maybe Bool
enabled = Maybe Bool
a} :: Tls)

-- | List of ACM Certificate Authority ARNs.
tls_certificateAuthorityArnList :: Lens.Lens' Tls (Prelude.Maybe [Prelude.Text])
tls_certificateAuthorityArnList :: (Maybe [Text] -> f (Maybe [Text])) -> Tls -> f Tls
tls_certificateAuthorityArnList = (Tls -> Maybe [Text])
-> (Tls -> Maybe [Text] -> Tls)
-> Lens Tls Tls (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tls' {Maybe [Text]
certificateAuthorityArnList :: Maybe [Text]
$sel:certificateAuthorityArnList:Tls' :: Tls -> Maybe [Text]
certificateAuthorityArnList} -> Maybe [Text]
certificateAuthorityArnList) (\s :: Tls
s@Tls' {} Maybe [Text]
a -> Tls
s {$sel:certificateAuthorityArnList:Tls' :: Maybe [Text]
certificateAuthorityArnList = Maybe [Text]
a} :: Tls) ((Maybe [Text] -> f (Maybe [Text])) -> Tls -> f Tls)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Tls
-> f Tls
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Tls where
  parseJSON :: Value -> Parser Tls
parseJSON =
    String -> (Object -> Parser Tls) -> Value -> Parser Tls
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Tls"
      ( \Object
x ->
          Maybe Bool -> Maybe [Text] -> Tls
Tls'
            (Maybe Bool -> Maybe [Text] -> Tls)
-> Parser (Maybe Bool) -> Parser (Maybe [Text] -> Tls)
forall (f :: * -> *) a b. Functor 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
"enabled")
            Parser (Maybe [Text] -> Tls) -> Parser (Maybe [Text]) -> Parser Tls
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"certificateAuthorityArnList"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Tls

instance Prelude.NFData Tls

instance Core.ToJSON Tls where
  toJSON :: Tls -> Value
toJSON Tls' {Maybe Bool
Maybe [Text]
certificateAuthorityArnList :: Maybe [Text]
enabled :: Maybe Bool
$sel:certificateAuthorityArnList:Tls' :: Tls -> Maybe [Text]
$sel:enabled:Tls' :: Tls -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"enabled" 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
enabled,
            (Text
"certificateAuthorityArnList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
certificateAuthorityArnList
          ]
      )