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

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

-- | Details for SASL\/SCRAM client authentication.
--
-- /See:/ 'newScram' smart constructor.
data Scram = Scram'
  { -- | SASL\/SCRAM authentication is enabled or not.
    Scram -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (Scram -> Scram -> Bool
(Scram -> Scram -> Bool) -> (Scram -> Scram -> Bool) -> Eq Scram
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Scram -> Scram -> Bool
$c/= :: Scram -> Scram -> Bool
== :: Scram -> Scram -> Bool
$c== :: Scram -> Scram -> Bool
Prelude.Eq, ReadPrec [Scram]
ReadPrec Scram
Int -> ReadS Scram
ReadS [Scram]
(Int -> ReadS Scram)
-> ReadS [Scram]
-> ReadPrec Scram
-> ReadPrec [Scram]
-> Read Scram
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Scram]
$creadListPrec :: ReadPrec [Scram]
readPrec :: ReadPrec Scram
$creadPrec :: ReadPrec Scram
readList :: ReadS [Scram]
$creadList :: ReadS [Scram]
readsPrec :: Int -> ReadS Scram
$creadsPrec :: Int -> ReadS Scram
Prelude.Read, Int -> Scram -> ShowS
[Scram] -> ShowS
Scram -> String
(Int -> Scram -> ShowS)
-> (Scram -> String) -> ([Scram] -> ShowS) -> Show Scram
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Scram] -> ShowS
$cshowList :: [Scram] -> ShowS
show :: Scram -> String
$cshow :: Scram -> String
showsPrec :: Int -> Scram -> ShowS
$cshowsPrec :: Int -> Scram -> ShowS
Prelude.Show, (forall x. Scram -> Rep Scram x)
-> (forall x. Rep Scram x -> Scram) -> Generic Scram
forall x. Rep Scram x -> Scram
forall x. Scram -> Rep Scram x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Scram x -> Scram
$cfrom :: forall x. Scram -> Rep Scram x
Prelude.Generic)

-- |
-- Create a value of 'Scram' 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', 'scram_enabled' - SASL\/SCRAM authentication is enabled or not.
newScram ::
  Scram
newScram :: Scram
newScram = Scram' :: Maybe Bool -> Scram
Scram' {$sel:enabled:Scram' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | SASL\/SCRAM authentication is enabled or not.
scram_enabled :: Lens.Lens' Scram (Prelude.Maybe Prelude.Bool)
scram_enabled :: (Maybe Bool -> f (Maybe Bool)) -> Scram -> f Scram
scram_enabled = (Scram -> Maybe Bool)
-> (Scram -> Maybe Bool -> Scram)
-> Lens Scram Scram (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scram' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Scram' :: Scram -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: Scram
s@Scram' {} Maybe Bool
a -> Scram
s {$sel:enabled:Scram' :: Maybe Bool
enabled = Maybe Bool
a} :: Scram)

instance Core.FromJSON Scram where
  parseJSON :: Value -> Parser Scram
parseJSON =
    String -> (Object -> Parser Scram) -> Value -> Parser Scram
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Scram"
      (\Object
x -> Maybe Bool -> Scram
Scram' (Maybe Bool -> Scram) -> Parser (Maybe Bool) -> Parser Scram
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"))

instance Prelude.Hashable Scram

instance Prelude.NFData Scram

instance Core.ToJSON Scram where
  toJSON :: Scram -> Value
toJSON Scram' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Scram' :: Scram -> 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]
      )