{-# 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-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.MemberConfiguration 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.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'
  { -- | An optional description of the member.
    MemberConfiguration -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the customer managed key in Key
    -- Management Service (KMS) to use for encryption at rest in the member.
    -- This parameter is inherited by any nodes that this member creates. For
    -- more information, see
    -- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/managed-blockchain-encryption-at-rest.html Encryption at Rest>
    -- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
    --
    -- Use one of the following options to specify this parameter:
    --
    -- -   __Undefined or empty string__ - By default, use an KMS key that is
    --     owned and managed by Amazon Web Services on your behalf.
    --
    -- -   __A valid symmetric customer managed KMS key__ - Use the specified
    --     KMS key in your account that you create, own, and manage.
    --
    --     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 /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,
    -- | 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
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
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. 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:
--
-- 'description', 'memberConfiguration_description' - An optional description of the member.
--
-- 'kmsKeyArn', 'memberConfiguration_kmsKeyArn' - The Amazon Resource Name (ARN) of the customer managed key in Key
-- Management Service (KMS) to use for encryption at rest in the member.
-- This parameter is inherited by any nodes that this member creates. For
-- more information, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/managed-blockchain-encryption-at-rest.html Encryption at Rest>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
--
-- Use one of the following options to specify this parameter:
--
-- -   __Undefined or empty string__ - By default, use an KMS key that is
--     owned and managed by Amazon Web Services on your behalf.
--
-- -   __A valid symmetric customer managed KMS key__ - Use the specified
--     KMS key in your account that you create, own, and manage.
--
--     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 /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.
--
-- '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'
      { $sel:description:MemberConfiguration' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:kmsKeyArn:MemberConfiguration' :: Maybe Text
kmsKeyArn = forall a. Maybe a
Prelude.Nothing,
        $sel:logPublishingConfiguration:MemberConfiguration' :: Maybe MemberLogPublishingConfiguration
logPublishingConfiguration = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:MemberConfiguration' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:name:MemberConfiguration' :: Text
name = Text
pName_,
        $sel:frameworkConfiguration:MemberConfiguration' :: MemberFrameworkConfiguration
frameworkConfiguration = MemberFrameworkConfiguration
pFrameworkConfiguration_
      }

-- | An optional description of the member.
memberConfiguration_description :: Lens.Lens' MemberConfiguration (Prelude.Maybe Prelude.Text)
memberConfiguration_description :: Lens' MemberConfiguration (Maybe Text)
memberConfiguration_description = 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)

-- | The Amazon Resource Name (ARN) of the customer managed key in Key
-- Management Service (KMS) to use for encryption at rest in the member.
-- This parameter is inherited by any nodes that this member creates. For
-- more information, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/managed-blockchain-encryption-at-rest.html Encryption at Rest>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
--
-- Use one of the following options to specify this parameter:
--
-- -   __Undefined or empty string__ - By default, use an KMS key that is
--     owned and managed by Amazon Web Services on your behalf.
--
-- -   __A valid symmetric customer managed KMS key__ - Use the specified
--     KMS key in your account that you create, own, and manage.
--
--     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 /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 :: Lens' MemberConfiguration (Maybe Text)
memberConfiguration_kmsKeyArn = 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 :: Lens' MemberConfiguration (Maybe MemberLogPublishingConfiguration)
memberConfiguration_logPublishingConfiguration = 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)

-- | 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 :: Lens' MemberConfiguration (Maybe (HashMap Text Text))
memberConfiguration_tags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' MemberConfiguration Text
memberConfiguration_name = 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 :: Lens' MemberConfiguration MemberFrameworkConfiguration
memberConfiguration_frameworkConfiguration = 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 where
  hashWithSalt :: Int -> MemberConfiguration -> Int
hashWithSalt Int
_salt MemberConfiguration' {Maybe Text
Maybe (HashMap Text Text)
Maybe MemberLogPublishingConfiguration
Text
MemberFrameworkConfiguration
frameworkConfiguration :: MemberFrameworkConfiguration
name :: Text
tags :: Maybe (HashMap Text Text)
logPublishingConfiguration :: Maybe MemberLogPublishingConfiguration
kmsKeyArn :: Maybe Text
description :: Maybe Text
$sel:frameworkConfiguration:MemberConfiguration' :: MemberConfiguration -> MemberFrameworkConfiguration
$sel:name:MemberConfiguration' :: MemberConfiguration -> Text
$sel:tags:MemberConfiguration' :: MemberConfiguration -> Maybe (HashMap Text Text)
$sel:logPublishingConfiguration:MemberConfiguration' :: MemberConfiguration -> Maybe MemberLogPublishingConfiguration
$sel:kmsKeyArn:MemberConfiguration' :: MemberConfiguration -> Maybe Text
$sel:description:MemberConfiguration' :: MemberConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MemberLogPublishingConfiguration
logPublishingConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MemberFrameworkConfiguration
frameworkConfiguration

instance Prelude.NFData MemberConfiguration where
  rnf :: MemberConfiguration -> ()
rnf MemberConfiguration' {Maybe Text
Maybe (HashMap Text Text)
Maybe MemberLogPublishingConfiguration
Text
MemberFrameworkConfiguration
frameworkConfiguration :: MemberFrameworkConfiguration
name :: Text
tags :: Maybe (HashMap Text Text)
logPublishingConfiguration :: Maybe MemberLogPublishingConfiguration
kmsKeyArn :: Maybe Text
description :: Maybe Text
$sel:frameworkConfiguration:MemberConfiguration' :: MemberConfiguration -> MemberFrameworkConfiguration
$sel:name:MemberConfiguration' :: MemberConfiguration -> Text
$sel:tags:MemberConfiguration' :: MemberConfiguration -> Maybe (HashMap Text Text)
$sel:logPublishingConfiguration:MemberConfiguration' :: MemberConfiguration -> Maybe MemberLogPublishingConfiguration
$sel:kmsKeyArn:MemberConfiguration' :: MemberConfiguration -> Maybe Text
$sel:description:MemberConfiguration' :: MemberConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MemberLogPublishingConfiguration
logPublishingConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MemberFrameworkConfiguration
frameworkConfiguration

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