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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | The Availability Zone in which the node exists. Required for Ethereum
    -- nodes.
    NodeConfiguration -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | 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 Amazon Managed Blockchain instance type for the node.
    NodeConfiguration -> Text
instanceType :: Prelude.Text
  }
  deriving (NodeConfiguration -> NodeConfiguration -> Bool
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]
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
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. 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:
--
-- 'availabilityZone', 'nodeConfiguration_availabilityZone' - The Availability Zone in which the node exists. Required for Ethereum
-- nodes.
--
-- '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.
--
-- 'instanceType', 'nodeConfiguration_instanceType' - The Amazon Managed Blockchain instance type for the node.
newNodeConfiguration ::
  -- | 'instanceType'
  Prelude.Text ->
  NodeConfiguration
newNodeConfiguration :: Text -> NodeConfiguration
newNodeConfiguration Text
pInstanceType_ =
  NodeConfiguration'
    { $sel:availabilityZone:NodeConfiguration' :: Maybe Text
availabilityZone =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logPublishingConfiguration:NodeConfiguration' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:stateDB:NodeConfiguration' :: Maybe StateDBType
stateDB = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:NodeConfiguration' :: Text
instanceType = Text
pInstanceType_
    }

-- | The Availability Zone in which the node exists. Required for Ethereum
-- nodes.
nodeConfiguration_availabilityZone :: Lens.Lens' NodeConfiguration (Prelude.Maybe Prelude.Text)
nodeConfiguration_availabilityZone :: Lens' NodeConfiguration (Maybe Text)
nodeConfiguration_availabilityZone = 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)

-- | 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 :: Lens' NodeConfiguration (Maybe NodeLogPublishingConfiguration)
nodeConfiguration_logPublishingConfiguration = 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 :: Lens' NodeConfiguration (Maybe StateDBType)
nodeConfiguration_stateDB = 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 Amazon Managed Blockchain instance type for the node.
nodeConfiguration_instanceType :: Lens.Lens' NodeConfiguration Prelude.Text
nodeConfiguration_instanceType :: Lens' NodeConfiguration Text
nodeConfiguration_instanceType = 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 where
  hashWithSalt :: Int -> NodeConfiguration -> Int
hashWithSalt Int
_salt NodeConfiguration' {Maybe Text
Maybe NodeLogPublishingConfiguration
Maybe StateDBType
Text
instanceType :: Text
stateDB :: Maybe StateDBType
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
availabilityZone :: Maybe Text
$sel:instanceType:NodeConfiguration' :: NodeConfiguration -> Text
$sel:stateDB:NodeConfiguration' :: NodeConfiguration -> Maybe StateDBType
$sel:logPublishingConfiguration:NodeConfiguration' :: NodeConfiguration -> Maybe NodeLogPublishingConfiguration
$sel:availabilityZone:NodeConfiguration' :: NodeConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NodeLogPublishingConfiguration
logPublishingConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StateDBType
stateDB
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceType

instance Prelude.NFData NodeConfiguration where
  rnf :: NodeConfiguration -> ()
rnf NodeConfiguration' {Maybe Text
Maybe NodeLogPublishingConfiguration
Maybe StateDBType
Text
instanceType :: Text
stateDB :: Maybe StateDBType
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
availabilityZone :: Maybe Text
$sel:instanceType:NodeConfiguration' :: NodeConfiguration -> Text
$sel:stateDB:NodeConfiguration' :: NodeConfiguration -> Maybe StateDBType
$sel:logPublishingConfiguration:NodeConfiguration' :: NodeConfiguration -> Maybe NodeLogPublishingConfiguration
$sel:availabilityZone:NodeConfiguration' :: NodeConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NodeLogPublishingConfiguration
logPublishingConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StateDBType
stateDB
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceType

instance Data.ToJSON NodeConfiguration where
  toJSON :: NodeConfiguration -> Value
toJSON NodeConfiguration' {Maybe Text
Maybe NodeLogPublishingConfiguration
Maybe StateDBType
Text
instanceType :: Text
stateDB :: Maybe StateDBType
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
availabilityZone :: Maybe Text
$sel:instanceType:NodeConfiguration' :: NodeConfiguration -> Text
$sel:stateDB:NodeConfiguration' :: NodeConfiguration -> Maybe StateDBType
$sel:logPublishingConfiguration:NodeConfiguration' :: NodeConfiguration -> Maybe NodeLogPublishingConfiguration
$sel:availabilityZone:NodeConfiguration' :: NodeConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AvailabilityZone" 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 Text
availabilityZone,
            (Key
"LogPublishingConfiguration" 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 NodeLogPublishingConfiguration
logPublishingConfiguration,
            (Key
"StateDB" 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 StateDBType
stateDB,
            forall a. a -> Maybe a
Prelude.Just (Key
"InstanceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceType)
          ]
      )