{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MacieV2.Types.SessionIssuer where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 Amazon Web Services account that owns the
    -- entity that was used to get the credentials.
    SessionIssuer -> Maybe Text
accountId :: 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 unique identifier for the entity that was used to get the
    -- credentials.
    SessionIssuer -> Maybe Text
principalId :: 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,
    -- | 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
  }
  deriving (SessionIssuer -> SessionIssuer -> Bool
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]
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
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. 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:
--
-- 'accountId', 'sessionIssuer_accountId' - The unique identifier for the Amazon Web Services account that owns 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.
--
-- 'principalId', 'sessionIssuer_principalId' - The unique identifier for 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.
--
-- '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.
newSessionIssuer ::
  SessionIssuer
newSessionIssuer :: SessionIssuer
newSessionIssuer =
  SessionIssuer'
    { $sel:accountId:SessionIssuer' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:SessionIssuer' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:principalId:SessionIssuer' :: Maybe Text
principalId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':SessionIssuer' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:userName:SessionIssuer' :: Maybe Text
userName = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' SessionIssuer (Maybe Text)
sessionIssuer_accountId = 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 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 :: Lens' SessionIssuer (Maybe Text)
sessionIssuer_arn = 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 unique identifier for the entity that was used to get the
-- credentials.
sessionIssuer_principalId :: Lens.Lens' SessionIssuer (Prelude.Maybe Prelude.Text)
sessionIssuer_principalId :: Lens' SessionIssuer (Maybe Text)
sessionIssuer_principalId = 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 source of the temporary security credentials, such as Root, IAMUser,
-- or Role.
sessionIssuer_type :: Lens.Lens' SessionIssuer (Prelude.Maybe Prelude.Text)
sessionIssuer_type :: Lens' SessionIssuer (Maybe Text)
sessionIssuer_type = 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)

-- | 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 :: Lens' SessionIssuer (Maybe Text)
sessionIssuer_userName = 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)

instance Data.FromJSON SessionIssuer where
  parseJSON :: Value -> Parser SessionIssuer
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SessionIssuer"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SessionIssuer
SessionIssuer'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"accountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"principalId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"userName")
      )

instance Prelude.Hashable SessionIssuer where
  hashWithSalt :: Int -> SessionIssuer -> Int
hashWithSalt Int
_salt SessionIssuer' {Maybe Text
userName :: Maybe Text
type' :: Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:userName:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:type':SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:principalId:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:arn:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:accountId:SessionIssuer' :: SessionIssuer -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principalId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName

instance Prelude.NFData SessionIssuer where
  rnf :: SessionIssuer -> ()
rnf SessionIssuer' {Maybe Text
userName :: Maybe Text
type' :: Maybe Text
principalId :: Maybe Text
arn :: Maybe Text
accountId :: Maybe Text
$sel:userName:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:type':SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:principalId:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:arn:SessionIssuer' :: SessionIssuer -> Maybe Text
$sel:accountId:SessionIssuer' :: SessionIssuer -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principalId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userName