{-# 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.AssumedRole
-- 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.AssumedRole 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 AssumeRole operation of the Security
-- Token Service (STS) API.
--
-- /See:/ 'newAssumedRole' smart constructor.
data AssumedRole = AssumedRole'
  { -- | The unique identifier for the entity that was used to get the
    -- credentials.
    AssumedRole -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the entity that was used to get the
    -- credentials.
    AssumedRole -> 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.
    AssumedRole -> 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.
    AssumedRole -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services access key ID that identifies the credentials.
    AssumedRole -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (AssumedRole -> AssumedRole -> Bool
(AssumedRole -> AssumedRole -> Bool)
-> (AssumedRole -> AssumedRole -> Bool) -> Eq AssumedRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssumedRole -> AssumedRole -> Bool
$c/= :: AssumedRole -> AssumedRole -> Bool
== :: AssumedRole -> AssumedRole -> Bool
$c== :: AssumedRole -> AssumedRole -> Bool
Prelude.Eq, ReadPrec [AssumedRole]
ReadPrec AssumedRole
Int -> ReadS AssumedRole
ReadS [AssumedRole]
(Int -> ReadS AssumedRole)
-> ReadS [AssumedRole]
-> ReadPrec AssumedRole
-> ReadPrec [AssumedRole]
-> Read AssumedRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssumedRole]
$creadListPrec :: ReadPrec [AssumedRole]
readPrec :: ReadPrec AssumedRole
$creadPrec :: ReadPrec AssumedRole
readList :: ReadS [AssumedRole]
$creadList :: ReadS [AssumedRole]
readsPrec :: Int -> ReadS AssumedRole
$creadsPrec :: Int -> ReadS AssumedRole
Prelude.Read, Int -> AssumedRole -> ShowS
[AssumedRole] -> ShowS
AssumedRole -> String
(Int -> AssumedRole -> ShowS)
-> (AssumedRole -> String)
-> ([AssumedRole] -> ShowS)
-> Show AssumedRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssumedRole] -> ShowS
$cshowList :: [AssumedRole] -> ShowS
show :: AssumedRole -> String
$cshow :: AssumedRole -> String
showsPrec :: Int -> AssumedRole -> ShowS
$cshowsPrec :: Int -> AssumedRole -> ShowS
Prelude.Show, (forall x. AssumedRole -> Rep AssumedRole x)
-> (forall x. Rep AssumedRole x -> AssumedRole)
-> Generic AssumedRole
forall x. Rep AssumedRole x -> AssumedRole
forall x. AssumedRole -> Rep AssumedRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssumedRole x -> AssumedRole
$cfrom :: forall x. AssumedRole -> Rep AssumedRole x
Prelude.Generic)

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

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

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

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

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

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

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

instance Prelude.NFData AssumedRole