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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.ManagedBlockChain.Types.MemberFrameworkConfiguration
import Amazonka.ManagedBlockChain.Types.MemberLogPublishingConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Configuration properties of the member.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newMemberConfiguration' smart constructor.
data MemberConfiguration = MemberConfiguration'
  { -- | The Amazon Resource Name (ARN) of the customer managed key in AWS Key
    -- Management Service (AWS KMS) to use for encryption at rest in the
    -- member. This parameter is inherited by any nodes that this member
    -- creates.
    --
    -- Use one of the following options to specify this parameter:
    --
    -- -   __Undefined or empty string__ - The member uses an AWS owned KMS key
    --     for encryption by default.
    --
    -- -   __A valid symmetric customer managed KMS key__ - The member uses the
    --     specified key for encryption.
    --
    --     Amazon Managed Blockchain doesn\'t support asymmetric keys. For more
    --     information, see
    --     <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
    --     in the /AWS Key Management Service Developer Guide/.
    --
    --     The following is an example of a KMS key ARN:
    --     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
    MemberConfiguration -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | Configuration properties for logging events associated with a member of
    -- a Managed Blockchain network.
    MemberConfiguration -> Maybe MemberLogPublishingConfiguration
logPublishingConfiguration :: Prelude.Maybe MemberLogPublishingConfiguration,
    -- | An optional description of the member.
    MemberConfiguration -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Tags assigned to the member. Tags consist of a key and optional value.
    -- For more information about tags, see
    -- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
    -- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
    --
    -- When specifying tags during creation, you can specify multiple key-value
    -- pairs in a single request, with an overall maximum of 50 tags added to
    -- each resource.
    MemberConfiguration -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the member.
    MemberConfiguration -> Text
name :: Prelude.Text,
    -- | Configuration properties of the blockchain framework relevant to the
    -- member.
    MemberConfiguration -> MemberFrameworkConfiguration
frameworkConfiguration :: MemberFrameworkConfiguration
  }
  deriving (MemberConfiguration -> MemberConfiguration -> Bool
(MemberConfiguration -> MemberConfiguration -> Bool)
-> (MemberConfiguration -> MemberConfiguration -> Bool)
-> Eq MemberConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemberConfiguration -> MemberConfiguration -> Bool
$c/= :: MemberConfiguration -> MemberConfiguration -> Bool
== :: MemberConfiguration -> MemberConfiguration -> Bool
$c== :: MemberConfiguration -> MemberConfiguration -> Bool
Prelude.Eq, Int -> MemberConfiguration -> ShowS
[MemberConfiguration] -> ShowS
MemberConfiguration -> String
(Int -> MemberConfiguration -> ShowS)
-> (MemberConfiguration -> String)
-> ([MemberConfiguration] -> ShowS)
-> Show MemberConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemberConfiguration] -> ShowS
$cshowList :: [MemberConfiguration] -> ShowS
show :: MemberConfiguration -> String
$cshow :: MemberConfiguration -> String
showsPrec :: Int -> MemberConfiguration -> ShowS
$cshowsPrec :: Int -> MemberConfiguration -> ShowS
Prelude.Show, (forall x. MemberConfiguration -> Rep MemberConfiguration x)
-> (forall x. Rep MemberConfiguration x -> MemberConfiguration)
-> Generic MemberConfiguration
forall x. Rep MemberConfiguration x -> MemberConfiguration
forall x. MemberConfiguration -> Rep MemberConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemberConfiguration x -> MemberConfiguration
$cfrom :: forall x. MemberConfiguration -> Rep MemberConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'MemberConfiguration' 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:
--
-- 'kmsKeyArn', 'memberConfiguration_kmsKeyArn' - The Amazon Resource Name (ARN) of the customer managed key in AWS Key
-- Management Service (AWS KMS) to use for encryption at rest in the
-- member. This parameter is inherited by any nodes that this member
-- creates.
--
-- Use one of the following options to specify this parameter:
--
-- -   __Undefined or empty string__ - The member uses an AWS owned KMS key
--     for encryption by default.
--
-- -   __A valid symmetric customer managed KMS key__ - The member uses the
--     specified key for encryption.
--
--     Amazon Managed Blockchain doesn\'t support asymmetric keys. For more
--     information, see
--     <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
--     in the /AWS Key Management Service Developer Guide/.
--
--     The following is an example of a KMS key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- 'logPublishingConfiguration', 'memberConfiguration_logPublishingConfiguration' - Configuration properties for logging events associated with a member of
-- a Managed Blockchain network.
--
-- 'description', 'memberConfiguration_description' - An optional description of the member.
--
-- 'tags', 'memberConfiguration_tags' - Tags assigned to the member. Tags consist of a key and optional value.
-- For more information about tags, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
--
-- When specifying tags during creation, you can specify multiple key-value
-- pairs in a single request, with an overall maximum of 50 tags added to
-- each resource.
--
-- 'name', 'memberConfiguration_name' - The name of the member.
--
-- 'frameworkConfiguration', 'memberConfiguration_frameworkConfiguration' - Configuration properties of the blockchain framework relevant to the
-- member.
newMemberConfiguration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'frameworkConfiguration'
  MemberFrameworkConfiguration ->
  MemberConfiguration
newMemberConfiguration :: Text -> MemberFrameworkConfiguration -> MemberConfiguration
newMemberConfiguration
  Text
pName_
  MemberFrameworkConfiguration
pFrameworkConfiguration_ =
    MemberConfiguration' :: Maybe Text
-> Maybe MemberLogPublishingConfiguration
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> MemberFrameworkConfiguration
-> MemberConfiguration
MemberConfiguration'
      { $sel:kmsKeyArn:MemberConfiguration' :: Maybe Text
kmsKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:logPublishingConfiguration:MemberConfiguration' :: Maybe MemberLogPublishingConfiguration
logPublishingConfiguration = Maybe MemberLogPublishingConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:description:MemberConfiguration' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:MemberConfiguration' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:name:MemberConfiguration' :: Text
name = Text
pName_,
        $sel:frameworkConfiguration:MemberConfiguration' :: MemberFrameworkConfiguration
frameworkConfiguration = MemberFrameworkConfiguration
pFrameworkConfiguration_
      }

-- | The Amazon Resource Name (ARN) of the customer managed key in AWS Key
-- Management Service (AWS KMS) to use for encryption at rest in the
-- member. This parameter is inherited by any nodes that this member
-- creates.
--
-- Use one of the following options to specify this parameter:
--
-- -   __Undefined or empty string__ - The member uses an AWS owned KMS key
--     for encryption by default.
--
-- -   __A valid symmetric customer managed KMS key__ - The member uses the
--     specified key for encryption.
--
--     Amazon Managed Blockchain doesn\'t support asymmetric keys. For more
--     information, see
--     <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html Using symmetric and asymmetric keys>
--     in the /AWS Key Management Service Developer Guide/.
--
--     The following is an example of a KMS key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
memberConfiguration_kmsKeyArn :: Lens.Lens' MemberConfiguration (Prelude.Maybe Prelude.Text)
memberConfiguration_kmsKeyArn :: (Maybe Text -> f (Maybe Text))
-> MemberConfiguration -> f MemberConfiguration
memberConfiguration_kmsKeyArn = (MemberConfiguration -> Maybe Text)
-> (MemberConfiguration -> Maybe Text -> MemberConfiguration)
-> Lens
     MemberConfiguration MemberConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:MemberConfiguration' :: MemberConfiguration -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: MemberConfiguration
s@MemberConfiguration' {} Maybe Text
a -> MemberConfiguration
s {$sel:kmsKeyArn:MemberConfiguration' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: MemberConfiguration)

-- | Configuration properties for logging events associated with a member of
-- a Managed Blockchain network.
memberConfiguration_logPublishingConfiguration :: Lens.Lens' MemberConfiguration (Prelude.Maybe MemberLogPublishingConfiguration)
memberConfiguration_logPublishingConfiguration :: (Maybe MemberLogPublishingConfiguration
 -> f (Maybe MemberLogPublishingConfiguration))
-> MemberConfiguration -> f MemberConfiguration
memberConfiguration_logPublishingConfiguration = (MemberConfiguration -> Maybe MemberLogPublishingConfiguration)
-> (MemberConfiguration
    -> Maybe MemberLogPublishingConfiguration -> MemberConfiguration)
-> Lens
     MemberConfiguration
     MemberConfiguration
     (Maybe MemberLogPublishingConfiguration)
     (Maybe MemberLogPublishingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {Maybe MemberLogPublishingConfiguration
logPublishingConfiguration :: Maybe MemberLogPublishingConfiguration
$sel:logPublishingConfiguration:MemberConfiguration' :: MemberConfiguration -> Maybe MemberLogPublishingConfiguration
logPublishingConfiguration} -> Maybe MemberLogPublishingConfiguration
logPublishingConfiguration) (\s :: MemberConfiguration
s@MemberConfiguration' {} Maybe MemberLogPublishingConfiguration
a -> MemberConfiguration
s {$sel:logPublishingConfiguration:MemberConfiguration' :: Maybe MemberLogPublishingConfiguration
logPublishingConfiguration = Maybe MemberLogPublishingConfiguration
a} :: MemberConfiguration)

-- | An optional description of the member.
memberConfiguration_description :: Lens.Lens' MemberConfiguration (Prelude.Maybe Prelude.Text)
memberConfiguration_description :: (Maybe Text -> f (Maybe Text))
-> MemberConfiguration -> f MemberConfiguration
memberConfiguration_description = (MemberConfiguration -> Maybe Text)
-> (MemberConfiguration -> Maybe Text -> MemberConfiguration)
-> Lens
     MemberConfiguration MemberConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {Maybe Text
description :: Maybe Text
$sel:description:MemberConfiguration' :: MemberConfiguration -> Maybe Text
description} -> Maybe Text
description) (\s :: MemberConfiguration
s@MemberConfiguration' {} Maybe Text
a -> MemberConfiguration
s {$sel:description:MemberConfiguration' :: Maybe Text
description = Maybe Text
a} :: MemberConfiguration)

-- | Tags assigned to the member. Tags consist of a key and optional value.
-- For more information about tags, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
--
-- When specifying tags during creation, you can specify multiple key-value
-- pairs in a single request, with an overall maximum of 50 tags added to
-- each resource.
memberConfiguration_tags :: Lens.Lens' MemberConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
memberConfiguration_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MemberConfiguration -> f MemberConfiguration
memberConfiguration_tags = (MemberConfiguration -> Maybe (HashMap Text Text))
-> (MemberConfiguration
    -> Maybe (HashMap Text Text) -> MemberConfiguration)
-> Lens
     MemberConfiguration
     MemberConfiguration
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:MemberConfiguration' :: MemberConfiguration -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: MemberConfiguration
s@MemberConfiguration' {} Maybe (HashMap Text Text)
a -> MemberConfiguration
s {$sel:tags:MemberConfiguration' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: MemberConfiguration) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> MemberConfiguration -> f MemberConfiguration)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MemberConfiguration
-> f MemberConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the member.
memberConfiguration_name :: Lens.Lens' MemberConfiguration Prelude.Text
memberConfiguration_name :: (Text -> f Text) -> MemberConfiguration -> f MemberConfiguration
memberConfiguration_name = (MemberConfiguration -> Text)
-> (MemberConfiguration -> Text -> MemberConfiguration)
-> Lens MemberConfiguration MemberConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {Text
name :: Text
$sel:name:MemberConfiguration' :: MemberConfiguration -> Text
name} -> Text
name) (\s :: MemberConfiguration
s@MemberConfiguration' {} Text
a -> MemberConfiguration
s {$sel:name:MemberConfiguration' :: Text
name = Text
a} :: MemberConfiguration)

-- | Configuration properties of the blockchain framework relevant to the
-- member.
memberConfiguration_frameworkConfiguration :: Lens.Lens' MemberConfiguration MemberFrameworkConfiguration
memberConfiguration_frameworkConfiguration :: (MemberFrameworkConfiguration -> f MemberFrameworkConfiguration)
-> MemberConfiguration -> f MemberConfiguration
memberConfiguration_frameworkConfiguration = (MemberConfiguration -> MemberFrameworkConfiguration)
-> (MemberConfiguration
    -> MemberFrameworkConfiguration -> MemberConfiguration)
-> Lens
     MemberConfiguration
     MemberConfiguration
     MemberFrameworkConfiguration
     MemberFrameworkConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberConfiguration' {MemberFrameworkConfiguration
frameworkConfiguration :: MemberFrameworkConfiguration
$sel:frameworkConfiguration:MemberConfiguration' :: MemberConfiguration -> MemberFrameworkConfiguration
frameworkConfiguration} -> MemberFrameworkConfiguration
frameworkConfiguration) (\s :: MemberConfiguration
s@MemberConfiguration' {} MemberFrameworkConfiguration
a -> MemberConfiguration
s {$sel:frameworkConfiguration:MemberConfiguration' :: MemberFrameworkConfiguration
frameworkConfiguration = MemberFrameworkConfiguration
a} :: MemberConfiguration)

instance Prelude.Hashable MemberConfiguration

instance Prelude.NFData MemberConfiguration

instance Core.ToJSON MemberConfiguration where
  toJSON :: MemberConfiguration -> Value
toJSON MemberConfiguration' {Maybe Text
Maybe (HashMap Text Text)
Maybe MemberLogPublishingConfiguration
Text
MemberFrameworkConfiguration
frameworkConfiguration :: MemberFrameworkConfiguration
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
logPublishingConfiguration :: Maybe MemberLogPublishingConfiguration
kmsKeyArn :: Maybe Text
$sel:frameworkConfiguration:MemberConfiguration' :: MemberConfiguration -> MemberFrameworkConfiguration
$sel:name:MemberConfiguration' :: MemberConfiguration -> Text
$sel:tags:MemberConfiguration' :: MemberConfiguration -> Maybe (HashMap Text Text)
$sel:description:MemberConfiguration' :: MemberConfiguration -> Maybe Text
$sel:logPublishingConfiguration:MemberConfiguration' :: MemberConfiguration -> Maybe MemberLogPublishingConfiguration
$sel:kmsKeyArn:MemberConfiguration' :: MemberConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KmsKeyArn" 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
kmsKeyArn,
            (Text
"LogPublishingConfiguration" Text -> MemberLogPublishingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MemberLogPublishingConfiguration -> Pair)
-> Maybe MemberLogPublishingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MemberLogPublishingConfiguration
logPublishingConfiguration,
            (Text
"Description" 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
description,
            (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"FrameworkConfiguration"
                  Text -> MemberFrameworkConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MemberFrameworkConfiguration
frameworkConfiguration
              )
          ]
      )