{-# 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.AuditManager.Types.AWSAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AuditManager.Types.AWSAccount where

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

-- | The wrapper of Amazon Web Services account details, such as account ID
-- or email address.
--
-- /See:/ 'newAWSAccount' smart constructor.
data AWSAccount = AWSAccount'
  { -- | The email address that\'s associated with the Amazon Web Services
    -- account.
    AWSAccount -> Maybe Text
emailAddress :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the Amazon Web Services account.
    AWSAccount -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon Web Services account.
    AWSAccount -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (AWSAccount -> AWSAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AWSAccount -> AWSAccount -> Bool
$c/= :: AWSAccount -> AWSAccount -> Bool
== :: AWSAccount -> AWSAccount -> Bool
$c== :: AWSAccount -> AWSAccount -> Bool
Prelude.Eq, ReadPrec [AWSAccount]
ReadPrec AWSAccount
Int -> ReadS AWSAccount
ReadS [AWSAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AWSAccount]
$creadListPrec :: ReadPrec [AWSAccount]
readPrec :: ReadPrec AWSAccount
$creadPrec :: ReadPrec AWSAccount
readList :: ReadS [AWSAccount]
$creadList :: ReadS [AWSAccount]
readsPrec :: Int -> ReadS AWSAccount
$creadsPrec :: Int -> ReadS AWSAccount
Prelude.Read, Int -> AWSAccount -> ShowS
[AWSAccount] -> ShowS
AWSAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AWSAccount] -> ShowS
$cshowList :: [AWSAccount] -> ShowS
show :: AWSAccount -> String
$cshow :: AWSAccount -> String
showsPrec :: Int -> AWSAccount -> ShowS
$cshowsPrec :: Int -> AWSAccount -> ShowS
Prelude.Show, forall x. Rep AWSAccount x -> AWSAccount
forall x. AWSAccount -> Rep AWSAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AWSAccount x -> AWSAccount
$cfrom :: forall x. AWSAccount -> Rep AWSAccount x
Prelude.Generic)

-- |
-- Create a value of 'AWSAccount' 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:
--
-- 'emailAddress', 'aWSAccount_emailAddress' - The email address that\'s associated with the Amazon Web Services
-- account.
--
-- 'id', 'aWSAccount_id' - The identifier for the Amazon Web Services account.
--
-- 'name', 'aWSAccount_name' - The name of the Amazon Web Services account.
newAWSAccount ::
  AWSAccount
newAWSAccount :: AWSAccount
newAWSAccount =
  AWSAccount'
    { $sel:emailAddress:AWSAccount' :: Maybe Text
emailAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:id:AWSAccount' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AWSAccount' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The email address that\'s associated with the Amazon Web Services
-- account.
aWSAccount_emailAddress :: Lens.Lens' AWSAccount (Prelude.Maybe Prelude.Text)
aWSAccount_emailAddress :: Lens' AWSAccount (Maybe Text)
aWSAccount_emailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSAccount' {Maybe Text
emailAddress :: Maybe Text
$sel:emailAddress:AWSAccount' :: AWSAccount -> Maybe Text
emailAddress} -> Maybe Text
emailAddress) (\s :: AWSAccount
s@AWSAccount' {} Maybe Text
a -> AWSAccount
s {$sel:emailAddress:AWSAccount' :: Maybe Text
emailAddress = Maybe Text
a} :: AWSAccount)

-- | The identifier for the Amazon Web Services account.
aWSAccount_id :: Lens.Lens' AWSAccount (Prelude.Maybe Prelude.Text)
aWSAccount_id :: Lens' AWSAccount (Maybe Text)
aWSAccount_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSAccount' {Maybe Text
id :: Maybe Text
$sel:id:AWSAccount' :: AWSAccount -> Maybe Text
id} -> Maybe Text
id) (\s :: AWSAccount
s@AWSAccount' {} Maybe Text
a -> AWSAccount
s {$sel:id:AWSAccount' :: Maybe Text
id = Maybe Text
a} :: AWSAccount)

-- | The name of the Amazon Web Services account.
aWSAccount_name :: Lens.Lens' AWSAccount (Prelude.Maybe Prelude.Text)
aWSAccount_name :: Lens' AWSAccount (Maybe Text)
aWSAccount_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSAccount' {Maybe Text
name :: Maybe Text
$sel:name:AWSAccount' :: AWSAccount -> Maybe Text
name} -> Maybe Text
name) (\s :: AWSAccount
s@AWSAccount' {} Maybe Text
a -> AWSAccount
s {$sel:name:AWSAccount' :: Maybe Text
name = Maybe Text
a} :: AWSAccount)

instance Data.FromJSON AWSAccount where
  parseJSON :: Value -> Parser AWSAccount
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AWSAccount"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> AWSAccount
AWSAccount'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"emailAddress")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
      )

instance Prelude.Hashable AWSAccount where
  hashWithSalt :: Int -> AWSAccount -> Int
hashWithSalt Int
_salt AWSAccount' {Maybe Text
name :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
$sel:name:AWSAccount' :: AWSAccount -> Maybe Text
$sel:id:AWSAccount' :: AWSAccount -> Maybe Text
$sel:emailAddress:AWSAccount' :: AWSAccount -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
emailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData AWSAccount where
  rnf :: AWSAccount -> ()
rnf AWSAccount' {Maybe Text
name :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
$sel:name:AWSAccount' :: AWSAccount -> Maybe Text
$sel:id:AWSAccount' :: AWSAccount -> Maybe Text
$sel:emailAddress:AWSAccount' :: AWSAccount -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
emailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

instance Data.ToJSON AWSAccount where
  toJSON :: AWSAccount -> Value
toJSON AWSAccount' {Maybe Text
name :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
$sel:name:AWSAccount' :: AWSAccount -> Maybe Text
$sel:id:AWSAccount' :: AWSAccount -> Maybe Text
$sel:emailAddress:AWSAccount' :: AWSAccount -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"emailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
emailAddress,
            (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
            (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name
          ]
      )