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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 IAM user who performed the action.
    IamUser -> 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 who
    -- performed the action.
    IamUser -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The user name of the IAM user who performed the action.
    IamUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (IamUser -> IamUser -> Bool
(IamUser -> IamUser -> Bool)
-> (IamUser -> IamUser -> Bool) -> Eq IamUser
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]
(Int -> ReadS IamUser)
-> ReadS [IamUser]
-> ReadPrec IamUser
-> ReadPrec [IamUser]
-> Read 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
(Int -> IamUser -> ShowS)
-> (IamUser -> String) -> ([IamUser] -> ShowS) -> Show IamUser
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. IamUser -> Rep IamUser x)
-> (forall x. Rep IamUser x -> IamUser) -> Generic IamUser
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:
--
-- 'principalId', 'iamUser_principalId' - The unique identifier for 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.
--
-- 'userName', 'iamUser_userName' - The user name of the IAM user who performed the action.
--
-- 'accountId', 'iamUser_accountId' - The unique identifier for the Amazon Web Services account that\'s
-- associated with the IAM user who performed the action.
newIamUser ::
  IamUser
newIamUser :: IamUser
newIamUser =
  IamUser' :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> IamUser
IamUser'
    { $sel:principalId:IamUser' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:IamUser' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:IamUser' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:IamUser' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the IAM user who performed the action.
iamUser_principalId :: Lens.Lens' IamUser (Prelude.Maybe Prelude.Text)
iamUser_principalId :: (Maybe Text -> f (Maybe Text)) -> IamUser -> f IamUser
iamUser_principalId = (IamUser -> Maybe Text)
-> (IamUser -> Maybe Text -> IamUser)
-> Lens IamUser IamUser (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> IamUser -> f IamUser
iamUser_arn = (IamUser -> Maybe Text)
-> (IamUser -> Maybe Text -> IamUser)
-> Lens IamUser IamUser (Maybe Text) (Maybe Text)
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 user name of the IAM user who performed the action.
iamUser_userName :: Lens.Lens' IamUser (Prelude.Maybe Prelude.Text)
iamUser_userName :: (Maybe Text -> f (Maybe Text)) -> IamUser -> f IamUser
iamUser_userName = (IamUser -> Maybe Text)
-> (IamUser -> Maybe Text -> IamUser)
-> Lens IamUser IamUser (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> IamUser -> f IamUser
iamUser_accountId = (IamUser -> Maybe Text)
-> (IamUser -> Maybe Text -> IamUser)
-> Lens IamUser IamUser (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData IamUser