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

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

-- | Configuration properties for logging events associated with a peer node
-- owned by a member in a Managed Blockchain network.
--
-- /See:/ 'newNodeFabricLogPublishingConfiguration' smart constructor.
data NodeFabricLogPublishingConfiguration = NodeFabricLogPublishingConfiguration'
  { -- | Configuration properties for logging events associated with chaincode
    -- execution on a peer node. Chaincode logs contain the results of
    -- instantiating, invoking, and querying the chaincode. A peer can run
    -- multiple instances of chaincode. When enabled, a log stream is created
    -- for all chaincodes, with an individual log stream for each chaincode.
    NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations
chaincodeLogs :: Prelude.Maybe LogConfigurations,
    -- | Configuration properties for a peer node log. Peer node logs contain
    -- messages generated when your client submits transaction proposals to
    -- peer nodes, requests to join channels, enrolls an admin peer, and lists
    -- the chaincode instances on a peer node.
    NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations
peerLogs :: Prelude.Maybe LogConfigurations
  }
  deriving (NodeFabricLogPublishingConfiguration
-> NodeFabricLogPublishingConfiguration -> Bool
(NodeFabricLogPublishingConfiguration
 -> NodeFabricLogPublishingConfiguration -> Bool)
-> (NodeFabricLogPublishingConfiguration
    -> NodeFabricLogPublishingConfiguration -> Bool)
-> Eq NodeFabricLogPublishingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeFabricLogPublishingConfiguration
-> NodeFabricLogPublishingConfiguration -> Bool
$c/= :: NodeFabricLogPublishingConfiguration
-> NodeFabricLogPublishingConfiguration -> Bool
== :: NodeFabricLogPublishingConfiguration
-> NodeFabricLogPublishingConfiguration -> Bool
$c== :: NodeFabricLogPublishingConfiguration
-> NodeFabricLogPublishingConfiguration -> Bool
Prelude.Eq, ReadPrec [NodeFabricLogPublishingConfiguration]
ReadPrec NodeFabricLogPublishingConfiguration
Int -> ReadS NodeFabricLogPublishingConfiguration
ReadS [NodeFabricLogPublishingConfiguration]
(Int -> ReadS NodeFabricLogPublishingConfiguration)
-> ReadS [NodeFabricLogPublishingConfiguration]
-> ReadPrec NodeFabricLogPublishingConfiguration
-> ReadPrec [NodeFabricLogPublishingConfiguration]
-> Read NodeFabricLogPublishingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodeFabricLogPublishingConfiguration]
$creadListPrec :: ReadPrec [NodeFabricLogPublishingConfiguration]
readPrec :: ReadPrec NodeFabricLogPublishingConfiguration
$creadPrec :: ReadPrec NodeFabricLogPublishingConfiguration
readList :: ReadS [NodeFabricLogPublishingConfiguration]
$creadList :: ReadS [NodeFabricLogPublishingConfiguration]
readsPrec :: Int -> ReadS NodeFabricLogPublishingConfiguration
$creadsPrec :: Int -> ReadS NodeFabricLogPublishingConfiguration
Prelude.Read, Int -> NodeFabricLogPublishingConfiguration -> ShowS
[NodeFabricLogPublishingConfiguration] -> ShowS
NodeFabricLogPublishingConfiguration -> String
(Int -> NodeFabricLogPublishingConfiguration -> ShowS)
-> (NodeFabricLogPublishingConfiguration -> String)
-> ([NodeFabricLogPublishingConfiguration] -> ShowS)
-> Show NodeFabricLogPublishingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeFabricLogPublishingConfiguration] -> ShowS
$cshowList :: [NodeFabricLogPublishingConfiguration] -> ShowS
show :: NodeFabricLogPublishingConfiguration -> String
$cshow :: NodeFabricLogPublishingConfiguration -> String
showsPrec :: Int -> NodeFabricLogPublishingConfiguration -> ShowS
$cshowsPrec :: Int -> NodeFabricLogPublishingConfiguration -> ShowS
Prelude.Show, (forall x.
 NodeFabricLogPublishingConfiguration
 -> Rep NodeFabricLogPublishingConfiguration x)
-> (forall x.
    Rep NodeFabricLogPublishingConfiguration x
    -> NodeFabricLogPublishingConfiguration)
-> Generic NodeFabricLogPublishingConfiguration
forall x.
Rep NodeFabricLogPublishingConfiguration x
-> NodeFabricLogPublishingConfiguration
forall x.
NodeFabricLogPublishingConfiguration
-> Rep NodeFabricLogPublishingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NodeFabricLogPublishingConfiguration x
-> NodeFabricLogPublishingConfiguration
$cfrom :: forall x.
NodeFabricLogPublishingConfiguration
-> Rep NodeFabricLogPublishingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NodeFabricLogPublishingConfiguration' 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:
--
-- 'chaincodeLogs', 'nodeFabricLogPublishingConfiguration_chaincodeLogs' - Configuration properties for logging events associated with chaincode
-- execution on a peer node. Chaincode logs contain the results of
-- instantiating, invoking, and querying the chaincode. A peer can run
-- multiple instances of chaincode. When enabled, a log stream is created
-- for all chaincodes, with an individual log stream for each chaincode.
--
-- 'peerLogs', 'nodeFabricLogPublishingConfiguration_peerLogs' - Configuration properties for a peer node log. Peer node logs contain
-- messages generated when your client submits transaction proposals to
-- peer nodes, requests to join channels, enrolls an admin peer, and lists
-- the chaincode instances on a peer node.
newNodeFabricLogPublishingConfiguration ::
  NodeFabricLogPublishingConfiguration
newNodeFabricLogPublishingConfiguration :: NodeFabricLogPublishingConfiguration
newNodeFabricLogPublishingConfiguration =
  NodeFabricLogPublishingConfiguration' :: Maybe LogConfigurations
-> Maybe LogConfigurations -> NodeFabricLogPublishingConfiguration
NodeFabricLogPublishingConfiguration'
    { $sel:chaincodeLogs:NodeFabricLogPublishingConfiguration' :: Maybe LogConfigurations
chaincodeLogs =
        Maybe LogConfigurations
forall a. Maybe a
Prelude.Nothing,
      $sel:peerLogs:NodeFabricLogPublishingConfiguration' :: Maybe LogConfigurations
peerLogs = Maybe LogConfigurations
forall a. Maybe a
Prelude.Nothing
    }

-- | Configuration properties for logging events associated with chaincode
-- execution on a peer node. Chaincode logs contain the results of
-- instantiating, invoking, and querying the chaincode. A peer can run
-- multiple instances of chaincode. When enabled, a log stream is created
-- for all chaincodes, with an individual log stream for each chaincode.
nodeFabricLogPublishingConfiguration_chaincodeLogs :: Lens.Lens' NodeFabricLogPublishingConfiguration (Prelude.Maybe LogConfigurations)
nodeFabricLogPublishingConfiguration_chaincodeLogs :: (Maybe LogConfigurations -> f (Maybe LogConfigurations))
-> NodeFabricLogPublishingConfiguration
-> f NodeFabricLogPublishingConfiguration
nodeFabricLogPublishingConfiguration_chaincodeLogs = (NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations)
-> (NodeFabricLogPublishingConfiguration
    -> Maybe LogConfigurations -> NodeFabricLogPublishingConfiguration)
-> Lens
     NodeFabricLogPublishingConfiguration
     NodeFabricLogPublishingConfiguration
     (Maybe LogConfigurations)
     (Maybe LogConfigurations)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeFabricLogPublishingConfiguration' {Maybe LogConfigurations
chaincodeLogs :: Maybe LogConfigurations
$sel:chaincodeLogs:NodeFabricLogPublishingConfiguration' :: NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations
chaincodeLogs} -> Maybe LogConfigurations
chaincodeLogs) (\s :: NodeFabricLogPublishingConfiguration
s@NodeFabricLogPublishingConfiguration' {} Maybe LogConfigurations
a -> NodeFabricLogPublishingConfiguration
s {$sel:chaincodeLogs:NodeFabricLogPublishingConfiguration' :: Maybe LogConfigurations
chaincodeLogs = Maybe LogConfigurations
a} :: NodeFabricLogPublishingConfiguration)

-- | Configuration properties for a peer node log. Peer node logs contain
-- messages generated when your client submits transaction proposals to
-- peer nodes, requests to join channels, enrolls an admin peer, and lists
-- the chaincode instances on a peer node.
nodeFabricLogPublishingConfiguration_peerLogs :: Lens.Lens' NodeFabricLogPublishingConfiguration (Prelude.Maybe LogConfigurations)
nodeFabricLogPublishingConfiguration_peerLogs :: (Maybe LogConfigurations -> f (Maybe LogConfigurations))
-> NodeFabricLogPublishingConfiguration
-> f NodeFabricLogPublishingConfiguration
nodeFabricLogPublishingConfiguration_peerLogs = (NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations)
-> (NodeFabricLogPublishingConfiguration
    -> Maybe LogConfigurations -> NodeFabricLogPublishingConfiguration)
-> Lens
     NodeFabricLogPublishingConfiguration
     NodeFabricLogPublishingConfiguration
     (Maybe LogConfigurations)
     (Maybe LogConfigurations)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeFabricLogPublishingConfiguration' {Maybe LogConfigurations
peerLogs :: Maybe LogConfigurations
$sel:peerLogs:NodeFabricLogPublishingConfiguration' :: NodeFabricLogPublishingConfiguration -> Maybe LogConfigurations
peerLogs} -> Maybe LogConfigurations
peerLogs) (\s :: NodeFabricLogPublishingConfiguration
s@NodeFabricLogPublishingConfiguration' {} Maybe LogConfigurations
a -> NodeFabricLogPublishingConfiguration
s {$sel:peerLogs:NodeFabricLogPublishingConfiguration' :: Maybe LogConfigurations
peerLogs = Maybe LogConfigurations
a} :: NodeFabricLogPublishingConfiguration)

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

instance
  Prelude.Hashable
    NodeFabricLogPublishingConfiguration

instance
  Prelude.NFData
    NodeFabricLogPublishingConfiguration

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