{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MQ.Types.Logs 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

-- | 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
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]
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
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. 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'
    { $sel:audit:Logs' :: Maybe Bool
audit = forall a. Maybe a
Prelude.Nothing,
      $sel:general:Logs' :: Maybe Bool
general = 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 :: Lens' Logs (Maybe Bool)
logs_audit = 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 :: Lens' Logs (Maybe Bool)
logs_general = 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 Data.FromJSON Logs where
  parseJSON :: Value -> Parser Logs
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Logs"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Logs
Logs'
            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
"audit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"general")
      )

instance Prelude.Hashable Logs where
  hashWithSalt :: Int -> Logs -> Int
hashWithSalt Int
_salt Logs' {Maybe Bool
general :: Maybe Bool
audit :: Maybe Bool
$sel:general:Logs' :: Logs -> Maybe Bool
$sel:audit:Logs' :: Logs -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
audit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
general

instance Prelude.NFData Logs where
  rnf :: Logs -> ()
rnf Logs' {Maybe Bool
general :: Maybe Bool
audit :: Maybe Bool
$sel:general:Logs' :: Logs -> Maybe Bool
$sel:audit:Logs' :: Logs -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
audit seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
general

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"audit" 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
audit,
            (Key
"general" 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
general
          ]
      )