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

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

-- | An action to invite a specific Amazon Web Services 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 Amazon Web Services account ID to invite.
    InviteAction -> Text
principal :: Prelude.Text
  }
  deriving (InviteAction -> InviteAction -> Bool
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]
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
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. 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 Amazon Web Services account ID to invite.
newInviteAction ::
  -- | 'principal'
  Prelude.Text ->
  InviteAction
newInviteAction :: Text -> InviteAction
newInviteAction Text
pPrincipal_ =
  InviteAction' {$sel:principal:InviteAction' :: Text
principal = Text
pPrincipal_}

-- | The Amazon Web Services account ID to invite.
inviteAction_principal :: Lens.Lens' InviteAction Prelude.Text
inviteAction_principal :: Lens' InviteAction Text
inviteAction_principal = 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 Data.FromJSON InviteAction where
  parseJSON :: Value -> Parser InviteAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InviteAction"
      ( \Object
x ->
          Text -> InviteAction
InviteAction' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Principal")
      )

instance Prelude.Hashable InviteAction where
  hashWithSalt :: Int -> InviteAction -> Int
hashWithSalt Int
_salt InviteAction' {Text
principal :: Text
$sel:principal:InviteAction' :: InviteAction -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
principal

instance Prelude.NFData InviteAction where
  rnf :: InviteAction -> ()
rnf InviteAction' {Text
principal :: Text
$sel:principal:InviteAction' :: InviteAction -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
principal

instance Data.ToJSON InviteAction where
  toJSON :: InviteAction -> Value
toJSON InviteAction' {Text
principal :: Text
$sel:principal:InviteAction' :: InviteAction -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Principal" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
principal)]
      )