{-# 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.SecurityHub.Types.AccountDetails
-- 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.SecurityHub.Types.AccountDetails where

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

-- | The details of an Amazon Web Services account.
--
-- /See:/ 'newAccountDetails' smart constructor.
data AccountDetails = AccountDetails'
  { -- | The email of an Amazon Web Services account.
    AccountDetails -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The ID of an Amazon Web Services account.
    AccountDetails -> Text
accountId :: Prelude.Text
  }
  deriving (AccountDetails -> AccountDetails -> Bool
(AccountDetails -> AccountDetails -> Bool)
-> (AccountDetails -> AccountDetails -> Bool) -> Eq AccountDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountDetails -> AccountDetails -> Bool
$c/= :: AccountDetails -> AccountDetails -> Bool
== :: AccountDetails -> AccountDetails -> Bool
$c== :: AccountDetails -> AccountDetails -> Bool
Prelude.Eq, ReadPrec [AccountDetails]
ReadPrec AccountDetails
Int -> ReadS AccountDetails
ReadS [AccountDetails]
(Int -> ReadS AccountDetails)
-> ReadS [AccountDetails]
-> ReadPrec AccountDetails
-> ReadPrec [AccountDetails]
-> Read AccountDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountDetails]
$creadListPrec :: ReadPrec [AccountDetails]
readPrec :: ReadPrec AccountDetails
$creadPrec :: ReadPrec AccountDetails
readList :: ReadS [AccountDetails]
$creadList :: ReadS [AccountDetails]
readsPrec :: Int -> ReadS AccountDetails
$creadsPrec :: Int -> ReadS AccountDetails
Prelude.Read, Int -> AccountDetails -> ShowS
[AccountDetails] -> ShowS
AccountDetails -> String
(Int -> AccountDetails -> ShowS)
-> (AccountDetails -> String)
-> ([AccountDetails] -> ShowS)
-> Show AccountDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountDetails] -> ShowS
$cshowList :: [AccountDetails] -> ShowS
show :: AccountDetails -> String
$cshow :: AccountDetails -> String
showsPrec :: Int -> AccountDetails -> ShowS
$cshowsPrec :: Int -> AccountDetails -> ShowS
Prelude.Show, (forall x. AccountDetails -> Rep AccountDetails x)
-> (forall x. Rep AccountDetails x -> AccountDetails)
-> Generic AccountDetails
forall x. Rep AccountDetails x -> AccountDetails
forall x. AccountDetails -> Rep AccountDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountDetails x -> AccountDetails
$cfrom :: forall x. AccountDetails -> Rep AccountDetails x
Prelude.Generic)

-- |
-- Create a value of 'AccountDetails' 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:
--
-- 'email', 'accountDetails_email' - The email of an Amazon Web Services account.
--
-- 'accountId', 'accountDetails_accountId' - The ID of an Amazon Web Services account.
newAccountDetails ::
  -- | 'accountId'
  Prelude.Text ->
  AccountDetails
newAccountDetails :: Text -> AccountDetails
newAccountDetails Text
pAccountId_ =
  AccountDetails' :: Maybe Text -> Text -> AccountDetails
AccountDetails'
    { $sel:email:AccountDetails' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:AccountDetails' :: Text
accountId = Text
pAccountId_
    }

-- | The email of an Amazon Web Services account.
accountDetails_email :: Lens.Lens' AccountDetails (Prelude.Maybe Prelude.Text)
accountDetails_email :: (Maybe Text -> f (Maybe Text))
-> AccountDetails -> f AccountDetails
accountDetails_email = (AccountDetails -> Maybe Text)
-> (AccountDetails -> Maybe Text -> AccountDetails)
-> Lens AccountDetails AccountDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountDetails' {Maybe Text
email :: Maybe Text
$sel:email:AccountDetails' :: AccountDetails -> Maybe Text
email} -> Maybe Text
email) (\s :: AccountDetails
s@AccountDetails' {} Maybe Text
a -> AccountDetails
s {$sel:email:AccountDetails' :: Maybe Text
email = Maybe Text
a} :: AccountDetails)

-- | The ID of an Amazon Web Services account.
accountDetails_accountId :: Lens.Lens' AccountDetails Prelude.Text
accountDetails_accountId :: (Text -> f Text) -> AccountDetails -> f AccountDetails
accountDetails_accountId = (AccountDetails -> Text)
-> (AccountDetails -> Text -> AccountDetails)
-> Lens AccountDetails AccountDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountDetails' {Text
accountId :: Text
$sel:accountId:AccountDetails' :: AccountDetails -> Text
accountId} -> Text
accountId) (\s :: AccountDetails
s@AccountDetails' {} Text
a -> AccountDetails
s {$sel:accountId:AccountDetails' :: Text
accountId = Text
a} :: AccountDetails)

instance Prelude.Hashable AccountDetails

instance Prelude.NFData AccountDetails

instance Core.ToJSON AccountDetails where
  toJSON :: AccountDetails -> Value
toJSON AccountDetails' {Maybe Text
Text
accountId :: Text
email :: Maybe Text
$sel:accountId:AccountDetails' :: AccountDetails -> Text
$sel:email:AccountDetails' :: AccountDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Email" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
email,
            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)
          ]
      )