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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SessionContext
import qualified Amazonka.Prelude as Prelude

-- | Provides information about an identity that performed an action on an
-- affected resource by using temporary security credentials. The
-- credentials were obtained using the GetFederationToken operation of the
-- Security Token Service (STS) API.
--
-- /See:/ 'newFederatedUser' smart constructor.
data FederatedUser = FederatedUser'
  { -- | The unique identifier for the entity that was used to get the
    -- credentials.
    FederatedUser -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the entity that was used to get the
    -- credentials.
    FederatedUser -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The details of the session that was created for the credentials,
    -- including the entity that issued the session.
    FederatedUser -> Maybe SessionContext
sessionContext :: Prelude.Maybe SessionContext,
    -- | The unique identifier for the Amazon Web Services account that owns the
    -- entity that was used to get the credentials.
    FederatedUser -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services access key ID that identifies the credentials.
    FederatedUser -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (FederatedUser -> FederatedUser -> Bool
(FederatedUser -> FederatedUser -> Bool)
-> (FederatedUser -> FederatedUser -> Bool) -> Eq FederatedUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FederatedUser -> FederatedUser -> Bool
$c/= :: FederatedUser -> FederatedUser -> Bool
== :: FederatedUser -> FederatedUser -> Bool
$c== :: FederatedUser -> FederatedUser -> Bool
Prelude.Eq, ReadPrec [FederatedUser]
ReadPrec FederatedUser
Int -> ReadS FederatedUser
ReadS [FederatedUser]
(Int -> ReadS FederatedUser)
-> ReadS [FederatedUser]
-> ReadPrec FederatedUser
-> ReadPrec [FederatedUser]
-> Read FederatedUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FederatedUser]
$creadListPrec :: ReadPrec [FederatedUser]
readPrec :: ReadPrec FederatedUser
$creadPrec :: ReadPrec FederatedUser
readList :: ReadS [FederatedUser]
$creadList :: ReadS [FederatedUser]
readsPrec :: Int -> ReadS FederatedUser
$creadsPrec :: Int -> ReadS FederatedUser
Prelude.Read, Int -> FederatedUser -> ShowS
[FederatedUser] -> ShowS
FederatedUser -> String
(Int -> FederatedUser -> ShowS)
-> (FederatedUser -> String)
-> ([FederatedUser] -> ShowS)
-> Show FederatedUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FederatedUser] -> ShowS
$cshowList :: [FederatedUser] -> ShowS
show :: FederatedUser -> String
$cshow :: FederatedUser -> String
showsPrec :: Int -> FederatedUser -> ShowS
$cshowsPrec :: Int -> FederatedUser -> ShowS
Prelude.Show, (forall x. FederatedUser -> Rep FederatedUser x)
-> (forall x. Rep FederatedUser x -> FederatedUser)
-> Generic FederatedUser
forall x. Rep FederatedUser x -> FederatedUser
forall x. FederatedUser -> Rep FederatedUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FederatedUser x -> FederatedUser
$cfrom :: forall x. FederatedUser -> Rep FederatedUser x
Prelude.Generic)

-- |
-- Create a value of 'FederatedUser' 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', 'federatedUser_principalId' - The unique identifier for the entity that was used to get the
-- credentials.
--
-- 'arn', 'federatedUser_arn' - The Amazon Resource Name (ARN) of the entity that was used to get the
-- credentials.
--
-- 'sessionContext', 'federatedUser_sessionContext' - The details of the session that was created for the credentials,
-- including the entity that issued the session.
--
-- 'accountId', 'federatedUser_accountId' - The unique identifier for the Amazon Web Services account that owns the
-- entity that was used to get the credentials.
--
-- 'accessKeyId', 'federatedUser_accessKeyId' - The Amazon Web Services access key ID that identifies the credentials.
newFederatedUser ::
  FederatedUser
newFederatedUser :: FederatedUser
newFederatedUser =
  FederatedUser' :: Maybe Text
-> Maybe Text
-> Maybe SessionContext
-> Maybe Text
-> Maybe Text
-> FederatedUser
FederatedUser'
    { $sel:principalId:FederatedUser' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:FederatedUser' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionContext:FederatedUser' :: Maybe SessionContext
sessionContext = Maybe SessionContext
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:FederatedUser' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:FederatedUser' :: Maybe Text
accessKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the entity that was used to get the
-- credentials.
federatedUser_principalId :: Lens.Lens' FederatedUser (Prelude.Maybe Prelude.Text)
federatedUser_principalId :: (Maybe Text -> f (Maybe Text)) -> FederatedUser -> f FederatedUser
federatedUser_principalId = (FederatedUser -> Maybe Text)
-> (FederatedUser -> Maybe Text -> FederatedUser)
-> Lens FederatedUser FederatedUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederatedUser' {Maybe Text
principalId :: Maybe Text
$sel:principalId:FederatedUser' :: FederatedUser -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: FederatedUser
s@FederatedUser' {} Maybe Text
a -> FederatedUser
s {$sel:principalId:FederatedUser' :: Maybe Text
principalId = Maybe Text
a} :: FederatedUser)

-- | The Amazon Resource Name (ARN) of the entity that was used to get the
-- credentials.
federatedUser_arn :: Lens.Lens' FederatedUser (Prelude.Maybe Prelude.Text)
federatedUser_arn :: (Maybe Text -> f (Maybe Text)) -> FederatedUser -> f FederatedUser
federatedUser_arn = (FederatedUser -> Maybe Text)
-> (FederatedUser -> Maybe Text -> FederatedUser)
-> Lens FederatedUser FederatedUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederatedUser' {Maybe Text
arn :: Maybe Text
$sel:arn:FederatedUser' :: FederatedUser -> Maybe Text
arn} -> Maybe Text
arn) (\s :: FederatedUser
s@FederatedUser' {} Maybe Text
a -> FederatedUser
s {$sel:arn:FederatedUser' :: Maybe Text
arn = Maybe Text
a} :: FederatedUser)

-- | The details of the session that was created for the credentials,
-- including the entity that issued the session.
federatedUser_sessionContext :: Lens.Lens' FederatedUser (Prelude.Maybe SessionContext)
federatedUser_sessionContext :: (Maybe SessionContext -> f (Maybe SessionContext))
-> FederatedUser -> f FederatedUser
federatedUser_sessionContext = (FederatedUser -> Maybe SessionContext)
-> (FederatedUser -> Maybe SessionContext -> FederatedUser)
-> Lens
     FederatedUser
     FederatedUser
     (Maybe SessionContext)
     (Maybe SessionContext)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederatedUser' {Maybe SessionContext
sessionContext :: Maybe SessionContext
$sel:sessionContext:FederatedUser' :: FederatedUser -> Maybe SessionContext
sessionContext} -> Maybe SessionContext
sessionContext) (\s :: FederatedUser
s@FederatedUser' {} Maybe SessionContext
a -> FederatedUser
s {$sel:sessionContext:FederatedUser' :: Maybe SessionContext
sessionContext = Maybe SessionContext
a} :: FederatedUser)

-- | The unique identifier for the Amazon Web Services account that owns the
-- entity that was used to get the credentials.
federatedUser_accountId :: Lens.Lens' FederatedUser (Prelude.Maybe Prelude.Text)
federatedUser_accountId :: (Maybe Text -> f (Maybe Text)) -> FederatedUser -> f FederatedUser
federatedUser_accountId = (FederatedUser -> Maybe Text)
-> (FederatedUser -> Maybe Text -> FederatedUser)
-> Lens FederatedUser FederatedUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederatedUser' {Maybe Text
accountId :: Maybe Text
$sel:accountId:FederatedUser' :: FederatedUser -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: FederatedUser
s@FederatedUser' {} Maybe Text
a -> FederatedUser
s {$sel:accountId:FederatedUser' :: Maybe Text
accountId = Maybe Text
a} :: FederatedUser)

-- | The Amazon Web Services access key ID that identifies the credentials.
federatedUser_accessKeyId :: Lens.Lens' FederatedUser (Prelude.Maybe Prelude.Text)
federatedUser_accessKeyId :: (Maybe Text -> f (Maybe Text)) -> FederatedUser -> f FederatedUser
federatedUser_accessKeyId = (FederatedUser -> Maybe Text)
-> (FederatedUser -> Maybe Text -> FederatedUser)
-> Lens FederatedUser FederatedUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederatedUser' {Maybe Text
accessKeyId :: Maybe Text
$sel:accessKeyId:FederatedUser' :: FederatedUser -> Maybe Text
accessKeyId} -> Maybe Text
accessKeyId) (\s :: FederatedUser
s@FederatedUser' {} Maybe Text
a -> FederatedUser
s {$sel:accessKeyId:FederatedUser' :: Maybe Text
accessKeyId = Maybe Text
a} :: FederatedUser)

instance Core.FromJSON FederatedUser where
  parseJSON :: Value -> Parser FederatedUser
parseJSON =
    String
-> (Object -> Parser FederatedUser)
-> Value
-> Parser FederatedUser
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FederatedUser"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe SessionContext
-> Maybe Text
-> Maybe Text
-> FederatedUser
FederatedUser'
            (Maybe Text
 -> Maybe Text
 -> Maybe SessionContext
 -> Maybe Text
 -> Maybe Text
 -> FederatedUser)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe SessionContext
      -> Maybe Text
      -> Maybe Text
      -> FederatedUser)
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 SessionContext
   -> Maybe Text
   -> Maybe Text
   -> FederatedUser)
-> Parser (Maybe Text)
-> Parser
     (Maybe SessionContext -> Maybe Text -> Maybe Text -> FederatedUser)
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 SessionContext -> Maybe Text -> Maybe Text -> FederatedUser)
-> Parser (Maybe SessionContext)
-> Parser (Maybe Text -> Maybe Text -> FederatedUser)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SessionContext)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sessionContext")
            Parser (Maybe Text -> Maybe Text -> FederatedUser)
-> Parser (Maybe Text) -> Parser (Maybe Text -> FederatedUser)
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")
            Parser (Maybe Text -> FederatedUser)
-> Parser (Maybe Text) -> Parser FederatedUser
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
"accessKeyId")
      )

instance Prelude.Hashable FederatedUser

instance Prelude.NFData FederatedUser