{-# 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-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.Iam 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 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
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]
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
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. 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' {$sel:enabled:Iam' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing}

-- | Indicates whether IAM access control is enabled.
iam_enabled :: Lens.Lens' Iam (Prelude.Maybe Prelude.Bool)
iam_enabled :: Lens' Iam (Maybe Bool)
iam_enabled = 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 Data.FromJSON Iam where
  parseJSON :: Value -> Parser Iam
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Iam"
      (\Object
x -> Maybe Bool -> Iam
Iam' 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 Iam where
  hashWithSalt :: Int -> Iam -> Int
hashWithSalt Int
_salt Iam' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Iam' :: Iam -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled

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

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