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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.AssumedRole
import Amazonka.MacieV2.Types.AwsAccount
import Amazonka.MacieV2.Types.AwsService
import Amazonka.MacieV2.Types.FederatedUser
import Amazonka.MacieV2.Types.IamUser
import Amazonka.MacieV2.Types.UserIdentityRoot
import Amazonka.MacieV2.Types.UserIdentityType
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the type and other characteristics of an
-- entity that performed an action on an affected resource.
--
-- /See:/ 'newUserIdentity' smart constructor.
data UserIdentity = UserIdentity'
  { -- | If the action was performed using the credentials for an Identity and
    -- Access Management (IAM) user, the name and other details about the user.
    UserIdentity -> Maybe IamUser
iamUser :: Prelude.Maybe IamUser,
    -- | If the action was performed using the credentials for your Amazon Web
    -- Services account, the details of your account.
    UserIdentity -> Maybe UserIdentityRoot
root :: Prelude.Maybe UserIdentityRoot,
    -- | If the action was performed using the credentials for another Amazon Web
    -- Services account, the details of that account.
    UserIdentity -> Maybe AwsAccount
awsAccount :: Prelude.Maybe AwsAccount,
    -- | If the action was performed with temporary security credentials that
    -- were obtained using the AssumeRole operation of the Security Token
    -- Service (STS) API, the identifiers, session context, and other details
    -- about the identity.
    UserIdentity -> Maybe AssumedRole
assumedRole :: Prelude.Maybe AssumedRole,
    -- | If the action was performed with temporary security credentials that
    -- were obtained using the GetFederationToken operation of the Security
    -- Token Service (STS) API, the identifiers, session context, and other
    -- details about the identity.
    UserIdentity -> Maybe FederatedUser
federatedUser :: Prelude.Maybe FederatedUser,
    -- | If the action was performed by an Amazon Web Services account that
    -- belongs to an Amazon Web Service, the name of the service.
    UserIdentity -> Maybe AwsService
awsService :: Prelude.Maybe AwsService,
    -- | The type of entity that performed the action.
    UserIdentity -> Maybe UserIdentityType
type' :: Prelude.Maybe UserIdentityType
  }
  deriving (UserIdentity -> UserIdentity -> Bool
(UserIdentity -> UserIdentity -> Bool)
-> (UserIdentity -> UserIdentity -> Bool) -> Eq UserIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserIdentity -> UserIdentity -> Bool
$c/= :: UserIdentity -> UserIdentity -> Bool
== :: UserIdentity -> UserIdentity -> Bool
$c== :: UserIdentity -> UserIdentity -> Bool
Prelude.Eq, ReadPrec [UserIdentity]
ReadPrec UserIdentity
Int -> ReadS UserIdentity
ReadS [UserIdentity]
(Int -> ReadS UserIdentity)
-> ReadS [UserIdentity]
-> ReadPrec UserIdentity
-> ReadPrec [UserIdentity]
-> Read UserIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserIdentity]
$creadListPrec :: ReadPrec [UserIdentity]
readPrec :: ReadPrec UserIdentity
$creadPrec :: ReadPrec UserIdentity
readList :: ReadS [UserIdentity]
$creadList :: ReadS [UserIdentity]
readsPrec :: Int -> ReadS UserIdentity
$creadsPrec :: Int -> ReadS UserIdentity
Prelude.Read, Int -> UserIdentity -> ShowS
[UserIdentity] -> ShowS
UserIdentity -> String
(Int -> UserIdentity -> ShowS)
-> (UserIdentity -> String)
-> ([UserIdentity] -> ShowS)
-> Show UserIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserIdentity] -> ShowS
$cshowList :: [UserIdentity] -> ShowS
show :: UserIdentity -> String
$cshow :: UserIdentity -> String
showsPrec :: Int -> UserIdentity -> ShowS
$cshowsPrec :: Int -> UserIdentity -> ShowS
Prelude.Show, (forall x. UserIdentity -> Rep UserIdentity x)
-> (forall x. Rep UserIdentity x -> UserIdentity)
-> Generic UserIdentity
forall x. Rep UserIdentity x -> UserIdentity
forall x. UserIdentity -> Rep UserIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserIdentity x -> UserIdentity
$cfrom :: forall x. UserIdentity -> Rep UserIdentity x
Prelude.Generic)

-- |
-- Create a value of 'UserIdentity' 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:
--
-- 'iamUser', 'userIdentity_iamUser' - If the action was performed using the credentials for an Identity and
-- Access Management (IAM) user, the name and other details about the user.
--
-- 'root', 'userIdentity_root' - If the action was performed using the credentials for your Amazon Web
-- Services account, the details of your account.
--
-- 'awsAccount', 'userIdentity_awsAccount' - If the action was performed using the credentials for another Amazon Web
-- Services account, the details of that account.
--
-- 'assumedRole', 'userIdentity_assumedRole' - If the action was performed with temporary security credentials that
-- were obtained using the AssumeRole operation of the Security Token
-- Service (STS) API, the identifiers, session context, and other details
-- about the identity.
--
-- 'federatedUser', 'userIdentity_federatedUser' - If the action was performed with temporary security credentials that
-- were obtained using the GetFederationToken operation of the Security
-- Token Service (STS) API, the identifiers, session context, and other
-- details about the identity.
--
-- 'awsService', 'userIdentity_awsService' - If the action was performed by an Amazon Web Services account that
-- belongs to an Amazon Web Service, the name of the service.
--
-- 'type'', 'userIdentity_type' - The type of entity that performed the action.
newUserIdentity ::
  UserIdentity
newUserIdentity :: UserIdentity
newUserIdentity =
  UserIdentity' :: Maybe IamUser
-> Maybe UserIdentityRoot
-> Maybe AwsAccount
-> Maybe AssumedRole
-> Maybe FederatedUser
-> Maybe AwsService
-> Maybe UserIdentityType
-> UserIdentity
UserIdentity'
    { $sel:iamUser:UserIdentity' :: Maybe IamUser
iamUser = Maybe IamUser
forall a. Maybe a
Prelude.Nothing,
      $sel:root:UserIdentity' :: Maybe UserIdentityRoot
root = Maybe UserIdentityRoot
forall a. Maybe a
Prelude.Nothing,
      $sel:awsAccount:UserIdentity' :: Maybe AwsAccount
awsAccount = Maybe AwsAccount
forall a. Maybe a
Prelude.Nothing,
      $sel:assumedRole:UserIdentity' :: Maybe AssumedRole
assumedRole = Maybe AssumedRole
forall a. Maybe a
Prelude.Nothing,
      $sel:federatedUser:UserIdentity' :: Maybe FederatedUser
federatedUser = Maybe FederatedUser
forall a. Maybe a
Prelude.Nothing,
      $sel:awsService:UserIdentity' :: Maybe AwsService
awsService = Maybe AwsService
forall a. Maybe a
Prelude.Nothing,
      $sel:type':UserIdentity' :: Maybe UserIdentityType
type' = Maybe UserIdentityType
forall a. Maybe a
Prelude.Nothing
    }

-- | If the action was performed using the credentials for an Identity and
-- Access Management (IAM) user, the name and other details about the user.
userIdentity_iamUser :: Lens.Lens' UserIdentity (Prelude.Maybe IamUser)
userIdentity_iamUser :: (Maybe IamUser -> f (Maybe IamUser))
-> UserIdentity -> f UserIdentity
userIdentity_iamUser = (UserIdentity -> Maybe IamUser)
-> (UserIdentity -> Maybe IamUser -> UserIdentity)
-> Lens UserIdentity UserIdentity (Maybe IamUser) (Maybe IamUser)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe IamUser
iamUser :: Maybe IamUser
$sel:iamUser:UserIdentity' :: UserIdentity -> Maybe IamUser
iamUser} -> Maybe IamUser
iamUser) (\s :: UserIdentity
s@UserIdentity' {} Maybe IamUser
a -> UserIdentity
s {$sel:iamUser:UserIdentity' :: Maybe IamUser
iamUser = Maybe IamUser
a} :: UserIdentity)

-- | If the action was performed using the credentials for your Amazon Web
-- Services account, the details of your account.
userIdentity_root :: Lens.Lens' UserIdentity (Prelude.Maybe UserIdentityRoot)
userIdentity_root :: (Maybe UserIdentityRoot -> f (Maybe UserIdentityRoot))
-> UserIdentity -> f UserIdentity
userIdentity_root = (UserIdentity -> Maybe UserIdentityRoot)
-> (UserIdentity -> Maybe UserIdentityRoot -> UserIdentity)
-> Lens
     UserIdentity
     UserIdentity
     (Maybe UserIdentityRoot)
     (Maybe UserIdentityRoot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe UserIdentityRoot
root :: Maybe UserIdentityRoot
$sel:root:UserIdentity' :: UserIdentity -> Maybe UserIdentityRoot
root} -> Maybe UserIdentityRoot
root) (\s :: UserIdentity
s@UserIdentity' {} Maybe UserIdentityRoot
a -> UserIdentity
s {$sel:root:UserIdentity' :: Maybe UserIdentityRoot
root = Maybe UserIdentityRoot
a} :: UserIdentity)

-- | If the action was performed using the credentials for another Amazon Web
-- Services account, the details of that account.
userIdentity_awsAccount :: Lens.Lens' UserIdentity (Prelude.Maybe AwsAccount)
userIdentity_awsAccount :: (Maybe AwsAccount -> f (Maybe AwsAccount))
-> UserIdentity -> f UserIdentity
userIdentity_awsAccount = (UserIdentity -> Maybe AwsAccount)
-> (UserIdentity -> Maybe AwsAccount -> UserIdentity)
-> Lens
     UserIdentity UserIdentity (Maybe AwsAccount) (Maybe AwsAccount)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe AwsAccount
awsAccount :: Maybe AwsAccount
$sel:awsAccount:UserIdentity' :: UserIdentity -> Maybe AwsAccount
awsAccount} -> Maybe AwsAccount
awsAccount) (\s :: UserIdentity
s@UserIdentity' {} Maybe AwsAccount
a -> UserIdentity
s {$sel:awsAccount:UserIdentity' :: Maybe AwsAccount
awsAccount = Maybe AwsAccount
a} :: UserIdentity)

-- | If the action was performed with temporary security credentials that
-- were obtained using the AssumeRole operation of the Security Token
-- Service (STS) API, the identifiers, session context, and other details
-- about the identity.
userIdentity_assumedRole :: Lens.Lens' UserIdentity (Prelude.Maybe AssumedRole)
userIdentity_assumedRole :: (Maybe AssumedRole -> f (Maybe AssumedRole))
-> UserIdentity -> f UserIdentity
userIdentity_assumedRole = (UserIdentity -> Maybe AssumedRole)
-> (UserIdentity -> Maybe AssumedRole -> UserIdentity)
-> Lens
     UserIdentity UserIdentity (Maybe AssumedRole) (Maybe AssumedRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe AssumedRole
assumedRole :: Maybe AssumedRole
$sel:assumedRole:UserIdentity' :: UserIdentity -> Maybe AssumedRole
assumedRole} -> Maybe AssumedRole
assumedRole) (\s :: UserIdentity
s@UserIdentity' {} Maybe AssumedRole
a -> UserIdentity
s {$sel:assumedRole:UserIdentity' :: Maybe AssumedRole
assumedRole = Maybe AssumedRole
a} :: UserIdentity)

-- | If the action was performed with temporary security credentials that
-- were obtained using the GetFederationToken operation of the Security
-- Token Service (STS) API, the identifiers, session context, and other
-- details about the identity.
userIdentity_federatedUser :: Lens.Lens' UserIdentity (Prelude.Maybe FederatedUser)
userIdentity_federatedUser :: (Maybe FederatedUser -> f (Maybe FederatedUser))
-> UserIdentity -> f UserIdentity
userIdentity_federatedUser = (UserIdentity -> Maybe FederatedUser)
-> (UserIdentity -> Maybe FederatedUser -> UserIdentity)
-> Lens
     UserIdentity
     UserIdentity
     (Maybe FederatedUser)
     (Maybe FederatedUser)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe FederatedUser
federatedUser :: Maybe FederatedUser
$sel:federatedUser:UserIdentity' :: UserIdentity -> Maybe FederatedUser
federatedUser} -> Maybe FederatedUser
federatedUser) (\s :: UserIdentity
s@UserIdentity' {} Maybe FederatedUser
a -> UserIdentity
s {$sel:federatedUser:UserIdentity' :: Maybe FederatedUser
federatedUser = Maybe FederatedUser
a} :: UserIdentity)

-- | If the action was performed by an Amazon Web Services account that
-- belongs to an Amazon Web Service, the name of the service.
userIdentity_awsService :: Lens.Lens' UserIdentity (Prelude.Maybe AwsService)
userIdentity_awsService :: (Maybe AwsService -> f (Maybe AwsService))
-> UserIdentity -> f UserIdentity
userIdentity_awsService = (UserIdentity -> Maybe AwsService)
-> (UserIdentity -> Maybe AwsService -> UserIdentity)
-> Lens
     UserIdentity UserIdentity (Maybe AwsService) (Maybe AwsService)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe AwsService
awsService :: Maybe AwsService
$sel:awsService:UserIdentity' :: UserIdentity -> Maybe AwsService
awsService} -> Maybe AwsService
awsService) (\s :: UserIdentity
s@UserIdentity' {} Maybe AwsService
a -> UserIdentity
s {$sel:awsService:UserIdentity' :: Maybe AwsService
awsService = Maybe AwsService
a} :: UserIdentity)

-- | The type of entity that performed the action.
userIdentity_type :: Lens.Lens' UserIdentity (Prelude.Maybe UserIdentityType)
userIdentity_type :: (Maybe UserIdentityType -> f (Maybe UserIdentityType))
-> UserIdentity -> f UserIdentity
userIdentity_type = (UserIdentity -> Maybe UserIdentityType)
-> (UserIdentity -> Maybe UserIdentityType -> UserIdentity)
-> Lens
     UserIdentity
     UserIdentity
     (Maybe UserIdentityType)
     (Maybe UserIdentityType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentity' {Maybe UserIdentityType
type' :: Maybe UserIdentityType
$sel:type':UserIdentity' :: UserIdentity -> Maybe UserIdentityType
type'} -> Maybe UserIdentityType
type') (\s :: UserIdentity
s@UserIdentity' {} Maybe UserIdentityType
a -> UserIdentity
s {$sel:type':UserIdentity' :: Maybe UserIdentityType
type' = Maybe UserIdentityType
a} :: UserIdentity)

instance Core.FromJSON UserIdentity where
  parseJSON :: Value -> Parser UserIdentity
parseJSON =
    String
-> (Object -> Parser UserIdentity) -> Value -> Parser UserIdentity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserIdentity"
      ( \Object
x ->
          Maybe IamUser
-> Maybe UserIdentityRoot
-> Maybe AwsAccount
-> Maybe AssumedRole
-> Maybe FederatedUser
-> Maybe AwsService
-> Maybe UserIdentityType
-> UserIdentity
UserIdentity'
            (Maybe IamUser
 -> Maybe UserIdentityRoot
 -> Maybe AwsAccount
 -> Maybe AssumedRole
 -> Maybe FederatedUser
 -> Maybe AwsService
 -> Maybe UserIdentityType
 -> UserIdentity)
-> Parser (Maybe IamUser)
-> Parser
     (Maybe UserIdentityRoot
      -> Maybe AwsAccount
      -> Maybe AssumedRole
      -> Maybe FederatedUser
      -> Maybe AwsService
      -> Maybe UserIdentityType
      -> UserIdentity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IamUser)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iamUser")
            Parser
  (Maybe UserIdentityRoot
   -> Maybe AwsAccount
   -> Maybe AssumedRole
   -> Maybe FederatedUser
   -> Maybe AwsService
   -> Maybe UserIdentityType
   -> UserIdentity)
-> Parser (Maybe UserIdentityRoot)
-> Parser
     (Maybe AwsAccount
      -> Maybe AssumedRole
      -> Maybe FederatedUser
      -> Maybe AwsService
      -> Maybe UserIdentityType
      -> UserIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserIdentityRoot)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"root")
            Parser
  (Maybe AwsAccount
   -> Maybe AssumedRole
   -> Maybe FederatedUser
   -> Maybe AwsService
   -> Maybe UserIdentityType
   -> UserIdentity)
-> Parser (Maybe AwsAccount)
-> Parser
     (Maybe AssumedRole
      -> Maybe FederatedUser
      -> Maybe AwsService
      -> Maybe UserIdentityType
      -> UserIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AwsAccount)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsAccount")
            Parser
  (Maybe AssumedRole
   -> Maybe FederatedUser
   -> Maybe AwsService
   -> Maybe UserIdentityType
   -> UserIdentity)
-> Parser (Maybe AssumedRole)
-> Parser
     (Maybe FederatedUser
      -> Maybe AwsService -> Maybe UserIdentityType -> UserIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AssumedRole)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"assumedRole")
            Parser
  (Maybe FederatedUser
   -> Maybe AwsService -> Maybe UserIdentityType -> UserIdentity)
-> Parser (Maybe FederatedUser)
-> Parser
     (Maybe AwsService -> Maybe UserIdentityType -> UserIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FederatedUser)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"federatedUser")
            Parser (Maybe AwsService -> Maybe UserIdentityType -> UserIdentity)
-> Parser (Maybe AwsService)
-> Parser (Maybe UserIdentityType -> UserIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AwsService)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsService")
            Parser (Maybe UserIdentityType -> UserIdentity)
-> Parser (Maybe UserIdentityType) -> Parser UserIdentity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserIdentityType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable UserIdentity

instance Prelude.NFData UserIdentity