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

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

-- | Provides information about an Amazon Web Services account and entity
-- that performed an action on an affected resource. The action was
-- performed using the credentials for an Amazon Web Services account other
-- than your own account.
--
-- /See:/ 'newAwsAccount' smart constructor.
data AwsAccount = AwsAccount'
  { -- | The unique identifier for the entity that performed the action.
    AwsAccount -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the Amazon Web Services account.
    AwsAccount -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsAccount -> AwsAccount -> Bool
(AwsAccount -> AwsAccount -> Bool)
-> (AwsAccount -> AwsAccount -> Bool) -> Eq AwsAccount
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]
(Int -> ReadS AwsAccount)
-> ReadS [AwsAccount]
-> ReadPrec AwsAccount
-> ReadPrec [AwsAccount]
-> Read 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
(Int -> AwsAccount -> ShowS)
-> (AwsAccount -> String)
-> ([AwsAccount] -> ShowS)
-> Show AwsAccount
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. AwsAccount -> Rep AwsAccount x)
-> (forall x. Rep AwsAccount x -> AwsAccount) -> Generic AwsAccount
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:
--
-- 'principalId', 'awsAccount_principalId' - The unique identifier for the entity that performed the action.
--
-- 'accountId', 'awsAccount_accountId' - The unique identifier for the Amazon Web Services account.
newAwsAccount ::
  AwsAccount
newAwsAccount :: AwsAccount
newAwsAccount =
  AwsAccount' :: Maybe Text -> Maybe Text -> AwsAccount
AwsAccount'
    { $sel:principalId:AwsAccount' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:AwsAccount' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the entity that performed the action.
awsAccount_principalId :: Lens.Lens' AwsAccount (Prelude.Maybe Prelude.Text)
awsAccount_principalId :: (Maybe Text -> f (Maybe Text)) -> AwsAccount -> f AwsAccount
awsAccount_principalId = (AwsAccount -> Maybe Text)
-> (AwsAccount -> Maybe Text -> AwsAccount)
-> Lens AwsAccount AwsAccount (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsAccount' {Maybe Text
principalId :: Maybe Text
$sel:principalId:AwsAccount' :: AwsAccount -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: AwsAccount
s@AwsAccount' {} Maybe Text
a -> AwsAccount
s {$sel:principalId:AwsAccount' :: Maybe Text
principalId = Maybe Text
a} :: AwsAccount)

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

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

instance Prelude.NFData AwsAccount