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

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

-- | Contains information about the invitation to become a member account.
--
-- /See:/ 'newInvitation' smart constructor.
data Invitation = Invitation'
  { -- | The timestamp when the invitation was sent.
    Invitation -> Maybe Text
invitedAt :: Prelude.Maybe Prelude.Text,
    -- | The status of the relationship between the inviter and invitee accounts.
    Invitation -> Maybe Text
relationshipStatus :: Prelude.Maybe Prelude.Text,
    -- | The ID of the invitation. This value is used to validate the inviter
    -- account to the member account.
    Invitation -> Maybe Text
invitationId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the account that the invitation was sent from.
    Invitation -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  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:
--
-- 'invitedAt', 'invitation_invitedAt' - The timestamp when the invitation was sent.
--
-- 'relationshipStatus', 'invitation_relationshipStatus' - The status of the relationship between the inviter and invitee accounts.
--
-- 'invitationId', 'invitation_invitationId' - The ID of the invitation. This value is used to validate the inviter
-- account to the member account.
--
-- 'accountId', 'invitation_accountId' - The ID of the account that the invitation was sent from.
newInvitation ::
  Invitation
newInvitation :: Invitation
newInvitation =
  Invitation' :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Invitation
Invitation'
    { $sel:invitedAt:Invitation' :: Maybe Text
invitedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relationshipStatus:Invitation' :: Maybe Text
relationshipStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:invitationId:Invitation' :: Maybe Text
invitationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:Invitation' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp when the invitation was sent.
invitation_invitedAt :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_invitedAt :: (Maybe Text -> f (Maybe Text)) -> Invitation -> f Invitation
invitation_invitedAt = (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
invitedAt :: Maybe Text
$sel:invitedAt:Invitation' :: Invitation -> Maybe Text
invitedAt} -> Maybe Text
invitedAt) (\s :: Invitation
s@Invitation' {} Maybe Text
a -> Invitation
s {$sel:invitedAt:Invitation' :: Maybe Text
invitedAt = Maybe Text
a} :: Invitation)

-- | The status of the relationship between the inviter and invitee accounts.
invitation_relationshipStatus :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_relationshipStatus :: (Maybe Text -> f (Maybe Text)) -> Invitation -> f Invitation
invitation_relationshipStatus = (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
relationshipStatus :: Maybe Text
$sel:relationshipStatus:Invitation' :: Invitation -> Maybe Text
relationshipStatus} -> Maybe Text
relationshipStatus) (\s :: Invitation
s@Invitation' {} Maybe Text
a -> Invitation
s {$sel:relationshipStatus:Invitation' :: Maybe Text
relationshipStatus = Maybe Text
a} :: Invitation)

-- | The ID of the invitation. This value is used to validate the inviter
-- account to the member account.
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 ID of the account that the invitation was sent from.
invitation_accountId :: Lens.Lens' Invitation (Prelude.Maybe Prelude.Text)
invitation_accountId :: (Maybe Text -> f (Maybe Text)) -> Invitation -> f Invitation
invitation_accountId = (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
accountId :: Maybe Text
$sel:accountId:Invitation' :: Invitation -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: Invitation
s@Invitation' {} Maybe Text
a -> Invitation
s {$sel:accountId:Invitation' :: Maybe Text
accountId = Maybe Text
a} :: Invitation)

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 Text -> Maybe Text -> Maybe Text -> Maybe Text -> Invitation
Invitation'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> Invitation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Invitation)
forall (f :: * -> *) a b. Functor 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
"invitedAt")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Invitation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> 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
"relationshipStatus")
            Parser (Maybe Text -> Maybe Text -> Invitation)
-> Parser (Maybe Text) -> Parser (Maybe Text -> 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 Text -> Invitation)
-> Parser (Maybe Text) -> Parser 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
"accountId")
      )

instance Prelude.Hashable Invitation

instance Prelude.NFData Invitation