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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.ManagedBlockChain.Types.LogConfiguration
import qualified Amazonka.Prelude as Prelude

-- | A collection of log configurations.
--
-- /See:/ 'newLogConfigurations' smart constructor.
data LogConfigurations = LogConfigurations'
  { -- | Parameters for publishing logs to Amazon CloudWatch Logs.
    LogConfigurations -> Maybe LogConfiguration
cloudwatch :: Prelude.Maybe LogConfiguration
  }
  deriving (LogConfigurations -> LogConfigurations -> Bool
(LogConfigurations -> LogConfigurations -> Bool)
-> (LogConfigurations -> LogConfigurations -> Bool)
-> Eq LogConfigurations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogConfigurations -> LogConfigurations -> Bool
$c/= :: LogConfigurations -> LogConfigurations -> Bool
== :: LogConfigurations -> LogConfigurations -> Bool
$c== :: LogConfigurations -> LogConfigurations -> Bool
Prelude.Eq, ReadPrec [LogConfigurations]
ReadPrec LogConfigurations
Int -> ReadS LogConfigurations
ReadS [LogConfigurations]
(Int -> ReadS LogConfigurations)
-> ReadS [LogConfigurations]
-> ReadPrec LogConfigurations
-> ReadPrec [LogConfigurations]
-> Read LogConfigurations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogConfigurations]
$creadListPrec :: ReadPrec [LogConfigurations]
readPrec :: ReadPrec LogConfigurations
$creadPrec :: ReadPrec LogConfigurations
readList :: ReadS [LogConfigurations]
$creadList :: ReadS [LogConfigurations]
readsPrec :: Int -> ReadS LogConfigurations
$creadsPrec :: Int -> ReadS LogConfigurations
Prelude.Read, Int -> LogConfigurations -> ShowS
[LogConfigurations] -> ShowS
LogConfigurations -> String
(Int -> LogConfigurations -> ShowS)
-> (LogConfigurations -> String)
-> ([LogConfigurations] -> ShowS)
-> Show LogConfigurations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogConfigurations] -> ShowS
$cshowList :: [LogConfigurations] -> ShowS
show :: LogConfigurations -> String
$cshow :: LogConfigurations -> String
showsPrec :: Int -> LogConfigurations -> ShowS
$cshowsPrec :: Int -> LogConfigurations -> ShowS
Prelude.Show, (forall x. LogConfigurations -> Rep LogConfigurations x)
-> (forall x. Rep LogConfigurations x -> LogConfigurations)
-> Generic LogConfigurations
forall x. Rep LogConfigurations x -> LogConfigurations
forall x. LogConfigurations -> Rep LogConfigurations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogConfigurations x -> LogConfigurations
$cfrom :: forall x. LogConfigurations -> Rep LogConfigurations x
Prelude.Generic)

-- |
-- Create a value of 'LogConfigurations' 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:
--
-- 'cloudwatch', 'logConfigurations_cloudwatch' - Parameters for publishing logs to Amazon CloudWatch Logs.
newLogConfigurations ::
  LogConfigurations
newLogConfigurations :: LogConfigurations
newLogConfigurations =
  LogConfigurations' :: Maybe LogConfiguration -> LogConfigurations
LogConfigurations' {$sel:cloudwatch:LogConfigurations' :: Maybe LogConfiguration
cloudwatch = Maybe LogConfiguration
forall a. Maybe a
Prelude.Nothing}

-- | Parameters for publishing logs to Amazon CloudWatch Logs.
logConfigurations_cloudwatch :: Lens.Lens' LogConfigurations (Prelude.Maybe LogConfiguration)
logConfigurations_cloudwatch :: (Maybe LogConfiguration -> f (Maybe LogConfiguration))
-> LogConfigurations -> f LogConfigurations
logConfigurations_cloudwatch = (LogConfigurations -> Maybe LogConfiguration)
-> (LogConfigurations
    -> Maybe LogConfiguration -> LogConfigurations)
-> Lens
     LogConfigurations
     LogConfigurations
     (Maybe LogConfiguration)
     (Maybe LogConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogConfigurations' {Maybe LogConfiguration
cloudwatch :: Maybe LogConfiguration
$sel:cloudwatch:LogConfigurations' :: LogConfigurations -> Maybe LogConfiguration
cloudwatch} -> Maybe LogConfiguration
cloudwatch) (\s :: LogConfigurations
s@LogConfigurations' {} Maybe LogConfiguration
a -> LogConfigurations
s {$sel:cloudwatch:LogConfigurations' :: Maybe LogConfiguration
cloudwatch = Maybe LogConfiguration
a} :: LogConfigurations)

instance Core.FromJSON LogConfigurations where
  parseJSON :: Value -> Parser LogConfigurations
parseJSON =
    String
-> (Object -> Parser LogConfigurations)
-> Value
-> Parser LogConfigurations
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogConfigurations"
      ( \Object
x ->
          Maybe LogConfiguration -> LogConfigurations
LogConfigurations'
            (Maybe LogConfiguration -> LogConfigurations)
-> Parser (Maybe LogConfiguration) -> Parser LogConfigurations
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LogConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Cloudwatch")
      )

instance Prelude.Hashable LogConfigurations

instance Prelude.NFData LogConfigurations

instance Core.ToJSON LogConfigurations where
  toJSON :: LogConfigurations -> Value
toJSON LogConfigurations' {Maybe LogConfiguration
cloudwatch :: Maybe LogConfiguration
$sel:cloudwatch:LogConfigurations' :: LogConfigurations -> Maybe LogConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Cloudwatch" Text -> LogConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LogConfiguration -> Pair) -> Maybe LogConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LogConfiguration
cloudwatch]
      )