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

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

-- | Details for IAM access control.
--
-- /See:/ 'newIam' smart constructor.
data Iam = Iam'
  { -- | Indicates whether IAM access control is enabled.
    Iam -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (Iam -> Iam -> Bool
(Iam -> Iam -> Bool) -> (Iam -> Iam -> Bool) -> Eq Iam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Iam -> Iam -> Bool
$c/= :: Iam -> Iam -> Bool
== :: Iam -> Iam -> Bool
$c== :: Iam -> Iam -> Bool
Prelude.Eq, ReadPrec [Iam]
ReadPrec Iam
Int -> ReadS Iam
ReadS [Iam]
(Int -> ReadS Iam)
-> ReadS [Iam] -> ReadPrec Iam -> ReadPrec [Iam] -> Read Iam
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Iam]
$creadListPrec :: ReadPrec [Iam]
readPrec :: ReadPrec Iam
$creadPrec :: ReadPrec Iam
readList :: ReadS [Iam]
$creadList :: ReadS [Iam]
readsPrec :: Int -> ReadS Iam
$creadsPrec :: Int -> ReadS Iam
Prelude.Read, Int -> Iam -> ShowS
[Iam] -> ShowS
Iam -> String
(Int -> Iam -> ShowS)
-> (Iam -> String) -> ([Iam] -> ShowS) -> Show Iam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Iam] -> ShowS
$cshowList :: [Iam] -> ShowS
show :: Iam -> String
$cshow :: Iam -> String
showsPrec :: Int -> Iam -> ShowS
$cshowsPrec :: Int -> Iam -> ShowS
Prelude.Show, (forall x. Iam -> Rep Iam x)
-> (forall x. Rep Iam x -> Iam) -> Generic Iam
forall x. Rep Iam x -> Iam
forall x. Iam -> Rep Iam x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Iam x -> Iam
$cfrom :: forall x. Iam -> Rep Iam x
Prelude.Generic)

-- |
-- Create a value of 'Iam' 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', 'iam_enabled' - Indicates whether IAM access control is enabled.
newIam ::
  Iam
newIam :: Iam
newIam = Iam' :: Maybe Bool -> Iam
Iam' {$sel:enabled:Iam' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | Indicates whether IAM access control is enabled.
iam_enabled :: Lens.Lens' Iam (Prelude.Maybe Prelude.Bool)
iam_enabled :: (Maybe Bool -> f (Maybe Bool)) -> Iam -> f Iam
iam_enabled = (Iam -> Maybe Bool)
-> (Iam -> Maybe Bool -> Iam)
-> Lens Iam Iam (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Iam' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Iam' :: Iam -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: Iam
s@Iam' {} Maybe Bool
a -> Iam
s {$sel:enabled:Iam' :: Maybe Bool
enabled = Maybe Bool
a} :: Iam)

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

instance Prelude.NFData Iam

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