{-# 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.IamUser
-- 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.IamUser 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 Identity and Access Management (IAM) user
-- who performed an action on an affected resource.
--
-- /See:/ 'newIamUser' smart constructor.
data IamUser = IamUser'
  { -- | The unique identifier for the Amazon Web Services account that\'s
    -- associated with the IAM user who performed the action.
    IamUser -> 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 who
    -- performed the action.
    IamUser -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the IAM user who performed the action.
    IamUser -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The user name of the IAM user who performed the action.
    IamUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text
  }
  deriving (IamUser -> IamUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IamUser -> IamUser -> Bool
$c/= :: IamUser -> IamUser -> Bool
== :: IamUser -> IamUser -> Bool
$c== :: IamUser -> IamUser -> Bool
Prelude.Eq, ReadPrec [IamUser]
ReadPrec IamUser
Int -> ReadS IamUser
ReadS [IamUser]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IamUser]
$creadListPrec :: ReadPrec [IamUser]
readPrec :: ReadPrec IamUser
$creadPrec :: ReadPrec IamUser
readList :: ReadS [IamUser]
$creadList :: ReadS [IamUser]
readsPrec :: Int -> ReadS IamUser
$creadsPrec :: Int -> ReadS IamUser
Prelude.Read, Int -> IamUser -> ShowS
[IamUser] -> ShowS
IamUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IamUser] -> ShowS
$cshowList :: [IamUser] -> ShowS
show :: IamUser -> String
$cshow :: IamUser -> String
showsPrec :: Int -> IamUser -> ShowS
$cshowsPrec :: Int -> IamUser -> ShowS
Prelude.Show, forall x. Rep IamUser x -> IamUser
forall x. IamUser -> Rep IamUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IamUser x -> IamUser
$cfrom :: forall x. IamUser -> Rep IamUser x
Prelude.Generic)

-- |
-- Create a value of 'IamUser' 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', 'iamUser_accountId' - The unique identifier for the Amazon Web Services account that\'s
-- associated with the IAM user who performed the action.
--
-- 'arn', 'iamUser_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 who
-- performed the action.
--
-- 'principalId', 'iamUser_principalId' - The unique identifier for the IAM user who performed the action.
--
-- 'userName', 'iamUser_userName' - The user name of the IAM user who performed the action.
newIamUser ::
  IamUser
newIamUser :: IamUser
newIamUser =
  IamUser'
    { $sel:accountId:IamUser' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:IamUser' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:principalId:IamUser' :: Maybe Text
principalId = forall a. Maybe a
Prelude.Nothing,
      $sel:userName:IamUser' :: Maybe Text
userName = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the Amazon Web Services account that\'s
-- associated with the IAM user who performed the action.
iamUser_accountId :: Lens.Lens' IamUser (Prelude.Maybe Prelude.Text)
iamUser_accountId :: Lens' IamUser (Maybe Text)
iamUser_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamUser' {Maybe Text
accountId :: Maybe Text
$sel:accountId:IamUser' :: IamUser -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: IamUser
s@IamUser' {} Maybe Text
a -> IamUser
s {$sel:accountId:IamUser' :: Maybe Text
accountId = Maybe Text
a} :: IamUser)

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

-- | The unique identifier for the IAM user who performed the action.
iamUser_principalId :: Lens.Lens' IamUser (Prelude.Maybe Prelude.Text)
iamUser_principalId :: Lens' IamUser (Maybe Text)
iamUser_principalId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamUser' {Maybe Text
principalId :: Maybe Text
$sel:principalId:IamUser' :: IamUser -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: IamUser
s@IamUser' {} Maybe Text
a -> IamUser
s {$sel:principalId:IamUser' :: Maybe Text
principalId = Maybe Text
a} :: IamUser)

-- | The user name of the IAM user who performed the action.
iamUser_userName :: Lens.Lens' IamUser (Prelude.Maybe Prelude.Text)
iamUser_userName :: Lens' IamUser (Maybe Text)
iamUser_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamUser' {Maybe Text
userName :: Maybe Text
$sel:userName:IamUser' :: IamUser -> Maybe Text
userName} -> Maybe Text
userName) (\s :: IamUser
s@IamUser' {} Maybe Text
a -> IamUser
s {$sel:userName:IamUser' :: Maybe Text
userName = Maybe Text
a} :: IamUser)

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

instance Prelude.Hashable IamUser where
  hashWithSalt :: Int -> IamUser -> Int
hashWithSalt Int
_salt IamUser' {Maybe Text
userName :: Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:userName:IamUser' :: IamUser -> Maybe Text
$sel:principalId:IamUser' :: IamUser -> Maybe Text
$sel:arn:IamUser' :: IamUser -> Maybe Text
$sel:accountId:IamUser' :: IamUser -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName

instance Prelude.NFData IamUser where
  rnf :: IamUser -> ()
rnf IamUser' {Maybe Text
userName :: Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:userName:IamUser' :: IamUser -> Maybe Text
$sel:principalId:IamUser' :: IamUser -> Maybe Text
$sel:arn:IamUser' :: IamUser -> Maybe Text
$sel:accountId:IamUser' :: IamUser -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userName