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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SessionContextAttributes
import Amazonka.MacieV2.Types.SessionIssuer
import qualified Amazonka.Prelude as Prelude

-- | Provides information about a session that was created for an entity that
-- performed an action by using temporary security credentials.
--
-- /See:/ 'newSessionContext' smart constructor.
data SessionContext = SessionContext'
  { -- | The date and time when the credentials were issued, and whether the
    -- credentials were authenticated with a multi-factor authentication (MFA)
    -- device.
    SessionContext -> Maybe SessionContextAttributes
attributes :: Prelude.Maybe SessionContextAttributes,
    -- | The source and type of credentials that were issued to the entity.
    SessionContext -> Maybe SessionIssuer
sessionIssuer :: Prelude.Maybe SessionIssuer
  }
  deriving (SessionContext -> SessionContext -> Bool
(SessionContext -> SessionContext -> Bool)
-> (SessionContext -> SessionContext -> Bool) -> Eq SessionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionContext -> SessionContext -> Bool
$c/= :: SessionContext -> SessionContext -> Bool
== :: SessionContext -> SessionContext -> Bool
$c== :: SessionContext -> SessionContext -> Bool
Prelude.Eq, ReadPrec [SessionContext]
ReadPrec SessionContext
Int -> ReadS SessionContext
ReadS [SessionContext]
(Int -> ReadS SessionContext)
-> ReadS [SessionContext]
-> ReadPrec SessionContext
-> ReadPrec [SessionContext]
-> Read SessionContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionContext]
$creadListPrec :: ReadPrec [SessionContext]
readPrec :: ReadPrec SessionContext
$creadPrec :: ReadPrec SessionContext
readList :: ReadS [SessionContext]
$creadList :: ReadS [SessionContext]
readsPrec :: Int -> ReadS SessionContext
$creadsPrec :: Int -> ReadS SessionContext
Prelude.Read, Int -> SessionContext -> ShowS
[SessionContext] -> ShowS
SessionContext -> String
(Int -> SessionContext -> ShowS)
-> (SessionContext -> String)
-> ([SessionContext] -> ShowS)
-> Show SessionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionContext] -> ShowS
$cshowList :: [SessionContext] -> ShowS
show :: SessionContext -> String
$cshow :: SessionContext -> String
showsPrec :: Int -> SessionContext -> ShowS
$cshowsPrec :: Int -> SessionContext -> ShowS
Prelude.Show, (forall x. SessionContext -> Rep SessionContext x)
-> (forall x. Rep SessionContext x -> SessionContext)
-> Generic SessionContext
forall x. Rep SessionContext x -> SessionContext
forall x. SessionContext -> Rep SessionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SessionContext x -> SessionContext
$cfrom :: forall x. SessionContext -> Rep SessionContext x
Prelude.Generic)

-- |
-- Create a value of 'SessionContext' 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:
--
-- 'attributes', 'sessionContext_attributes' - The date and time when the credentials were issued, and whether the
-- credentials were authenticated with a multi-factor authentication (MFA)
-- device.
--
-- 'sessionIssuer', 'sessionContext_sessionIssuer' - The source and type of credentials that were issued to the entity.
newSessionContext ::
  SessionContext
newSessionContext :: SessionContext
newSessionContext =
  SessionContext' :: Maybe SessionContextAttributes
-> Maybe SessionIssuer -> SessionContext
SessionContext'
    { $sel:attributes:SessionContext' :: Maybe SessionContextAttributes
attributes = Maybe SessionContextAttributes
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionIssuer:SessionContext' :: Maybe SessionIssuer
sessionIssuer = Maybe SessionIssuer
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the credentials were issued, and whether the
-- credentials were authenticated with a multi-factor authentication (MFA)
-- device.
sessionContext_attributes :: Lens.Lens' SessionContext (Prelude.Maybe SessionContextAttributes)
sessionContext_attributes :: (Maybe SessionContextAttributes
 -> f (Maybe SessionContextAttributes))
-> SessionContext -> f SessionContext
sessionContext_attributes = (SessionContext -> Maybe SessionContextAttributes)
-> (SessionContext
    -> Maybe SessionContextAttributes -> SessionContext)
-> Lens
     SessionContext
     SessionContext
     (Maybe SessionContextAttributes)
     (Maybe SessionContextAttributes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionContext' {Maybe SessionContextAttributes
attributes :: Maybe SessionContextAttributes
$sel:attributes:SessionContext' :: SessionContext -> Maybe SessionContextAttributes
attributes} -> Maybe SessionContextAttributes
attributes) (\s :: SessionContext
s@SessionContext' {} Maybe SessionContextAttributes
a -> SessionContext
s {$sel:attributes:SessionContext' :: Maybe SessionContextAttributes
attributes = Maybe SessionContextAttributes
a} :: SessionContext)

-- | The source and type of credentials that were issued to the entity.
sessionContext_sessionIssuer :: Lens.Lens' SessionContext (Prelude.Maybe SessionIssuer)
sessionContext_sessionIssuer :: (Maybe SessionIssuer -> f (Maybe SessionIssuer))
-> SessionContext -> f SessionContext
sessionContext_sessionIssuer = (SessionContext -> Maybe SessionIssuer)
-> (SessionContext -> Maybe SessionIssuer -> SessionContext)
-> Lens
     SessionContext
     SessionContext
     (Maybe SessionIssuer)
     (Maybe SessionIssuer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionContext' {Maybe SessionIssuer
sessionIssuer :: Maybe SessionIssuer
$sel:sessionIssuer:SessionContext' :: SessionContext -> Maybe SessionIssuer
sessionIssuer} -> Maybe SessionIssuer
sessionIssuer) (\s :: SessionContext
s@SessionContext' {} Maybe SessionIssuer
a -> SessionContext
s {$sel:sessionIssuer:SessionContext' :: Maybe SessionIssuer
sessionIssuer = Maybe SessionIssuer
a} :: SessionContext)

instance Core.FromJSON SessionContext where
  parseJSON :: Value -> Parser SessionContext
parseJSON =
    String
-> (Object -> Parser SessionContext)
-> Value
-> Parser SessionContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SessionContext"
      ( \Object
x ->
          Maybe SessionContextAttributes
-> Maybe SessionIssuer -> SessionContext
SessionContext'
            (Maybe SessionContextAttributes
 -> Maybe SessionIssuer -> SessionContext)
-> Parser (Maybe SessionContextAttributes)
-> Parser (Maybe SessionIssuer -> SessionContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SessionContextAttributes)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes")
            Parser (Maybe SessionIssuer -> SessionContext)
-> Parser (Maybe SessionIssuer) -> Parser SessionContext
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SessionIssuer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sessionIssuer")
      )

instance Prelude.Hashable SessionContext

instance Prelude.NFData SessionContext