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

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

-- | Contains information about the administrator account and invitation.
--
-- /See:/ 'newMaster' smart constructor.
data Master = Master'
  { -- | The timestamp when the invitation was sent.
    Master -> Maybe Text
invitedAt :: Prelude.Maybe Prelude.Text,
    -- | The status of the relationship between the administrator and member
    -- accounts.
    Master -> Maybe Text
relationshipStatus :: Prelude.Maybe Prelude.Text,
    -- | The value used to validate the administrator account to the member
    -- account.
    Master -> Maybe Text
invitationId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the account used as the administrator account.
    Master -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  deriving (Master -> Master -> Bool
(Master -> Master -> Bool)
-> (Master -> Master -> Bool) -> Eq Master
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Master -> Master -> Bool
$c/= :: Master -> Master -> Bool
== :: Master -> Master -> Bool
$c== :: Master -> Master -> Bool
Prelude.Eq, ReadPrec [Master]
ReadPrec Master
Int -> ReadS Master
ReadS [Master]
(Int -> ReadS Master)
-> ReadS [Master]
-> ReadPrec Master
-> ReadPrec [Master]
-> Read Master
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Master]
$creadListPrec :: ReadPrec [Master]
readPrec :: ReadPrec Master
$creadPrec :: ReadPrec Master
readList :: ReadS [Master]
$creadList :: ReadS [Master]
readsPrec :: Int -> ReadS Master
$creadsPrec :: Int -> ReadS Master
Prelude.Read, Int -> Master -> ShowS
[Master] -> ShowS
Master -> String
(Int -> Master -> ShowS)
-> (Master -> String) -> ([Master] -> ShowS) -> Show Master
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Master] -> ShowS
$cshowList :: [Master] -> ShowS
show :: Master -> String
$cshow :: Master -> String
showsPrec :: Int -> Master -> ShowS
$cshowsPrec :: Int -> Master -> ShowS
Prelude.Show, (forall x. Master -> Rep Master x)
-> (forall x. Rep Master x -> Master) -> Generic Master
forall x. Rep Master x -> Master
forall x. Master -> Rep Master x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Master x -> Master
$cfrom :: forall x. Master -> Rep Master x
Prelude.Generic)

-- |
-- Create a value of 'Master' 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', 'master_invitedAt' - The timestamp when the invitation was sent.
--
-- 'relationshipStatus', 'master_relationshipStatus' - The status of the relationship between the administrator and member
-- accounts.
--
-- 'invitationId', 'master_invitationId' - The value used to validate the administrator account to the member
-- account.
--
-- 'accountId', 'master_accountId' - The ID of the account used as the administrator account.
newMaster ::
  Master
newMaster :: Master
newMaster =
  Master' :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Master
Master'
    { $sel:invitedAt:Master' :: Maybe Text
invitedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relationshipStatus:Master' :: Maybe Text
relationshipStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:invitationId:Master' :: Maybe Text
invitationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:Master' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp when the invitation was sent.
master_invitedAt :: Lens.Lens' Master (Prelude.Maybe Prelude.Text)
master_invitedAt :: (Maybe Text -> f (Maybe Text)) -> Master -> f Master
master_invitedAt = (Master -> Maybe Text)
-> (Master -> Maybe Text -> Master)
-> Lens Master Master (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Master' {Maybe Text
invitedAt :: Maybe Text
$sel:invitedAt:Master' :: Master -> Maybe Text
invitedAt} -> Maybe Text
invitedAt) (\s :: Master
s@Master' {} Maybe Text
a -> Master
s {$sel:invitedAt:Master' :: Maybe Text
invitedAt = Maybe Text
a} :: Master)

-- | The status of the relationship between the administrator and member
-- accounts.
master_relationshipStatus :: Lens.Lens' Master (Prelude.Maybe Prelude.Text)
master_relationshipStatus :: (Maybe Text -> f (Maybe Text)) -> Master -> f Master
master_relationshipStatus = (Master -> Maybe Text)
-> (Master -> Maybe Text -> Master)
-> Lens Master Master (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Master' {Maybe Text
relationshipStatus :: Maybe Text
$sel:relationshipStatus:Master' :: Master -> Maybe Text
relationshipStatus} -> Maybe Text
relationshipStatus) (\s :: Master
s@Master' {} Maybe Text
a -> Master
s {$sel:relationshipStatus:Master' :: Maybe Text
relationshipStatus = Maybe Text
a} :: Master)

-- | The value used to validate the administrator account to the member
-- account.
master_invitationId :: Lens.Lens' Master (Prelude.Maybe Prelude.Text)
master_invitationId :: (Maybe Text -> f (Maybe Text)) -> Master -> f Master
master_invitationId = (Master -> Maybe Text)
-> (Master -> Maybe Text -> Master)
-> Lens Master Master (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Master' {Maybe Text
invitationId :: Maybe Text
$sel:invitationId:Master' :: Master -> Maybe Text
invitationId} -> Maybe Text
invitationId) (\s :: Master
s@Master' {} Maybe Text
a -> Master
s {$sel:invitationId:Master' :: Maybe Text
invitationId = Maybe Text
a} :: Master)

-- | The ID of the account used as the administrator account.
master_accountId :: Lens.Lens' Master (Prelude.Maybe Prelude.Text)
master_accountId :: (Maybe Text -> f (Maybe Text)) -> Master -> f Master
master_accountId = (Master -> Maybe Text)
-> (Master -> Maybe Text -> Master)
-> Lens Master Master (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Master' {Maybe Text
accountId :: Maybe Text
$sel:accountId:Master' :: Master -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: Master
s@Master' {} Maybe Text
a -> Master
s {$sel:accountId:Master' :: Maybe Text
accountId = Maybe Text
a} :: Master)

instance Core.FromJSON Master where
  parseJSON :: Value -> Parser Master
parseJSON =
    String -> (Object -> Parser Master) -> Value -> Parser Master
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Master"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Master
Master'
            (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Master)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Master)
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 -> Master)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Master)
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 -> Master)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Master)
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 -> Master)
-> Parser (Maybe Text) -> Parser Master
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 Master

instance Prelude.NFData Master