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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:enabled:Scram' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing}

-- | SASL\/SCRAM authentication is enabled or not.
scram_enabled :: Lens.Lens' Scram (Prelude.Maybe Prelude.Bool)
scram_enabled :: Lens' Scram (Maybe Bool)
scram_enabled = 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 Data.FromJSON Scram where
  parseJSON :: Value -> Parser Scram
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Scram"
      (\Object
x -> Maybe Bool -> Scram
Scram' 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
"enabled"))

instance Prelude.Hashable Scram where
  hashWithSalt :: Int -> Scram -> Int
hashWithSalt Int
_salt Scram' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Scram' :: Scram -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled

instance Prelude.NFData Scram where
  rnf :: Scram -> ()
rnf Scram' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Scram' :: Scram -> Maybe Bool
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled

instance Data.ToJSON Scram where
  toJSON :: Scram -> Value
toJSON Scram' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Scram' :: Scram -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"enabled" 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
enabled]
      )