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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.RelationshipStatus
import qualified Amazonka.Prelude as Prelude

-- | Provides information about an Amazon Macie membership invitation that
-- was received by an account.
--
-- /See:/ 'newInvitation' smart constructor.
data Invitation = Invitation'
  { -- | The status of the relationship between the account that sent the
    -- invitation (/inviter account/) and the account that received the
    -- invitation (/invitee account/).
    Invitation -> Maybe RelationshipStatus
relationshipStatus :: Prelude.Maybe RelationshipStatus,
    -- | The date and time, in UTC and extended ISO 8601 format, when the
    -- invitation was sent.
    Invitation -> Maybe POSIX
invitedAt :: Prelude.Maybe Core.POSIX,
    -- | The unique identifier for the invitation. Amazon Macie uses this
    -- identifier to validate the inviter account with the invitee account.
    Invitation -> Maybe Text
invitationId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services account ID for the account that sent the
    -- invitation.
    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:
--
-- 'relationshipStatus', 'invitation_relationshipStatus' - The status of the relationship between the account that sent the
-- invitation (/inviter account/) and the account that received the
-- invitation (/invitee account/).
--
-- 'invitedAt', 'invitation_invitedAt' - The date and time, in UTC and extended ISO 8601 format, when the
-- invitation was sent.
--
-- 'invitationId', 'invitation_invitationId' - The unique identifier for the invitation. Amazon Macie uses this
-- identifier to validate the inviter account with the invitee account.
--
-- 'accountId', 'invitation_accountId' - The Amazon Web Services account ID for the account that sent the
-- invitation.
newInvitation ::
  Invitation
newInvitation :: Invitation
newInvitation =
  Invitation' :: Maybe RelationshipStatus
-> Maybe POSIX -> Maybe Text -> Maybe Text -> Invitation
Invitation'
    { $sel:relationshipStatus:Invitation' :: Maybe RelationshipStatus
relationshipStatus = Maybe RelationshipStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:invitedAt:Invitation' :: Maybe POSIX
invitedAt = Maybe POSIX
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 status of the relationship between the account that sent the
-- invitation (/inviter account/) and the account that received the
-- invitation (/invitee account/).
invitation_relationshipStatus :: Lens.Lens' Invitation (Prelude.Maybe RelationshipStatus)
invitation_relationshipStatus :: (Maybe RelationshipStatus -> f (Maybe RelationshipStatus))
-> Invitation -> f Invitation
invitation_relationshipStatus = (Invitation -> Maybe RelationshipStatus)
-> (Invitation -> Maybe RelationshipStatus -> Invitation)
-> Lens
     Invitation
     Invitation
     (Maybe RelationshipStatus)
     (Maybe RelationshipStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Invitation' {Maybe RelationshipStatus
relationshipStatus :: Maybe RelationshipStatus
$sel:relationshipStatus:Invitation' :: Invitation -> Maybe RelationshipStatus
relationshipStatus} -> Maybe RelationshipStatus
relationshipStatus) (\s :: Invitation
s@Invitation' {} Maybe RelationshipStatus
a -> Invitation
s {$sel:relationshipStatus:Invitation' :: Maybe RelationshipStatus
relationshipStatus = Maybe RelationshipStatus
a} :: Invitation)

-- | The date and time, in UTC and extended ISO 8601 format, when the
-- invitation was sent.
invitation_invitedAt :: Lens.Lens' Invitation (Prelude.Maybe Prelude.UTCTime)
invitation_invitedAt :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Invitation -> f Invitation
invitation_invitedAt = (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
invitedAt :: Maybe POSIX
$sel:invitedAt:Invitation' :: Invitation -> Maybe POSIX
invitedAt} -> Maybe POSIX
invitedAt) (\s :: Invitation
s@Invitation' {} Maybe POSIX
a -> Invitation
s {$sel:invitedAt:Invitation' :: Maybe POSIX
invitedAt = 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

-- | The unique identifier for the invitation. Amazon Macie uses this
-- identifier to validate the inviter account with the invitee 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 Amazon Web Services account ID for the account that sent the
-- invitation.
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 RelationshipStatus
-> Maybe POSIX -> Maybe Text -> Maybe Text -> Invitation
Invitation'
            (Maybe RelationshipStatus
 -> Maybe POSIX -> Maybe Text -> Maybe Text -> Invitation)
-> Parser (Maybe RelationshipStatus)
-> Parser (Maybe POSIX -> Maybe Text -> Maybe Text -> Invitation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RelationshipStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"relationshipStatus")
            Parser (Maybe POSIX -> Maybe Text -> Maybe Text -> Invitation)
-> Parser (Maybe POSIX)
-> 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 POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"invitedAt")
            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