{-# 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-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.UserIdentityRoot 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 your Amazon Web Services account.
--
-- /See:/ 'newUserIdentityRoot' smart constructor.
data UserIdentityRoot = UserIdentityRoot'
  { -- | The unique identifier for the entity that performed the action.
    UserIdentityRoot -> Maybe Text
principalId :: 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 Amazon Web Services account.
    UserIdentityRoot -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  deriving (UserIdentityRoot -> UserIdentityRoot -> Bool
(UserIdentityRoot -> UserIdentityRoot -> Bool)
-> (UserIdentityRoot -> UserIdentityRoot -> Bool)
-> Eq UserIdentityRoot
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]
(Int -> ReadS UserIdentityRoot)
-> ReadS [UserIdentityRoot]
-> ReadPrec UserIdentityRoot
-> ReadPrec [UserIdentityRoot]
-> Read 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
(Int -> UserIdentityRoot -> ShowS)
-> (UserIdentityRoot -> String)
-> ([UserIdentityRoot] -> ShowS)
-> Show UserIdentityRoot
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. UserIdentityRoot -> Rep UserIdentityRoot x)
-> (forall x. Rep UserIdentityRoot x -> UserIdentityRoot)
-> Generic UserIdentityRoot
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:
--
-- 'principalId', 'userIdentityRoot_principalId' - The unique identifier for the entity that performed the action.
--
-- '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.
--
-- 'accountId', 'userIdentityRoot_accountId' - The unique identifier for the Amazon Web Services account.
newUserIdentityRoot ::
  UserIdentityRoot
newUserIdentityRoot :: UserIdentityRoot
newUserIdentityRoot =
  UserIdentityRoot' :: Maybe Text -> Maybe Text -> Maybe Text -> UserIdentityRoot
UserIdentityRoot'
    { $sel:principalId:UserIdentityRoot' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UserIdentityRoot' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:UserIdentityRoot' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the entity that performed the action.
userIdentityRoot_principalId :: Lens.Lens' UserIdentityRoot (Prelude.Maybe Prelude.Text)
userIdentityRoot_principalId :: (Maybe Text -> f (Maybe Text))
-> UserIdentityRoot -> f UserIdentityRoot
userIdentityRoot_principalId = (UserIdentityRoot -> Maybe Text)
-> (UserIdentityRoot -> Maybe Text -> UserIdentityRoot)
-> Lens UserIdentityRoot UserIdentityRoot (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> UserIdentityRoot -> f UserIdentityRoot
userIdentityRoot_arn = (UserIdentityRoot -> Maybe Text)
-> (UserIdentityRoot -> Maybe Text -> UserIdentityRoot)
-> Lens UserIdentityRoot UserIdentityRoot (Maybe Text) (Maybe Text)
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 Amazon Web Services account.
userIdentityRoot_accountId :: Lens.Lens' UserIdentityRoot (Prelude.Maybe Prelude.Text)
userIdentityRoot_accountId :: (Maybe Text -> f (Maybe Text))
-> UserIdentityRoot -> f UserIdentityRoot
userIdentityRoot_accountId = (UserIdentityRoot -> Maybe Text)
-> (UserIdentityRoot -> Maybe Text -> UserIdentityRoot)
-> Lens UserIdentityRoot UserIdentityRoot (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData UserIdentityRoot