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

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

-- | An action to invite a specific AWS account to create a member and join
-- the network. The @InviteAction@ is carried out when a @Proposal@ is
-- @APPROVED@.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newInviteAction' smart constructor.
data InviteAction = InviteAction'
  { -- | The AWS account ID to invite.
    InviteAction -> Text
principal :: Prelude.Text
  }
  deriving (InviteAction -> InviteAction -> Bool
(InviteAction -> InviteAction -> Bool)
-> (InviteAction -> InviteAction -> Bool) -> Eq InviteAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InviteAction -> InviteAction -> Bool
$c/= :: InviteAction -> InviteAction -> Bool
== :: InviteAction -> InviteAction -> Bool
$c== :: InviteAction -> InviteAction -> Bool
Prelude.Eq, ReadPrec [InviteAction]
ReadPrec InviteAction
Int -> ReadS InviteAction
ReadS [InviteAction]
(Int -> ReadS InviteAction)
-> ReadS [InviteAction]
-> ReadPrec InviteAction
-> ReadPrec [InviteAction]
-> Read InviteAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InviteAction]
$creadListPrec :: ReadPrec [InviteAction]
readPrec :: ReadPrec InviteAction
$creadPrec :: ReadPrec InviteAction
readList :: ReadS [InviteAction]
$creadList :: ReadS [InviteAction]
readsPrec :: Int -> ReadS InviteAction
$creadsPrec :: Int -> ReadS InviteAction
Prelude.Read, Int -> InviteAction -> ShowS
[InviteAction] -> ShowS
InviteAction -> String
(Int -> InviteAction -> ShowS)
-> (InviteAction -> String)
-> ([InviteAction] -> ShowS)
-> Show InviteAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InviteAction] -> ShowS
$cshowList :: [InviteAction] -> ShowS
show :: InviteAction -> String
$cshow :: InviteAction -> String
showsPrec :: Int -> InviteAction -> ShowS
$cshowsPrec :: Int -> InviteAction -> ShowS
Prelude.Show, (forall x. InviteAction -> Rep InviteAction x)
-> (forall x. Rep InviteAction x -> InviteAction)
-> Generic InviteAction
forall x. Rep InviteAction x -> InviteAction
forall x. InviteAction -> Rep InviteAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InviteAction x -> InviteAction
$cfrom :: forall x. InviteAction -> Rep InviteAction x
Prelude.Generic)

-- |
-- Create a value of 'InviteAction' 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:
--
-- 'principal', 'inviteAction_principal' - The AWS account ID to invite.
newInviteAction ::
  -- | 'principal'
  Prelude.Text ->
  InviteAction
newInviteAction :: Text -> InviteAction
newInviteAction Text
pPrincipal_ =
  InviteAction' :: Text -> InviteAction
InviteAction' {$sel:principal:InviteAction' :: Text
principal = Text
pPrincipal_}

-- | The AWS account ID to invite.
inviteAction_principal :: Lens.Lens' InviteAction Prelude.Text
inviteAction_principal :: (Text -> f Text) -> InviteAction -> f InviteAction
inviteAction_principal = (InviteAction -> Text)
-> (InviteAction -> Text -> InviteAction)
-> Lens InviteAction InviteAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InviteAction' {Text
principal :: Text
$sel:principal:InviteAction' :: InviteAction -> Text
principal} -> Text
principal) (\s :: InviteAction
s@InviteAction' {} Text
a -> InviteAction
s {$sel:principal:InviteAction' :: Text
principal = Text
a} :: InviteAction)

instance Core.FromJSON InviteAction where
  parseJSON :: Value -> Parser InviteAction
parseJSON =
    String
-> (Object -> Parser InviteAction) -> Value -> Parser InviteAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InviteAction"
      ( \Object
x ->
          Text -> InviteAction
InviteAction' (Text -> InviteAction) -> Parser Text -> Parser InviteAction
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
"Principal")
      )

instance Prelude.Hashable InviteAction

instance Prelude.NFData InviteAction

instance Core.ToJSON InviteAction where
  toJSON :: InviteAction -> Value
toJSON InviteAction' {Text
principal :: Text
$sel:principal:InviteAction' :: InviteAction -> 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
"Principal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
principal)]
      )