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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the source and type of temporary security
-- credentials that were issued to an entity.
--
-- /See:/ 'newSessionIssuer' smart constructor.
data SessionIssuer = SessionIssuer'
  { -- | The unique identifier for the entity that was used to get the
    -- credentials.
    SessionIssuer -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the source account, IAM user, or role
    -- that was used to get the credentials.
    SessionIssuer -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name or alias of the user or role that issued the session. This
    -- value is null if the credentials were obtained from a root account that
    -- doesn\'t have an alias.
    SessionIssuer -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the Amazon Web Services account that owns the
    -- entity that was used to get the credentials.
    SessionIssuer -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The source of the temporary security credentials, such as Root, IAMUser,
    -- or Role.
    SessionIssuer -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (SessionIssuer -> SessionIssuer -> Bool
(SessionIssuer -> SessionIssuer -> Bool)
-> (SessionIssuer -> SessionIssuer -> Bool) -> Eq SessionIssuer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionIssuer -> SessionIssuer -> Bool
$c/= :: SessionIssuer -> SessionIssuer -> Bool
== :: SessionIssuer -> SessionIssuer -> Bool
$c== :: SessionIssuer -> SessionIssuer -> Bool
Prelude.Eq, ReadPrec [SessionIssuer]
ReadPrec SessionIssuer
Int -> ReadS SessionIssuer
ReadS [SessionIssuer]
(Int -> ReadS SessionIssuer)
-> ReadS [SessionIssuer]
-> ReadPrec SessionIssuer
-> ReadPrec [SessionIssuer]
-> Read SessionIssuer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionIssuer]
$creadListPrec :: ReadPrec [SessionIssuer]
readPrec :: ReadPrec SessionIssuer
$creadPrec :: ReadPrec SessionIssuer
readList :: ReadS [SessionIssuer]
$creadList :: ReadS [SessionIssuer]
readsPrec :: Int -> ReadS SessionIssuer
$creadsPrec :: Int -> ReadS SessionIssuer
Prelude.Read, Int -> SessionIssuer -> ShowS
[SessionIssuer] -> ShowS
SessionIssuer -> String
(Int -> SessionIssuer -> ShowS)
-> (SessionIssuer -> String)
-> ([SessionIssuer] -> ShowS)
-> Show SessionIssuer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionIssuer] -> ShowS
$cshowList :: [SessionIssuer] -> ShowS
show :: SessionIssuer -> String
$cshow :: SessionIssuer -> String
showsPrec :: Int -> SessionIssuer -> ShowS
$cshowsPrec :: Int -> SessionIssuer -> ShowS
Prelude.Show, (forall x. SessionIssuer -> Rep SessionIssuer x)
-> (forall x. Rep SessionIssuer x -> SessionIssuer)
-> Generic SessionIssuer
forall x. Rep SessionIssuer x -> SessionIssuer
forall x. SessionIssuer -> Rep SessionIssuer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SessionIssuer x -> SessionIssuer
$cfrom :: forall x. SessionIssuer -> Rep SessionIssuer x
Prelude.Generic)

-- |
-- Create a value of 'SessionIssuer' 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', 'sessionIssuer_principalId' - The unique identifier for the entity that was used to get the
-- credentials.
--
-- 'arn', 'sessionIssuer_arn' - The Amazon Resource Name (ARN) of the source account, IAM user, or role
-- that was used to get the credentials.
--
-- 'userName', 'sessionIssuer_userName' - The name or alias of the user or role that issued the session. This
-- value is null if the credentials were obtained from a root account that
-- doesn\'t have an alias.
--
-- 'accountId', 'sessionIssuer_accountId' - The unique identifier for the Amazon Web Services account that owns the
-- entity that was used to get the credentials.
--
-- 'type'', 'sessionIssuer_type' - The source of the temporary security credentials, such as Root, IAMUser,
-- or Role.
newSessionIssuer ::
  SessionIssuer
newSessionIssuer :: SessionIssuer
newSessionIssuer =
  SessionIssuer' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SessionIssuer
SessionIssuer'
    { $sel:principalId:SessionIssuer' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:SessionIssuer' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:SessionIssuer' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:SessionIssuer' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':SessionIssuer' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The Amazon Resource Name (ARN) of the source account, IAM user, or role
-- that was used to get the credentials.
sessionIssuer_arn :: Lens.Lens' SessionIssuer (Prelude.Maybe Prelude.Text)
sessionIssuer_arn :: (Maybe Text -> f (Maybe Text)) -> SessionIssuer -> f SessionIssuer
sessionIssuer_arn = (SessionIssuer -> Maybe Text)
-> (SessionIssuer -> Maybe Text -> SessionIssuer)
-> Lens SessionIssuer SessionIssuer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionIssuer' {Maybe Text
arn :: Maybe Text
$sel:arn:SessionIssuer' :: SessionIssuer -> Maybe Text
arn} -> Maybe Text
arn) (\s :: SessionIssuer
s@SessionIssuer' {} Maybe Text
a -> SessionIssuer
s {$sel:arn:SessionIssuer' :: Maybe Text
arn = Maybe Text
a} :: SessionIssuer)

-- | The name or alias of the user or role that issued the session. This
-- value is null if the credentials were obtained from a root account that
-- doesn\'t have an alias.
sessionIssuer_userName :: Lens.Lens' SessionIssuer (Prelude.Maybe Prelude.Text)
sessionIssuer_userName :: (Maybe Text -> f (Maybe Text)) -> SessionIssuer -> f SessionIssuer
sessionIssuer_userName = (SessionIssuer -> Maybe Text)
-> (SessionIssuer -> Maybe Text -> SessionIssuer)
-> Lens SessionIssuer SessionIssuer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionIssuer' {Maybe Text
userName :: Maybe Text
$sel:userName:SessionIssuer' :: SessionIssuer -> Maybe Text
userName} -> Maybe Text
userName) (\s :: SessionIssuer
s@SessionIssuer' {} Maybe Text
a -> SessionIssuer
s {$sel:userName:SessionIssuer' :: Maybe Text
userName = Maybe Text
a} :: SessionIssuer)

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

-- | The source of the temporary security credentials, such as Root, IAMUser,
-- or Role.
sessionIssuer_type :: Lens.Lens' SessionIssuer (Prelude.Maybe Prelude.Text)
sessionIssuer_type :: (Maybe Text -> f (Maybe Text)) -> SessionIssuer -> f SessionIssuer
sessionIssuer_type = (SessionIssuer -> Maybe Text)
-> (SessionIssuer -> Maybe Text -> SessionIssuer)
-> Lens SessionIssuer SessionIssuer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionIssuer' {Maybe Text
type' :: Maybe Text
$sel:type':SessionIssuer' :: SessionIssuer -> Maybe Text
type'} -> Maybe Text
type') (\s :: SessionIssuer
s@SessionIssuer' {} Maybe Text
a -> SessionIssuer
s {$sel:type':SessionIssuer' :: Maybe Text
type' = Maybe Text
a} :: SessionIssuer)

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

instance Prelude.Hashable SessionIssuer

instance Prelude.NFData SessionIssuer