{-# 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.ServerlessClientAuthentication
-- 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.ServerlessClientAuthentication 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.ServerlessSasl
import qualified Amazonka.Prelude as Prelude

-- | Includes all client authentication information.
--
-- /See:/ 'newServerlessClientAuthentication' smart constructor.
data ServerlessClientAuthentication = ServerlessClientAuthentication'
  { -- | Details for ClientAuthentication using SASL.
    ServerlessClientAuthentication -> Maybe ServerlessSasl
sasl :: Prelude.Maybe ServerlessSasl
  }
  deriving (ServerlessClientAuthentication
-> ServerlessClientAuthentication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerlessClientAuthentication
-> ServerlessClientAuthentication -> Bool
$c/= :: ServerlessClientAuthentication
-> ServerlessClientAuthentication -> Bool
== :: ServerlessClientAuthentication
-> ServerlessClientAuthentication -> Bool
$c== :: ServerlessClientAuthentication
-> ServerlessClientAuthentication -> Bool
Prelude.Eq, ReadPrec [ServerlessClientAuthentication]
ReadPrec ServerlessClientAuthentication
Int -> ReadS ServerlessClientAuthentication
ReadS [ServerlessClientAuthentication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerlessClientAuthentication]
$creadListPrec :: ReadPrec [ServerlessClientAuthentication]
readPrec :: ReadPrec ServerlessClientAuthentication
$creadPrec :: ReadPrec ServerlessClientAuthentication
readList :: ReadS [ServerlessClientAuthentication]
$creadList :: ReadS [ServerlessClientAuthentication]
readsPrec :: Int -> ReadS ServerlessClientAuthentication
$creadsPrec :: Int -> ReadS ServerlessClientAuthentication
Prelude.Read, Int -> ServerlessClientAuthentication -> ShowS
[ServerlessClientAuthentication] -> ShowS
ServerlessClientAuthentication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerlessClientAuthentication] -> ShowS
$cshowList :: [ServerlessClientAuthentication] -> ShowS
show :: ServerlessClientAuthentication -> String
$cshow :: ServerlessClientAuthentication -> String
showsPrec :: Int -> ServerlessClientAuthentication -> ShowS
$cshowsPrec :: Int -> ServerlessClientAuthentication -> ShowS
Prelude.Show, forall x.
Rep ServerlessClientAuthentication x
-> ServerlessClientAuthentication
forall x.
ServerlessClientAuthentication
-> Rep ServerlessClientAuthentication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerlessClientAuthentication x
-> ServerlessClientAuthentication
$cfrom :: forall x.
ServerlessClientAuthentication
-> Rep ServerlessClientAuthentication x
Prelude.Generic)

-- |
-- Create a value of 'ServerlessClientAuthentication' 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:
--
-- 'sasl', 'serverlessClientAuthentication_sasl' - Details for ClientAuthentication using SASL.
newServerlessClientAuthentication ::
  ServerlessClientAuthentication
newServerlessClientAuthentication :: ServerlessClientAuthentication
newServerlessClientAuthentication =
  ServerlessClientAuthentication'
    { $sel:sasl:ServerlessClientAuthentication' :: Maybe ServerlessSasl
sasl =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Details for ClientAuthentication using SASL.
serverlessClientAuthentication_sasl :: Lens.Lens' ServerlessClientAuthentication (Prelude.Maybe ServerlessSasl)
serverlessClientAuthentication_sasl :: Lens' ServerlessClientAuthentication (Maybe ServerlessSasl)
serverlessClientAuthentication_sasl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerlessClientAuthentication' {Maybe ServerlessSasl
sasl :: Maybe ServerlessSasl
$sel:sasl:ServerlessClientAuthentication' :: ServerlessClientAuthentication -> Maybe ServerlessSasl
sasl} -> Maybe ServerlessSasl
sasl) (\s :: ServerlessClientAuthentication
s@ServerlessClientAuthentication' {} Maybe ServerlessSasl
a -> ServerlessClientAuthentication
s {$sel:sasl:ServerlessClientAuthentication' :: Maybe ServerlessSasl
sasl = Maybe ServerlessSasl
a} :: ServerlessClientAuthentication)

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

instance
  Prelude.Hashable
    ServerlessClientAuthentication
  where
  hashWithSalt :: Int -> ServerlessClientAuthentication -> Int
hashWithSalt
    Int
_salt
    ServerlessClientAuthentication' {Maybe ServerlessSasl
sasl :: Maybe ServerlessSasl
$sel:sasl:ServerlessClientAuthentication' :: ServerlessClientAuthentication -> Maybe ServerlessSasl
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ServerlessSasl
sasl

instance
  Prelude.NFData
    ServerlessClientAuthentication
  where
  rnf :: ServerlessClientAuthentication -> ()
rnf ServerlessClientAuthentication' {Maybe ServerlessSasl
sasl :: Maybe ServerlessSasl
$sel:sasl:ServerlessClientAuthentication' :: ServerlessClientAuthentication -> Maybe ServerlessSasl
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ServerlessSasl
sasl

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