{-# 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.Detective.Types.Account
-- 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.Detective.Types.Account where

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

-- | An AWS account that is the administrator account of or a member of a
-- behavior graph.
--
-- /See:/ 'newAccount' smart constructor.
data Account = Account'
  { -- | The account identifier of the AWS account.
    Account -> Text
accountId :: Prelude.Text,
    -- | The AWS account root user email address for the AWS account.
    Account -> Text
emailAddress :: Prelude.Text
  }
  deriving (Account -> Account -> Bool
(Account -> Account -> Bool)
-> (Account -> Account -> Bool) -> Eq Account
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Account -> Account -> Bool
$c/= :: Account -> Account -> Bool
== :: Account -> Account -> Bool
$c== :: Account -> Account -> Bool
Prelude.Eq, ReadPrec [Account]
ReadPrec Account
Int -> ReadS Account
ReadS [Account]
(Int -> ReadS Account)
-> ReadS [Account]
-> ReadPrec Account
-> ReadPrec [Account]
-> Read Account
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Account]
$creadListPrec :: ReadPrec [Account]
readPrec :: ReadPrec Account
$creadPrec :: ReadPrec Account
readList :: ReadS [Account]
$creadList :: ReadS [Account]
readsPrec :: Int -> ReadS Account
$creadsPrec :: Int -> ReadS Account
Prelude.Read, Int -> Account -> ShowS
[Account] -> ShowS
Account -> String
(Int -> Account -> ShowS)
-> (Account -> String) -> ([Account] -> ShowS) -> Show Account
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Account] -> ShowS
$cshowList :: [Account] -> ShowS
show :: Account -> String
$cshow :: Account -> String
showsPrec :: Int -> Account -> ShowS
$cshowsPrec :: Int -> Account -> ShowS
Prelude.Show, (forall x. Account -> Rep Account x)
-> (forall x. Rep Account x -> Account) -> Generic Account
forall x. Rep Account x -> Account
forall x. Account -> Rep Account x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Account x -> Account
$cfrom :: forall x. Account -> Rep Account x
Prelude.Generic)

-- |
-- Create a value of 'Account' 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:
--
-- 'accountId', 'account_accountId' - The account identifier of the AWS account.
--
-- 'emailAddress', 'account_emailAddress' - The AWS account root user email address for the AWS account.
newAccount ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'emailAddress'
  Prelude.Text ->
  Account
newAccount :: Text -> Text -> Account
newAccount Text
pAccountId_ Text
pEmailAddress_ =
  Account' :: Text -> Text -> Account
Account'
    { $sel:accountId:Account' :: Text
accountId = Text
pAccountId_,
      $sel:emailAddress:Account' :: Text
emailAddress = Text
pEmailAddress_
    }

-- | The account identifier of the AWS account.
account_accountId :: Lens.Lens' Account Prelude.Text
account_accountId :: (Text -> f Text) -> Account -> f Account
account_accountId = (Account -> Text)
-> (Account -> Text -> Account) -> Lens Account Account Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Text
accountId :: Text
$sel:accountId:Account' :: Account -> Text
accountId} -> Text
accountId) (\s :: Account
s@Account' {} Text
a -> Account
s {$sel:accountId:Account' :: Text
accountId = Text
a} :: Account)

-- | The AWS account root user email address for the AWS account.
account_emailAddress :: Lens.Lens' Account Prelude.Text
account_emailAddress :: (Text -> f Text) -> Account -> f Account
account_emailAddress = (Account -> Text)
-> (Account -> Text -> Account) -> Lens Account Account Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Text
emailAddress :: Text
$sel:emailAddress:Account' :: Account -> Text
emailAddress} -> Text
emailAddress) (\s :: Account
s@Account' {} Text
a -> Account
s {$sel:emailAddress:Account' :: Text
emailAddress = Text
a} :: Account)

instance Prelude.Hashable Account

instance Prelude.NFData Account

instance Core.ToJSON Account where
  toJSON :: Account -> Value
toJSON Account' {Text
emailAddress :: Text
accountId :: Text
$sel:emailAddress:Account' :: Account -> Text
$sel:accountId:Account' :: Account -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EmailAddress" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
emailAddress)
          ]
      )