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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.ManagedBlockChain.Types.NodeLogPublishingConfiguration
import Amazonka.ManagedBlockChain.Types.StateDBType
import qualified Amazonka.Prelude as Prelude

-- | Configuration properties of a node.
--
-- /See:/ 'newNodeConfiguration' smart constructor.
data NodeConfiguration = NodeConfiguration'
  { -- | Configuration properties for logging events associated with a peer node
    -- on a Hyperledger Fabric network on Managed Blockchain.
    NodeConfiguration -> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration :: Prelude.Maybe NodeLogPublishingConfiguration,
    -- | The state database that the node uses. Values are @LevelDB@ or
    -- @CouchDB@. When using an Amazon Managed Blockchain network with
    -- Hyperledger Fabric version 1.4 or later, the default is @CouchDB@.
    --
    -- Applies only to Hyperledger Fabric.
    NodeConfiguration -> Maybe StateDBType
stateDB :: Prelude.Maybe StateDBType,
    -- | The Availability Zone in which the node exists. Required for Ethereum
    -- nodes.
    NodeConfiguration -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Managed Blockchain instance type for the node.
    NodeConfiguration -> Text
instanceType :: Prelude.Text
  }
  deriving (NodeConfiguration -> NodeConfiguration -> Bool
(NodeConfiguration -> NodeConfiguration -> Bool)
-> (NodeConfiguration -> NodeConfiguration -> Bool)
-> Eq NodeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeConfiguration -> NodeConfiguration -> Bool
$c/= :: NodeConfiguration -> NodeConfiguration -> Bool
== :: NodeConfiguration -> NodeConfiguration -> Bool
$c== :: NodeConfiguration -> NodeConfiguration -> Bool
Prelude.Eq, ReadPrec [NodeConfiguration]
ReadPrec NodeConfiguration
Int -> ReadS NodeConfiguration
ReadS [NodeConfiguration]
(Int -> ReadS NodeConfiguration)
-> ReadS [NodeConfiguration]
-> ReadPrec NodeConfiguration
-> ReadPrec [NodeConfiguration]
-> Read NodeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodeConfiguration]
$creadListPrec :: ReadPrec [NodeConfiguration]
readPrec :: ReadPrec NodeConfiguration
$creadPrec :: ReadPrec NodeConfiguration
readList :: ReadS [NodeConfiguration]
$creadList :: ReadS [NodeConfiguration]
readsPrec :: Int -> ReadS NodeConfiguration
$creadsPrec :: Int -> ReadS NodeConfiguration
Prelude.Read, Int -> NodeConfiguration -> ShowS
[NodeConfiguration] -> ShowS
NodeConfiguration -> String
(Int -> NodeConfiguration -> ShowS)
-> (NodeConfiguration -> String)
-> ([NodeConfiguration] -> ShowS)
-> Show NodeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeConfiguration] -> ShowS
$cshowList :: [NodeConfiguration] -> ShowS
show :: NodeConfiguration -> String
$cshow :: NodeConfiguration -> String
showsPrec :: Int -> NodeConfiguration -> ShowS
$cshowsPrec :: Int -> NodeConfiguration -> ShowS
Prelude.Show, (forall x. NodeConfiguration -> Rep NodeConfiguration x)
-> (forall x. Rep NodeConfiguration x -> NodeConfiguration)
-> Generic NodeConfiguration
forall x. Rep NodeConfiguration x -> NodeConfiguration
forall x. NodeConfiguration -> Rep NodeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodeConfiguration x -> NodeConfiguration
$cfrom :: forall x. NodeConfiguration -> Rep NodeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NodeConfiguration' 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:
--
-- 'logPublishingConfiguration', 'nodeConfiguration_logPublishingConfiguration' - Configuration properties for logging events associated with a peer node
-- on a Hyperledger Fabric network on Managed Blockchain.
--
-- 'stateDB', 'nodeConfiguration_stateDB' - The state database that the node uses. Values are @LevelDB@ or
-- @CouchDB@. When using an Amazon Managed Blockchain network with
-- Hyperledger Fabric version 1.4 or later, the default is @CouchDB@.
--
-- Applies only to Hyperledger Fabric.
--
-- 'availabilityZone', 'nodeConfiguration_availabilityZone' - The Availability Zone in which the node exists. Required for Ethereum
-- nodes.
--
-- 'instanceType', 'nodeConfiguration_instanceType' - The Amazon Managed Blockchain instance type for the node.
newNodeConfiguration ::
  -- | 'instanceType'
  Prelude.Text ->
  NodeConfiguration
newNodeConfiguration :: Text -> NodeConfiguration
newNodeConfiguration Text
pInstanceType_ =
  NodeConfiguration' :: Maybe NodeLogPublishingConfiguration
-> Maybe StateDBType -> Maybe Text -> Text -> NodeConfiguration
NodeConfiguration'
    { $sel:logPublishingConfiguration:NodeConfiguration' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration =
        Maybe NodeLogPublishingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:stateDB:NodeConfiguration' :: Maybe StateDBType
stateDB = Maybe StateDBType
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:NodeConfiguration' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:NodeConfiguration' :: Text
instanceType = Text
pInstanceType_
    }

-- | Configuration properties for logging events associated with a peer node
-- on a Hyperledger Fabric network on Managed Blockchain.
nodeConfiguration_logPublishingConfiguration :: Lens.Lens' NodeConfiguration (Prelude.Maybe NodeLogPublishingConfiguration)
nodeConfiguration_logPublishingConfiguration :: (Maybe NodeLogPublishingConfiguration
 -> f (Maybe NodeLogPublishingConfiguration))
-> NodeConfiguration -> f NodeConfiguration
nodeConfiguration_logPublishingConfiguration = (NodeConfiguration -> Maybe NodeLogPublishingConfiguration)
-> (NodeConfiguration
    -> Maybe NodeLogPublishingConfiguration -> NodeConfiguration)
-> Lens
     NodeConfiguration
     NodeConfiguration
     (Maybe NodeLogPublishingConfiguration)
     (Maybe NodeLogPublishingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeConfiguration' {Maybe NodeLogPublishingConfiguration
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
$sel:logPublishingConfiguration:NodeConfiguration' :: NodeConfiguration -> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration} -> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration) (\s :: NodeConfiguration
s@NodeConfiguration' {} Maybe NodeLogPublishingConfiguration
a -> NodeConfiguration
s {$sel:logPublishingConfiguration:NodeConfiguration' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration = Maybe NodeLogPublishingConfiguration
a} :: NodeConfiguration)

-- | The state database that the node uses. Values are @LevelDB@ or
-- @CouchDB@. When using an Amazon Managed Blockchain network with
-- Hyperledger Fabric version 1.4 or later, the default is @CouchDB@.
--
-- Applies only to Hyperledger Fabric.
nodeConfiguration_stateDB :: Lens.Lens' NodeConfiguration (Prelude.Maybe StateDBType)
nodeConfiguration_stateDB :: (Maybe StateDBType -> f (Maybe StateDBType))
-> NodeConfiguration -> f NodeConfiguration
nodeConfiguration_stateDB = (NodeConfiguration -> Maybe StateDBType)
-> (NodeConfiguration -> Maybe StateDBType -> NodeConfiguration)
-> Lens
     NodeConfiguration
     NodeConfiguration
     (Maybe StateDBType)
     (Maybe StateDBType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeConfiguration' {Maybe StateDBType
stateDB :: Maybe StateDBType
$sel:stateDB:NodeConfiguration' :: NodeConfiguration -> Maybe StateDBType
stateDB} -> Maybe StateDBType
stateDB) (\s :: NodeConfiguration
s@NodeConfiguration' {} Maybe StateDBType
a -> NodeConfiguration
s {$sel:stateDB:NodeConfiguration' :: Maybe StateDBType
stateDB = Maybe StateDBType
a} :: NodeConfiguration)

-- | The Availability Zone in which the node exists. Required for Ethereum
-- nodes.
nodeConfiguration_availabilityZone :: Lens.Lens' NodeConfiguration (Prelude.Maybe Prelude.Text)
nodeConfiguration_availabilityZone :: (Maybe Text -> f (Maybe Text))
-> NodeConfiguration -> f NodeConfiguration
nodeConfiguration_availabilityZone = (NodeConfiguration -> Maybe Text)
-> (NodeConfiguration -> Maybe Text -> NodeConfiguration)
-> Lens
     NodeConfiguration NodeConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeConfiguration' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:NodeConfiguration' :: NodeConfiguration -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: NodeConfiguration
s@NodeConfiguration' {} Maybe Text
a -> NodeConfiguration
s {$sel:availabilityZone:NodeConfiguration' :: Maybe Text
availabilityZone = Maybe Text
a} :: NodeConfiguration)

-- | The Amazon Managed Blockchain instance type for the node.
nodeConfiguration_instanceType :: Lens.Lens' NodeConfiguration Prelude.Text
nodeConfiguration_instanceType :: (Text -> f Text) -> NodeConfiguration -> f NodeConfiguration
nodeConfiguration_instanceType = (NodeConfiguration -> Text)
-> (NodeConfiguration -> Text -> NodeConfiguration)
-> Lens NodeConfiguration NodeConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeConfiguration' {Text
instanceType :: Text
$sel:instanceType:NodeConfiguration' :: NodeConfiguration -> Text
instanceType} -> Text
instanceType) (\s :: NodeConfiguration
s@NodeConfiguration' {} Text
a -> NodeConfiguration
s {$sel:instanceType:NodeConfiguration' :: Text
instanceType = Text
a} :: NodeConfiguration)

instance Prelude.Hashable NodeConfiguration

instance Prelude.NFData NodeConfiguration

instance Core.ToJSON NodeConfiguration where
  toJSON :: NodeConfiguration -> Value
toJSON NodeConfiguration' {Maybe Text
Maybe NodeLogPublishingConfiguration
Maybe StateDBType
Text
instanceType :: Text
availabilityZone :: Maybe Text
stateDB :: Maybe StateDBType
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
$sel:instanceType:NodeConfiguration' :: NodeConfiguration -> Text
$sel:availabilityZone:NodeConfiguration' :: NodeConfiguration -> Maybe Text
$sel:stateDB:NodeConfiguration' :: NodeConfiguration -> Maybe StateDBType
$sel:logPublishingConfiguration:NodeConfiguration' :: NodeConfiguration -> Maybe NodeLogPublishingConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LogPublishingConfiguration" Text -> NodeLogPublishingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NodeLogPublishingConfiguration -> Pair)
-> Maybe NodeLogPublishingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration,
            (Text
"StateDB" Text -> StateDBType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StateDBType -> Pair) -> Maybe StateDBType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StateDBType
stateDB,
            (Text
"AvailabilityZone" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
availabilityZone,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceType)
          ]
      )