{-# 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.SessionContextAttributes
-- 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.SessionContextAttributes 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 context in which temporary security
-- credentials were issued to an entity.
--
-- /See:/ 'newSessionContextAttributes' smart constructor.
data SessionContextAttributes = SessionContextAttributes'
  { -- | The date and time, in UTC and ISO 8601 format, when the credentials were
    -- issued.
    SessionContextAttributes -> Maybe ISO8601
creationDate :: Prelude.Maybe Data.ISO8601,
    -- | Specifies whether the credentials were authenticated with a multi-factor
    -- authentication (MFA) device.
    SessionContextAttributes -> Maybe Bool
mfaAuthenticated :: Prelude.Maybe Prelude.Bool
  }
  deriving (SessionContextAttributes -> SessionContextAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionContextAttributes -> SessionContextAttributes -> Bool
$c/= :: SessionContextAttributes -> SessionContextAttributes -> Bool
== :: SessionContextAttributes -> SessionContextAttributes -> Bool
$c== :: SessionContextAttributes -> SessionContextAttributes -> Bool
Prelude.Eq, ReadPrec [SessionContextAttributes]
ReadPrec SessionContextAttributes
Int -> ReadS SessionContextAttributes
ReadS [SessionContextAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionContextAttributes]
$creadListPrec :: ReadPrec [SessionContextAttributes]
readPrec :: ReadPrec SessionContextAttributes
$creadPrec :: ReadPrec SessionContextAttributes
readList :: ReadS [SessionContextAttributes]
$creadList :: ReadS [SessionContextAttributes]
readsPrec :: Int -> ReadS SessionContextAttributes
$creadsPrec :: Int -> ReadS SessionContextAttributes
Prelude.Read, Int -> SessionContextAttributes -> ShowS
[SessionContextAttributes] -> ShowS
SessionContextAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionContextAttributes] -> ShowS
$cshowList :: [SessionContextAttributes] -> ShowS
show :: SessionContextAttributes -> String
$cshow :: SessionContextAttributes -> String
showsPrec :: Int -> SessionContextAttributes -> ShowS
$cshowsPrec :: Int -> SessionContextAttributes -> ShowS
Prelude.Show, forall x.
Rep SessionContextAttributes x -> SessionContextAttributes
forall x.
SessionContextAttributes -> Rep SessionContextAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SessionContextAttributes x -> SessionContextAttributes
$cfrom :: forall x.
SessionContextAttributes -> Rep SessionContextAttributes x
Prelude.Generic)

-- |
-- Create a value of 'SessionContextAttributes' 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:
--
-- 'creationDate', 'sessionContextAttributes_creationDate' - The date and time, in UTC and ISO 8601 format, when the credentials were
-- issued.
--
-- 'mfaAuthenticated', 'sessionContextAttributes_mfaAuthenticated' - Specifies whether the credentials were authenticated with a multi-factor
-- authentication (MFA) device.
newSessionContextAttributes ::
  SessionContextAttributes
newSessionContextAttributes :: SessionContextAttributes
newSessionContextAttributes =
  SessionContextAttributes'
    { $sel:creationDate:SessionContextAttributes' :: Maybe ISO8601
creationDate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:mfaAuthenticated:SessionContextAttributes' :: Maybe Bool
mfaAuthenticated = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time, in UTC and ISO 8601 format, when the credentials were
-- issued.
sessionContextAttributes_creationDate :: Lens.Lens' SessionContextAttributes (Prelude.Maybe Prelude.UTCTime)
sessionContextAttributes_creationDate :: Lens' SessionContextAttributes (Maybe UTCTime)
sessionContextAttributes_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionContextAttributes' {Maybe ISO8601
creationDate :: Maybe ISO8601
$sel:creationDate:SessionContextAttributes' :: SessionContextAttributes -> Maybe ISO8601
creationDate} -> Maybe ISO8601
creationDate) (\s :: SessionContextAttributes
s@SessionContextAttributes' {} Maybe ISO8601
a -> SessionContextAttributes
s {$sel:creationDate:SessionContextAttributes' :: Maybe ISO8601
creationDate = Maybe ISO8601
a} :: SessionContextAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Specifies whether the credentials were authenticated with a multi-factor
-- authentication (MFA) device.
sessionContextAttributes_mfaAuthenticated :: Lens.Lens' SessionContextAttributes (Prelude.Maybe Prelude.Bool)
sessionContextAttributes_mfaAuthenticated :: Lens' SessionContextAttributes (Maybe Bool)
sessionContextAttributes_mfaAuthenticated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionContextAttributes' {Maybe Bool
mfaAuthenticated :: Maybe Bool
$sel:mfaAuthenticated:SessionContextAttributes' :: SessionContextAttributes -> Maybe Bool
mfaAuthenticated} -> Maybe Bool
mfaAuthenticated) (\s :: SessionContextAttributes
s@SessionContextAttributes' {} Maybe Bool
a -> SessionContextAttributes
s {$sel:mfaAuthenticated:SessionContextAttributes' :: Maybe Bool
mfaAuthenticated = Maybe Bool
a} :: SessionContextAttributes)

instance Data.FromJSON SessionContextAttributes where
  parseJSON :: Value -> Parser SessionContextAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SessionContextAttributes"
      ( \Object
x ->
          Maybe ISO8601 -> Maybe Bool -> SessionContextAttributes
SessionContextAttributes'
            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
"creationDate")
            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
"mfaAuthenticated")
      )

instance Prelude.Hashable SessionContextAttributes where
  hashWithSalt :: Int -> SessionContextAttributes -> Int
hashWithSalt Int
_salt SessionContextAttributes' {Maybe Bool
Maybe ISO8601
mfaAuthenticated :: Maybe Bool
creationDate :: Maybe ISO8601
$sel:mfaAuthenticated:SessionContextAttributes' :: SessionContextAttributes -> Maybe Bool
$sel:creationDate:SessionContextAttributes' :: SessionContextAttributes -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
mfaAuthenticated

instance Prelude.NFData SessionContextAttributes where
  rnf :: SessionContextAttributes -> ()
rnf SessionContextAttributes' {Maybe Bool
Maybe ISO8601
mfaAuthenticated :: Maybe Bool
creationDate :: Maybe ISO8601
$sel:mfaAuthenticated:SessionContextAttributes' :: SessionContextAttributes -> Maybe Bool
$sel:creationDate:SessionContextAttributes' :: SessionContextAttributes -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
mfaAuthenticated