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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An action to remove a member from a Managed Blockchain network as the
-- result of a removal proposal that is @APPROVED@. The member and all
-- associated resources are deleted from the network.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newRemoveAction' smart constructor.
data RemoveAction = RemoveAction'
  { -- | The unique identifier of the member to remove.
    RemoveAction -> Text
memberId :: Prelude.Text
  }
  deriving (RemoveAction -> RemoveAction -> Bool
(RemoveAction -> RemoveAction -> Bool)
-> (RemoveAction -> RemoveAction -> Bool) -> Eq RemoveAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveAction -> RemoveAction -> Bool
$c/= :: RemoveAction -> RemoveAction -> Bool
== :: RemoveAction -> RemoveAction -> Bool
$c== :: RemoveAction -> RemoveAction -> Bool
Prelude.Eq, ReadPrec [RemoveAction]
ReadPrec RemoveAction
Int -> ReadS RemoveAction
ReadS [RemoveAction]
(Int -> ReadS RemoveAction)
-> ReadS [RemoveAction]
-> ReadPrec RemoveAction
-> ReadPrec [RemoveAction]
-> Read RemoveAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveAction]
$creadListPrec :: ReadPrec [RemoveAction]
readPrec :: ReadPrec RemoveAction
$creadPrec :: ReadPrec RemoveAction
readList :: ReadS [RemoveAction]
$creadList :: ReadS [RemoveAction]
readsPrec :: Int -> ReadS RemoveAction
$creadsPrec :: Int -> ReadS RemoveAction
Prelude.Read, Int -> RemoveAction -> ShowS
[RemoveAction] -> ShowS
RemoveAction -> String
(Int -> RemoveAction -> ShowS)
-> (RemoveAction -> String)
-> ([RemoveAction] -> ShowS)
-> Show RemoveAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveAction] -> ShowS
$cshowList :: [RemoveAction] -> ShowS
show :: RemoveAction -> String
$cshow :: RemoveAction -> String
showsPrec :: Int -> RemoveAction -> ShowS
$cshowsPrec :: Int -> RemoveAction -> ShowS
Prelude.Show, (forall x. RemoveAction -> Rep RemoveAction x)
-> (forall x. Rep RemoveAction x -> RemoveAction)
-> Generic RemoveAction
forall x. Rep RemoveAction x -> RemoveAction
forall x. RemoveAction -> Rep RemoveAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveAction x -> RemoveAction
$cfrom :: forall x. RemoveAction -> Rep RemoveAction x
Prelude.Generic)

-- |
-- Create a value of 'RemoveAction' 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:
--
-- 'memberId', 'removeAction_memberId' - The unique identifier of the member to remove.
newRemoveAction ::
  -- | 'memberId'
  Prelude.Text ->
  RemoveAction
newRemoveAction :: Text -> RemoveAction
newRemoveAction Text
pMemberId_ =
  RemoveAction' :: Text -> RemoveAction
RemoveAction' {$sel:memberId:RemoveAction' :: Text
memberId = Text
pMemberId_}

-- | The unique identifier of the member to remove.
removeAction_memberId :: Lens.Lens' RemoveAction Prelude.Text
removeAction_memberId :: (Text -> f Text) -> RemoveAction -> f RemoveAction
removeAction_memberId = (RemoveAction -> Text)
-> (RemoveAction -> Text -> RemoveAction)
-> Lens RemoveAction RemoveAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAction' {Text
memberId :: Text
$sel:memberId:RemoveAction' :: RemoveAction -> Text
memberId} -> Text
memberId) (\s :: RemoveAction
s@RemoveAction' {} Text
a -> RemoveAction
s {$sel:memberId:RemoveAction' :: Text
memberId = Text
a} :: RemoveAction)

instance Core.FromJSON RemoveAction where
  parseJSON :: Value -> Parser RemoveAction
parseJSON =
    String
-> (Object -> Parser RemoveAction) -> Value -> Parser RemoveAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemoveAction"
      ( \Object
x ->
          Text -> RemoveAction
RemoveAction' (Text -> RemoveAction) -> Parser Text -> Parser RemoveAction
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MemberId")
      )

instance Prelude.Hashable RemoveAction

instance Prelude.NFData RemoveAction

instance Core.ToJSON RemoveAction where
  toJSON :: RemoveAction -> Value
toJSON RemoveAction' {Text
memberId :: Text
$sel:memberId:RemoveAction' :: RemoveAction -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MemberId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
memberId)]
      )