{-# 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.ManagedBlockChain.Types.LogConfiguration
-- 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.ManagedBlockChain.Types.LogConfiguration where

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

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

-- |
-- Create a value of 'LogConfiguration' 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', 'logConfiguration_enabled' - Indicates whether logging is enabled.
newLogConfiguration ::
  LogConfiguration
newLogConfiguration :: LogConfiguration
newLogConfiguration =
  LogConfiguration' :: Maybe Bool -> LogConfiguration
LogConfiguration' {$sel:enabled:LogConfiguration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | Indicates whether logging is enabled.
logConfiguration_enabled :: Lens.Lens' LogConfiguration (Prelude.Maybe Prelude.Bool)
logConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> LogConfiguration -> f LogConfiguration
logConfiguration_enabled = (LogConfiguration -> Maybe Bool)
-> (LogConfiguration -> Maybe Bool -> LogConfiguration)
-> Lens LogConfiguration LogConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:LogConfiguration' :: LogConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: LogConfiguration
s@LogConfiguration' {} Maybe Bool
a -> LogConfiguration
s {$sel:enabled:LogConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: LogConfiguration)

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

instance Prelude.NFData LogConfiguration

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