{-# 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-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.Invitation 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.InvitationStatus
import Amazonka.ManagedBlockChain.Types.NetworkSummary
import qualified Amazonka.Prelude as Prelude

-- | An invitation to an Amazon Web Services account to create a member and
-- join the network.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newInvitation' smart constructor.
data Invitation = 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 /Amazon Web Services General Reference/.
    Invitation -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the invitation was created.
    Invitation -> Maybe ISO8601
creationDate :: Prelude.Maybe Data.ISO8601,
    -- | 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 ISO8601
expirationDate :: Prelude.Maybe Data.ISO8601,
    -- | The unique identifier for the invitation.
    Invitation -> Maybe Text
invitationId :: Prelude.Maybe Prelude.Text,
    Invitation -> Maybe NetworkSummary
networkSummary :: Prelude.Maybe NetworkSummary,
    -- | The status of the invitation:
    --
    -- -   @PENDING@ - The invitee hasn\'t created a member to join the
    --     network, and the invitation hasn\'t yet expired.
    --
    -- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
    --     hasn\'t 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
  }
  deriving (Invitation -> Invitation -> Bool
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]
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
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. 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:
--
-- '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 /Amazon Web Services General Reference/.
--
-- 'creationDate', 'invitation_creationDate' - The date and time that the invitation was created.
--
-- '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@.
--
-- 'invitationId', 'invitation_invitationId' - The unique identifier for the invitation.
--
-- 'networkSummary', 'invitation_networkSummary' - Undocumented member.
--
-- 'status', 'invitation_status' - The status of the invitation:
--
-- -   @PENDING@ - The invitee hasn\'t created a member to join the
--     network, and the invitation hasn\'t yet expired.
--
-- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
--     hasn\'t 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@.
newInvitation ::
  Invitation
newInvitation :: Invitation
newInvitation =
  Invitation'
    { $sel:arn:Invitation' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:Invitation' :: Maybe ISO8601
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:Invitation' :: Maybe ISO8601
expirationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:invitationId:Invitation' :: Maybe Text
invitationId = forall a. Maybe a
Prelude.Nothing,
      $sel:networkSummary:Invitation' :: Maybe NetworkSummary
networkSummary = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Invitation' :: Maybe InvitationStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 /Amazon Web Services General Reference/.
invitation_arn :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_arn :: Lens' Invitation (Maybe Text)
invitation_arn = 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 date and time that the invitation was created.
invitation_creationDate :: Lens.Lens' Invitation (Prelude.Maybe Prelude.UTCTime)
invitation_creationDate :: Lens' Invitation (Maybe UTCTime)
invitation_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe ISO8601
creationDate :: Maybe ISO8601
$sel:creationDate:Invitation' :: Invitation -> Maybe ISO8601
creationDate} -> Maybe ISO8601
creationDate) (\s :: Invitation
s@Invitation' {} Maybe ISO8601
a -> Invitation
s {$sel:creationDate:Invitation' :: Maybe ISO8601
creationDate = Maybe ISO8601
a} :: Invitation) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' Invitation (Maybe UTCTime)
invitation_expirationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe ISO8601
expirationDate :: Maybe ISO8601
$sel:expirationDate:Invitation' :: Invitation -> Maybe ISO8601
expirationDate} -> Maybe ISO8601
expirationDate) (\s :: Invitation
s@Invitation' {} Maybe ISO8601
a -> Invitation
s {$sel:expirationDate:Invitation' :: Maybe ISO8601
expirationDate = Maybe ISO8601
a} :: Invitation) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The unique identifier for the invitation.
invitation_invitationId :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_invitationId :: Lens' Invitation (Maybe Text)
invitation_invitationId = 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)

-- | Undocumented member.
invitation_networkSummary :: Lens.Lens' Invitation (Prelude.Maybe NetworkSummary)
invitation_networkSummary :: Lens' Invitation (Maybe NetworkSummary)
invitation_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 status of the invitation:
--
-- -   @PENDING@ - The invitee hasn\'t created a member to join the
--     network, and the invitation hasn\'t yet expired.
--
-- -   @ACCEPTING@ - The invitee has begun creating a member, and creation
--     hasn\'t 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 :: Lens' Invitation (Maybe InvitationStatus)
invitation_status = 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)

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

instance Prelude.Hashable Invitation where
  hashWithSalt :: Int -> Invitation -> Int
hashWithSalt Int
_salt Invitation' {Maybe Text
Maybe ISO8601
Maybe InvitationStatus
Maybe NetworkSummary
status :: Maybe InvitationStatus
networkSummary :: Maybe NetworkSummary
invitationId :: Maybe Text
expirationDate :: Maybe ISO8601
creationDate :: Maybe ISO8601
arn :: Maybe Text
$sel:status:Invitation' :: Invitation -> Maybe InvitationStatus
$sel:networkSummary:Invitation' :: Invitation -> Maybe NetworkSummary
$sel:invitationId:Invitation' :: Invitation -> Maybe Text
$sel:expirationDate:Invitation' :: Invitation -> Maybe ISO8601
$sel:creationDate:Invitation' :: Invitation -> Maybe ISO8601
$sel:arn:Invitation' :: Invitation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
expirationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
invitationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkSummary
networkSummary
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InvitationStatus
status

instance Prelude.NFData Invitation where
  rnf :: Invitation -> ()
rnf Invitation' {Maybe Text
Maybe ISO8601
Maybe InvitationStatus
Maybe NetworkSummary
status :: Maybe InvitationStatus
networkSummary :: Maybe NetworkSummary
invitationId :: Maybe Text
expirationDate :: Maybe ISO8601
creationDate :: Maybe ISO8601
arn :: Maybe Text
$sel:status:Invitation' :: Invitation -> Maybe InvitationStatus
$sel:networkSummary:Invitation' :: Invitation -> Maybe NetworkSummary
$sel:invitationId:Invitation' :: Invitation -> Maybe Text
$sel:expirationDate:Invitation' :: Invitation -> Maybe ISO8601
$sel:creationDate:Invitation' :: Invitation -> Maybe ISO8601
$sel:arn:Invitation' :: Invitation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
expirationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
invitationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkSummary
networkSummary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InvitationStatus
status