{-# 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.MQ.Types.Logs
-- 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.MQ.Types.Logs where

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

-- | The list of information about logs to be enabled for the specified
-- broker.
--
-- /See:/ 'newLogs' smart constructor.
data Logs = Logs'
  { -- | Enables audit logging. Every user management action made using JMX or
    -- the ActiveMQ Web Console is logged. Does not apply to RabbitMQ brokers.
    Logs -> Maybe Bool
audit :: Prelude.Maybe Prelude.Bool,
    -- | Enables general logging.
    Logs -> Maybe Bool
general :: Prelude.Maybe Prelude.Bool
  }
  deriving (Logs -> Logs -> Bool
(Logs -> Logs -> Bool) -> (Logs -> Logs -> Bool) -> Eq Logs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Logs -> Logs -> Bool
$c/= :: Logs -> Logs -> Bool
== :: Logs -> Logs -> Bool
$c== :: Logs -> Logs -> Bool
Prelude.Eq, ReadPrec [Logs]
ReadPrec Logs
Int -> ReadS Logs
ReadS [Logs]
(Int -> ReadS Logs)
-> ReadS [Logs] -> ReadPrec Logs -> ReadPrec [Logs] -> Read Logs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Logs]
$creadListPrec :: ReadPrec [Logs]
readPrec :: ReadPrec Logs
$creadPrec :: ReadPrec Logs
readList :: ReadS [Logs]
$creadList :: ReadS [Logs]
readsPrec :: Int -> ReadS Logs
$creadsPrec :: Int -> ReadS Logs
Prelude.Read, Int -> Logs -> ShowS
[Logs] -> ShowS
Logs -> String
(Int -> Logs -> ShowS)
-> (Logs -> String) -> ([Logs] -> ShowS) -> Show Logs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Logs] -> ShowS
$cshowList :: [Logs] -> ShowS
show :: Logs -> String
$cshow :: Logs -> String
showsPrec :: Int -> Logs -> ShowS
$cshowsPrec :: Int -> Logs -> ShowS
Prelude.Show, (forall x. Logs -> Rep Logs x)
-> (forall x. Rep Logs x -> Logs) -> Generic Logs
forall x. Rep Logs x -> Logs
forall x. Logs -> Rep Logs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Logs x -> Logs
$cfrom :: forall x. Logs -> Rep Logs x
Prelude.Generic)

-- |
-- Create a value of 'Logs' 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:
--
-- 'audit', 'logs_audit' - Enables audit logging. Every user management action made using JMX or
-- the ActiveMQ Web Console is logged. Does not apply to RabbitMQ brokers.
--
-- 'general', 'logs_general' - Enables general logging.
newLogs ::
  Logs
newLogs :: Logs
newLogs =
  Logs' :: Maybe Bool -> Maybe Bool -> Logs
Logs'
    { $sel:audit:Logs' :: Maybe Bool
audit = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:general:Logs' :: Maybe Bool
general = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Enables audit logging. Every user management action made using JMX or
-- the ActiveMQ Web Console is logged. Does not apply to RabbitMQ brokers.
logs_audit :: Lens.Lens' Logs (Prelude.Maybe Prelude.Bool)
logs_audit :: (Maybe Bool -> f (Maybe Bool)) -> Logs -> f Logs
logs_audit = (Logs -> Maybe Bool)
-> (Logs -> Maybe Bool -> Logs)
-> Lens Logs Logs (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Logs' {Maybe Bool
audit :: Maybe Bool
$sel:audit:Logs' :: Logs -> Maybe Bool
audit} -> Maybe Bool
audit) (\s :: Logs
s@Logs' {} Maybe Bool
a -> Logs
s {$sel:audit:Logs' :: Maybe Bool
audit = Maybe Bool
a} :: Logs)

-- | Enables general logging.
logs_general :: Lens.Lens' Logs (Prelude.Maybe Prelude.Bool)
logs_general :: (Maybe Bool -> f (Maybe Bool)) -> Logs -> f Logs
logs_general = (Logs -> Maybe Bool)
-> (Logs -> Maybe Bool -> Logs)
-> Lens Logs Logs (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Logs' {Maybe Bool
general :: Maybe Bool
$sel:general:Logs' :: Logs -> Maybe Bool
general} -> Maybe Bool
general) (\s :: Logs
s@Logs' {} Maybe Bool
a -> Logs
s {$sel:general:Logs' :: Maybe Bool
general = Maybe Bool
a} :: Logs)

instance Core.FromJSON Logs where
  parseJSON :: Value -> Parser Logs
parseJSON =
    String -> (Object -> Parser Logs) -> Value -> Parser Logs
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Logs"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Logs
Logs'
            (Maybe Bool -> Maybe Bool -> Logs)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> Logs)
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
"audit")
            Parser (Maybe Bool -> Logs) -> Parser (Maybe Bool) -> Parser Logs
forall (f :: * -> *) a b. Applicative f => 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
"general")
      )

instance Prelude.Hashable Logs

instance Prelude.NFData Logs

instance Core.ToJSON Logs where
  toJSON :: Logs -> Value
toJSON Logs' {Maybe Bool
general :: Maybe Bool
audit :: Maybe Bool
$sel:general:Logs' :: Logs -> Maybe Bool
$sel:audit:Logs' :: Logs -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"audit" 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
audit,
            (Text
"general" 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
general
          ]
      )