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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.ManagedBlockChain.Types.InvitationStatus
import Amazonka.ManagedBlockChain.Types.NetworkSummary
import qualified Amazonka.Prelude as Prelude

-- | An invitation to an AWS account to create a member and join the network.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newInvitation' smart constructor.
data Invitation = Invitation'
  { -- | The status of the invitation:
    --
    -- -   @PENDING@ - The invitee has not created a member to join the
    --     network, and the invitation has not yet expired.
    --
    -- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
    --     has not yet completed.
    --
    -- -   @ACCEPTED@ - The invitee created a member and joined the network
    --     using the @InvitationID@.
    --
    -- -   @REJECTED@ - The invitee rejected the invitation.
    --
    -- -   @EXPIRED@ - The invitee neither created a member nor rejected the
    --     invitation before the @ExpirationDate@.
    Invitation -> Maybe InvitationStatus
status :: Prelude.Maybe InvitationStatus,
    -- | The Amazon Resource Name (ARN) of the invitation. For more information
    -- about ARNs and their format, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /AWS General Reference/.
    Invitation -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the invitation.
    Invitation -> Maybe Text
invitationId :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the invitation expires. This is the
    -- @CreationDate@ plus the @ProposalDurationInHours@ that is specified in
    -- the @ProposalThresholdPolicy@. After this date and time, the invitee can
    -- no longer create a member and join the network using this
    -- @InvitationId@.
    Invitation -> Maybe POSIX
expirationDate :: Prelude.Maybe Core.POSIX,
    Invitation -> Maybe NetworkSummary
networkSummary :: Prelude.Maybe NetworkSummary,
    -- | The date and time that the invitation was created.
    Invitation -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX
  }
  deriving (Invitation -> Invitation -> Bool
(Invitation -> Invitation -> Bool)
-> (Invitation -> Invitation -> Bool) -> Eq Invitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Invitation -> Invitation -> Bool
$c/= :: Invitation -> Invitation -> Bool
== :: Invitation -> Invitation -> Bool
$c== :: Invitation -> Invitation -> Bool
Prelude.Eq, ReadPrec [Invitation]
ReadPrec Invitation
Int -> ReadS Invitation
ReadS [Invitation]
(Int -> ReadS Invitation)
-> ReadS [Invitation]
-> ReadPrec Invitation
-> ReadPrec [Invitation]
-> Read Invitation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Invitation]
$creadListPrec :: ReadPrec [Invitation]
readPrec :: ReadPrec Invitation
$creadPrec :: ReadPrec Invitation
readList :: ReadS [Invitation]
$creadList :: ReadS [Invitation]
readsPrec :: Int -> ReadS Invitation
$creadsPrec :: Int -> ReadS Invitation
Prelude.Read, Int -> Invitation -> ShowS
[Invitation] -> ShowS
Invitation -> String
(Int -> Invitation -> ShowS)
-> (Invitation -> String)
-> ([Invitation] -> ShowS)
-> Show Invitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Invitation] -> ShowS
$cshowList :: [Invitation] -> ShowS
show :: Invitation -> String
$cshow :: Invitation -> String
showsPrec :: Int -> Invitation -> ShowS
$cshowsPrec :: Int -> Invitation -> ShowS
Prelude.Show, (forall x. Invitation -> Rep Invitation x)
-> (forall x. Rep Invitation x -> Invitation) -> Generic Invitation
forall x. Rep Invitation x -> Invitation
forall x. Invitation -> Rep Invitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Invitation x -> Invitation
$cfrom :: forall x. Invitation -> Rep Invitation x
Prelude.Generic)

-- |
-- Create a value of 'Invitation' 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:
--
-- 'status', 'invitation_status' - The status of the invitation:
--
-- -   @PENDING@ - The invitee has not created a member to join the
--     network, and the invitation has not yet expired.
--
-- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
--     has not yet completed.
--
-- -   @ACCEPTED@ - The invitee created a member and joined the network
--     using the @InvitationID@.
--
-- -   @REJECTED@ - The invitee rejected the invitation.
--
-- -   @EXPIRED@ - The invitee neither created a member nor rejected the
--     invitation before the @ExpirationDate@.
--
-- 'arn', 'invitation_arn' - The Amazon Resource Name (ARN) of the invitation. For more information
-- about ARNs and their format, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
--
-- 'invitationId', 'invitation_invitationId' - The unique identifier for the invitation.
--
-- 'expirationDate', 'invitation_expirationDate' - The date and time that the invitation expires. This is the
-- @CreationDate@ plus the @ProposalDurationInHours@ that is specified in
-- the @ProposalThresholdPolicy@. After this date and time, the invitee can
-- no longer create a member and join the network using this
-- @InvitationId@.
--
-- 'networkSummary', 'invitation_networkSummary' - Undocumented member.
--
-- 'creationDate', 'invitation_creationDate' - The date and time that the invitation was created.
newInvitation ::
  Invitation
newInvitation :: Invitation
newInvitation =
  Invitation' :: Maybe InvitationStatus
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe NetworkSummary
-> Maybe POSIX
-> Invitation
Invitation'
    { $sel:status:Invitation' :: Maybe InvitationStatus
status = Maybe InvitationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Invitation' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:invitationId:Invitation' :: Maybe Text
invitationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:Invitation' :: Maybe POSIX
expirationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:networkSummary:Invitation' :: Maybe NetworkSummary
networkSummary = Maybe NetworkSummary
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:Invitation' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the invitation:
--
-- -   @PENDING@ - The invitee has not created a member to join the
--     network, and the invitation has not yet expired.
--
-- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
--     has not yet completed.
--
-- -   @ACCEPTED@ - The invitee created a member and joined the network
--     using the @InvitationID@.
--
-- -   @REJECTED@ - The invitee rejected the invitation.
--
-- -   @EXPIRED@ - The invitee neither created a member nor rejected the
--     invitation before the @ExpirationDate@.
invitation_status :: Lens.Lens' Invitation (Prelude.Maybe InvitationStatus)
invitation_status :: (Maybe InvitationStatus -> f (Maybe InvitationStatus))
-> Invitation -> f Invitation
invitation_status = (Invitation -> Maybe InvitationStatus)
-> (Invitation -> Maybe InvitationStatus -> Invitation)
-> Lens
     Invitation
     Invitation
     (Maybe InvitationStatus)
     (Maybe InvitationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe InvitationStatus
status :: Maybe InvitationStatus
$sel:status:Invitation' :: Invitation -> Maybe InvitationStatus
status} -> Maybe InvitationStatus
status) (\s :: Invitation
s@Invitation' {} Maybe InvitationStatus
a -> Invitation
s {$sel:status:Invitation' :: Maybe InvitationStatus
status = Maybe InvitationStatus
a} :: Invitation)

-- | The Amazon Resource Name (ARN) of the invitation. For more information
-- about ARNs and their format, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
invitation_arn :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_arn :: (Maybe Text -> f (Maybe Text)) -> Invitation -> f Invitation
invitation_arn = (Invitation -> Maybe Text)
-> (Invitation -> Maybe Text -> Invitation)
-> Lens Invitation Invitation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe Text
arn :: Maybe Text
$sel:arn:Invitation' :: Invitation -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Invitation
s@Invitation' {} Maybe Text
a -> Invitation
s {$sel:arn:Invitation' :: Maybe Text
arn = Maybe Text
a} :: Invitation)

-- | The unique identifier for the invitation.
invitation_invitationId :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_invitationId :: (Maybe Text -> f (Maybe Text)) -> Invitation -> f Invitation
invitation_invitationId = (Invitation -> Maybe Text)
-> (Invitation -> Maybe Text -> Invitation)
-> Lens Invitation Invitation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe Text
invitationId :: Maybe Text
$sel:invitationId:Invitation' :: Invitation -> Maybe Text
invitationId} -> Maybe Text
invitationId) (\s :: Invitation
s@Invitation' {} Maybe Text
a -> Invitation
s {$sel:invitationId:Invitation' :: Maybe Text
invitationId = Maybe Text
a} :: Invitation)

-- | The date and time that the invitation expires. This is the
-- @CreationDate@ plus the @ProposalDurationInHours@ that is specified in
-- the @ProposalThresholdPolicy@. After this date and time, the invitee can
-- no longer create a member and join the network using this
-- @InvitationId@.
invitation_expirationDate :: Lens.Lens' Invitation (Prelude.Maybe Prelude.UTCTime)
invitation_expirationDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Invitation -> f Invitation
invitation_expirationDate = (Invitation -> Maybe POSIX)
-> (Invitation -> Maybe POSIX -> Invitation)
-> Lens Invitation Invitation (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe POSIX
expirationDate :: Maybe POSIX
$sel:expirationDate:Invitation' :: Invitation -> Maybe POSIX
expirationDate} -> Maybe POSIX
expirationDate) (\s :: Invitation
s@Invitation' {} Maybe POSIX
a -> Invitation
s {$sel:expirationDate:Invitation' :: Maybe POSIX
expirationDate = Maybe POSIX
a} :: Invitation) ((Maybe POSIX -> f (Maybe POSIX)) -> Invitation -> f Invitation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Invitation
-> f Invitation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Undocumented member.
invitation_networkSummary :: Lens.Lens' Invitation (Prelude.Maybe NetworkSummary)
invitation_networkSummary :: (Maybe NetworkSummary -> f (Maybe NetworkSummary))
-> Invitation -> f Invitation
invitation_networkSummary = (Invitation -> Maybe NetworkSummary)
-> (Invitation -> Maybe NetworkSummary -> Invitation)
-> Lens
     Invitation Invitation (Maybe NetworkSummary) (Maybe NetworkSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe NetworkSummary
networkSummary :: Maybe NetworkSummary
$sel:networkSummary:Invitation' :: Invitation -> Maybe NetworkSummary
networkSummary} -> Maybe NetworkSummary
networkSummary) (\s :: Invitation
s@Invitation' {} Maybe NetworkSummary
a -> Invitation
s {$sel:networkSummary:Invitation' :: Maybe NetworkSummary
networkSummary = Maybe NetworkSummary
a} :: Invitation)

-- | The date and time that the invitation was created.
invitation_creationDate :: Lens.Lens' Invitation (Prelude.Maybe Prelude.UTCTime)
invitation_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Invitation -> f Invitation
invitation_creationDate = (Invitation -> Maybe POSIX)
-> (Invitation -> Maybe POSIX -> Invitation)
-> Lens Invitation Invitation (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:Invitation' :: Invitation -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: Invitation
s@Invitation' {} Maybe POSIX
a -> Invitation
s {$sel:creationDate:Invitation' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: Invitation) ((Maybe POSIX -> f (Maybe POSIX)) -> Invitation -> f Invitation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Invitation
-> f Invitation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Invitation where
  parseJSON :: Value -> Parser Invitation
parseJSON =
    String
-> (Object -> Parser Invitation) -> Value -> Parser Invitation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Invitation"
      ( \Object
x ->
          Maybe InvitationStatus
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe NetworkSummary
-> Maybe POSIX
-> Invitation
Invitation'
            (Maybe InvitationStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe NetworkSummary
 -> Maybe POSIX
 -> Invitation)
-> Parser (Maybe InvitationStatus)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe NetworkSummary
      -> Maybe POSIX
      -> Invitation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InvitationStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe NetworkSummary
   -> Maybe POSIX
   -> Invitation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe NetworkSummary
      -> Maybe POSIX
      -> Invitation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Arn")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe NetworkSummary
   -> Maybe POSIX
   -> Invitation)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe NetworkSummary -> Maybe POSIX -> Invitation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InvitationId")
            Parser
  (Maybe POSIX -> Maybe NetworkSummary -> Maybe POSIX -> Invitation)
-> Parser (Maybe POSIX)
-> Parser (Maybe NetworkSummary -> Maybe POSIX -> Invitation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpirationDate")
            Parser (Maybe NetworkSummary -> Maybe POSIX -> Invitation)
-> Parser (Maybe NetworkSummary)
-> Parser (Maybe POSIX -> Invitation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NetworkSummary)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NetworkSummary")
            Parser (Maybe POSIX -> Invitation)
-> Parser (Maybe POSIX) -> Parser Invitation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationDate")
      )

instance Prelude.Hashable Invitation

instance Prelude.NFData Invitation