{-# 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.UserIdentityRoot
-- 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.MacieV2.Types.UserIdentityRoot 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

-- | 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 your Amazon Web Services account.
--
-- /See:/ 'newUserIdentityRoot' smart constructor.
data UserIdentityRoot = UserIdentityRoot'
  { -- | The unique identifier for the Amazon Web Services account.
    UserIdentityRoot -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the principal that performed the
    -- action. The last section of the ARN contains the name of the user or
    -- role that performed the action.
    UserIdentityRoot -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the entity that performed the action.
    UserIdentityRoot -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text
  }
  deriving (UserIdentityRoot -> UserIdentityRoot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserIdentityRoot -> UserIdentityRoot -> Bool
$c/= :: UserIdentityRoot -> UserIdentityRoot -> Bool
== :: UserIdentityRoot -> UserIdentityRoot -> Bool
$c== :: UserIdentityRoot -> UserIdentityRoot -> Bool
Prelude.Eq, ReadPrec [UserIdentityRoot]
ReadPrec UserIdentityRoot
Int -> ReadS UserIdentityRoot
ReadS [UserIdentityRoot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserIdentityRoot]
$creadListPrec :: ReadPrec [UserIdentityRoot]
readPrec :: ReadPrec UserIdentityRoot
$creadPrec :: ReadPrec UserIdentityRoot
readList :: ReadS [UserIdentityRoot]
$creadList :: ReadS [UserIdentityRoot]
readsPrec :: Int -> ReadS UserIdentityRoot
$creadsPrec :: Int -> ReadS UserIdentityRoot
Prelude.Read, Int -> UserIdentityRoot -> ShowS
[UserIdentityRoot] -> ShowS
UserIdentityRoot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserIdentityRoot] -> ShowS
$cshowList :: [UserIdentityRoot] -> ShowS
show :: UserIdentityRoot -> String
$cshow :: UserIdentityRoot -> String
showsPrec :: Int -> UserIdentityRoot -> ShowS
$cshowsPrec :: Int -> UserIdentityRoot -> ShowS
Prelude.Show, forall x. Rep UserIdentityRoot x -> UserIdentityRoot
forall x. UserIdentityRoot -> Rep UserIdentityRoot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserIdentityRoot x -> UserIdentityRoot
$cfrom :: forall x. UserIdentityRoot -> Rep UserIdentityRoot x
Prelude.Generic)

-- |
-- Create a value of 'UserIdentityRoot' 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', 'userIdentityRoot_accountId' - The unique identifier for the Amazon Web Services account.
--
-- 'arn', 'userIdentityRoot_arn' - The Amazon Resource Name (ARN) of the principal that performed the
-- action. The last section of the ARN contains the name of the user or
-- role that performed the action.
--
-- 'principalId', 'userIdentityRoot_principalId' - The unique identifier for the entity that performed the action.
newUserIdentityRoot ::
  UserIdentityRoot
newUserIdentityRoot :: UserIdentityRoot
newUserIdentityRoot =
  UserIdentityRoot'
    { $sel:accountId:UserIdentityRoot' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UserIdentityRoot' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:principalId:UserIdentityRoot' :: Maybe Text
principalId = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The Amazon Resource Name (ARN) of the principal that performed the
-- action. The last section of the ARN contains the name of the user or
-- role that performed the action.
userIdentityRoot_arn :: Lens.Lens' UserIdentityRoot (Prelude.Maybe Prelude.Text)
userIdentityRoot_arn :: Lens' UserIdentityRoot (Maybe Text)
userIdentityRoot_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityRoot' {Maybe Text
arn :: Maybe Text
$sel:arn:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
arn} -> Maybe Text
arn) (\s :: UserIdentityRoot
s@UserIdentityRoot' {} Maybe Text
a -> UserIdentityRoot
s {$sel:arn:UserIdentityRoot' :: Maybe Text
arn = Maybe Text
a} :: UserIdentityRoot)

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

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

instance Prelude.Hashable UserIdentityRoot where
  hashWithSalt :: Int -> UserIdentityRoot -> Int
hashWithSalt Int
_salt UserIdentityRoot' {Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:principalId:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
$sel:arn:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
$sel:accountId:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principalId

instance Prelude.NFData UserIdentityRoot where
  rnf :: UserIdentityRoot -> ()
rnf UserIdentityRoot' {Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:principalId:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
$sel:arn:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
$sel:accountId:UserIdentityRoot' :: UserIdentityRoot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principalId