{-# 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 #-}
module Amazonka.Kafka.Types.Sasl where
import qualified Amazonka.Core as Core
import Amazonka.Kafka.Types.Iam
import Amazonka.Kafka.Types.Scram
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Sasl = Sasl'
{
Sasl -> Maybe Iam
iam :: Prelude.Maybe Iam,
Sasl -> Maybe Scram
scram :: Prelude.Maybe Scram
}
deriving (Sasl -> Sasl -> Bool
(Sasl -> Sasl -> Bool) -> (Sasl -> Sasl -> Bool) -> Eq Sasl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sasl -> Sasl -> Bool
$c/= :: Sasl -> Sasl -> Bool
== :: Sasl -> Sasl -> Bool
$c== :: Sasl -> Sasl -> Bool
Prelude.Eq, ReadPrec [Sasl]
ReadPrec Sasl
Int -> ReadS Sasl
ReadS [Sasl]
(Int -> ReadS Sasl)
-> ReadS [Sasl] -> ReadPrec Sasl -> ReadPrec [Sasl] -> Read Sasl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Sasl]
$creadListPrec :: ReadPrec [Sasl]
readPrec :: ReadPrec Sasl
$creadPrec :: ReadPrec Sasl
readList :: ReadS [Sasl]
$creadList :: ReadS [Sasl]
readsPrec :: Int -> ReadS Sasl
$creadsPrec :: Int -> ReadS Sasl
Prelude.Read, Int -> Sasl -> ShowS
[Sasl] -> ShowS
Sasl -> String
(Int -> Sasl -> ShowS)
-> (Sasl -> String) -> ([Sasl] -> ShowS) -> Show Sasl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sasl] -> ShowS
$cshowList :: [Sasl] -> ShowS
show :: Sasl -> String
$cshow :: Sasl -> String
showsPrec :: Int -> Sasl -> ShowS
$cshowsPrec :: Int -> Sasl -> ShowS
Prelude.Show, (forall x. Sasl -> Rep Sasl x)
-> (forall x. Rep Sasl x -> Sasl) -> Generic Sasl
forall x. Rep Sasl x -> Sasl
forall x. Sasl -> Rep Sasl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Sasl x -> Sasl
$cfrom :: forall x. Sasl -> Rep Sasl x
Prelude.Generic)
newSasl ::
Sasl
newSasl :: Sasl
newSasl =
Sasl' :: Maybe Iam -> Maybe Scram -> Sasl
Sasl'
{ $sel:iam:Sasl' :: Maybe Iam
iam = Maybe Iam
forall a. Maybe a
Prelude.Nothing,
$sel:scram:Sasl' :: Maybe Scram
scram = Maybe Scram
forall a. Maybe a
Prelude.Nothing
}
sasl_iam :: Lens.Lens' Sasl (Prelude.Maybe Iam)
sasl_iam :: (Maybe Iam -> f (Maybe Iam)) -> Sasl -> f Sasl
sasl_iam = (Sasl -> Maybe Iam)
-> (Sasl -> Maybe Iam -> Sasl)
-> Lens Sasl Sasl (Maybe Iam) (Maybe Iam)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sasl' {Maybe Iam
iam :: Maybe Iam
$sel:iam:Sasl' :: Sasl -> Maybe Iam
iam} -> Maybe Iam
iam) (\s :: Sasl
s@Sasl' {} Maybe Iam
a -> Sasl
s {$sel:iam:Sasl' :: Maybe Iam
iam = Maybe Iam
a} :: Sasl)
sasl_scram :: Lens.Lens' Sasl (Prelude.Maybe Scram)
sasl_scram :: (Maybe Scram -> f (Maybe Scram)) -> Sasl -> f Sasl
sasl_scram = (Sasl -> Maybe Scram)
-> (Sasl -> Maybe Scram -> Sasl)
-> Lens Sasl Sasl (Maybe Scram) (Maybe Scram)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sasl' {Maybe Scram
scram :: Maybe Scram
$sel:scram:Sasl' :: Sasl -> Maybe Scram
scram} -> Maybe Scram
scram) (\s :: Sasl
s@Sasl' {} Maybe Scram
a -> Sasl
s {$sel:scram:Sasl' :: Maybe Scram
scram = Maybe Scram
a} :: Sasl)
instance Core.FromJSON Sasl where
parseJSON :: Value -> Parser Sasl
parseJSON =
String -> (Object -> Parser Sasl) -> Value -> Parser Sasl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Sasl"
( \Object
x ->
Maybe Iam -> Maybe Scram -> Sasl
Sasl'
(Maybe Iam -> Maybe Scram -> Sasl)
-> Parser (Maybe Iam) -> Parser (Maybe Scram -> Sasl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Iam)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iam") Parser (Maybe Scram -> Sasl) -> Parser (Maybe Scram) -> Parser Sasl
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Scram)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"scram")
)
instance Prelude.Hashable Sasl
instance Prelude.NFData Sasl
instance Core.ToJSON Sasl where
toJSON :: Sasl -> Value
toJSON Sasl' {Maybe Iam
Maybe Scram
scram :: Maybe Scram
iam :: Maybe Iam
$sel:scram:Sasl' :: Sasl -> Maybe Scram
$sel:iam:Sasl' :: Sasl -> Maybe Iam
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"iam" Text -> Iam -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Iam -> Pair) -> Maybe Iam -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Iam
iam,
(Text
"scram" Text -> Scram -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Scram -> Pair) -> Maybe Scram -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Scram
scram
]
)