{-# 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.SecurityHub.Types.AwsIamAccessKeySessionContextAttributes
-- 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.SecurityHub.Types.AwsIamAccessKeySessionContextAttributes where

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

-- | Attributes of the session that the key was used for.
--
-- /See:/ 'newAwsIamAccessKeySessionContextAttributes' smart constructor.
data AwsIamAccessKeySessionContextAttributes = AwsIamAccessKeySessionContextAttributes'
  { -- | Indicates when the session was created.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    AwsIamAccessKeySessionContextAttributes -> Maybe Text
creationDate :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the session used multi-factor authentication (MFA).
    AwsIamAccessKeySessionContextAttributes -> Maybe Bool
mfaAuthenticated :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsIamAccessKeySessionContextAttributes
-> AwsIamAccessKeySessionContextAttributes -> Bool
(AwsIamAccessKeySessionContextAttributes
 -> AwsIamAccessKeySessionContextAttributes -> Bool)
-> (AwsIamAccessKeySessionContextAttributes
    -> AwsIamAccessKeySessionContextAttributes -> Bool)
-> Eq AwsIamAccessKeySessionContextAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamAccessKeySessionContextAttributes
-> AwsIamAccessKeySessionContextAttributes -> Bool
$c/= :: AwsIamAccessKeySessionContextAttributes
-> AwsIamAccessKeySessionContextAttributes -> Bool
== :: AwsIamAccessKeySessionContextAttributes
-> AwsIamAccessKeySessionContextAttributes -> Bool
$c== :: AwsIamAccessKeySessionContextAttributes
-> AwsIamAccessKeySessionContextAttributes -> Bool
Prelude.Eq, ReadPrec [AwsIamAccessKeySessionContextAttributes]
ReadPrec AwsIamAccessKeySessionContextAttributes
Int -> ReadS AwsIamAccessKeySessionContextAttributes
ReadS [AwsIamAccessKeySessionContextAttributes]
(Int -> ReadS AwsIamAccessKeySessionContextAttributes)
-> ReadS [AwsIamAccessKeySessionContextAttributes]
-> ReadPrec AwsIamAccessKeySessionContextAttributes
-> ReadPrec [AwsIamAccessKeySessionContextAttributes]
-> Read AwsIamAccessKeySessionContextAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamAccessKeySessionContextAttributes]
$creadListPrec :: ReadPrec [AwsIamAccessKeySessionContextAttributes]
readPrec :: ReadPrec AwsIamAccessKeySessionContextAttributes
$creadPrec :: ReadPrec AwsIamAccessKeySessionContextAttributes
readList :: ReadS [AwsIamAccessKeySessionContextAttributes]
$creadList :: ReadS [AwsIamAccessKeySessionContextAttributes]
readsPrec :: Int -> ReadS AwsIamAccessKeySessionContextAttributes
$creadsPrec :: Int -> ReadS AwsIamAccessKeySessionContextAttributes
Prelude.Read, Int -> AwsIamAccessKeySessionContextAttributes -> ShowS
[AwsIamAccessKeySessionContextAttributes] -> ShowS
AwsIamAccessKeySessionContextAttributes -> String
(Int -> AwsIamAccessKeySessionContextAttributes -> ShowS)
-> (AwsIamAccessKeySessionContextAttributes -> String)
-> ([AwsIamAccessKeySessionContextAttributes] -> ShowS)
-> Show AwsIamAccessKeySessionContextAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamAccessKeySessionContextAttributes] -> ShowS
$cshowList :: [AwsIamAccessKeySessionContextAttributes] -> ShowS
show :: AwsIamAccessKeySessionContextAttributes -> String
$cshow :: AwsIamAccessKeySessionContextAttributes -> String
showsPrec :: Int -> AwsIamAccessKeySessionContextAttributes -> ShowS
$cshowsPrec :: Int -> AwsIamAccessKeySessionContextAttributes -> ShowS
Prelude.Show, (forall x.
 AwsIamAccessKeySessionContextAttributes
 -> Rep AwsIamAccessKeySessionContextAttributes x)
-> (forall x.
    Rep AwsIamAccessKeySessionContextAttributes x
    -> AwsIamAccessKeySessionContextAttributes)
-> Generic AwsIamAccessKeySessionContextAttributes
forall x.
Rep AwsIamAccessKeySessionContextAttributes x
-> AwsIamAccessKeySessionContextAttributes
forall x.
AwsIamAccessKeySessionContextAttributes
-> Rep AwsIamAccessKeySessionContextAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsIamAccessKeySessionContextAttributes x
-> AwsIamAccessKeySessionContextAttributes
$cfrom :: forall x.
AwsIamAccessKeySessionContextAttributes
-> Rep AwsIamAccessKeySessionContextAttributes x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamAccessKeySessionContextAttributes' 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', 'awsIamAccessKeySessionContextAttributes_creationDate' - Indicates when the session was created.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
--
-- 'mfaAuthenticated', 'awsIamAccessKeySessionContextAttributes_mfaAuthenticated' - Indicates whether the session used multi-factor authentication (MFA).
newAwsIamAccessKeySessionContextAttributes ::
  AwsIamAccessKeySessionContextAttributes
newAwsIamAccessKeySessionContextAttributes :: AwsIamAccessKeySessionContextAttributes
newAwsIamAccessKeySessionContextAttributes =
  AwsIamAccessKeySessionContextAttributes' :: Maybe Text -> Maybe Bool -> AwsIamAccessKeySessionContextAttributes
AwsIamAccessKeySessionContextAttributes'
    { $sel:creationDate:AwsIamAccessKeySessionContextAttributes' :: Maybe Text
creationDate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mfaAuthenticated:AwsIamAccessKeySessionContextAttributes' :: Maybe Bool
mfaAuthenticated = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates when the session was created.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
awsIamAccessKeySessionContextAttributes_creationDate :: Lens.Lens' AwsIamAccessKeySessionContextAttributes (Prelude.Maybe Prelude.Text)
awsIamAccessKeySessionContextAttributes_creationDate :: (Maybe Text -> f (Maybe Text))
-> AwsIamAccessKeySessionContextAttributes
-> f AwsIamAccessKeySessionContextAttributes
awsIamAccessKeySessionContextAttributes_creationDate = (AwsIamAccessKeySessionContextAttributes -> Maybe Text)
-> (AwsIamAccessKeySessionContextAttributes
    -> Maybe Text -> AwsIamAccessKeySessionContextAttributes)
-> Lens
     AwsIamAccessKeySessionContextAttributes
     AwsIamAccessKeySessionContextAttributes
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamAccessKeySessionContextAttributes' {Maybe Text
creationDate :: Maybe Text
$sel:creationDate:AwsIamAccessKeySessionContextAttributes' :: AwsIamAccessKeySessionContextAttributes -> Maybe Text
creationDate} -> Maybe Text
creationDate) (\s :: AwsIamAccessKeySessionContextAttributes
s@AwsIamAccessKeySessionContextAttributes' {} Maybe Text
a -> AwsIamAccessKeySessionContextAttributes
s {$sel:creationDate:AwsIamAccessKeySessionContextAttributes' :: Maybe Text
creationDate = Maybe Text
a} :: AwsIamAccessKeySessionContextAttributes)

-- | Indicates whether the session used multi-factor authentication (MFA).
awsIamAccessKeySessionContextAttributes_mfaAuthenticated :: Lens.Lens' AwsIamAccessKeySessionContextAttributes (Prelude.Maybe Prelude.Bool)
awsIamAccessKeySessionContextAttributes_mfaAuthenticated :: (Maybe Bool -> f (Maybe Bool))
-> AwsIamAccessKeySessionContextAttributes
-> f AwsIamAccessKeySessionContextAttributes
awsIamAccessKeySessionContextAttributes_mfaAuthenticated = (AwsIamAccessKeySessionContextAttributes -> Maybe Bool)
-> (AwsIamAccessKeySessionContextAttributes
    -> Maybe Bool -> AwsIamAccessKeySessionContextAttributes)
-> Lens
     AwsIamAccessKeySessionContextAttributes
     AwsIamAccessKeySessionContextAttributes
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamAccessKeySessionContextAttributes' {Maybe Bool
mfaAuthenticated :: Maybe Bool
$sel:mfaAuthenticated:AwsIamAccessKeySessionContextAttributes' :: AwsIamAccessKeySessionContextAttributes -> Maybe Bool
mfaAuthenticated} -> Maybe Bool
mfaAuthenticated) (\s :: AwsIamAccessKeySessionContextAttributes
s@AwsIamAccessKeySessionContextAttributes' {} Maybe Bool
a -> AwsIamAccessKeySessionContextAttributes
s {$sel:mfaAuthenticated:AwsIamAccessKeySessionContextAttributes' :: Maybe Bool
mfaAuthenticated = Maybe Bool
a} :: AwsIamAccessKeySessionContextAttributes)

instance
  Core.FromJSON
    AwsIamAccessKeySessionContextAttributes
  where
  parseJSON :: Value -> Parser AwsIamAccessKeySessionContextAttributes
parseJSON =
    String
-> (Object -> Parser AwsIamAccessKeySessionContextAttributes)
-> Value
-> Parser AwsIamAccessKeySessionContextAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsIamAccessKeySessionContextAttributes"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> AwsIamAccessKeySessionContextAttributes
AwsIamAccessKeySessionContextAttributes'
            (Maybe Text
 -> Maybe Bool -> AwsIamAccessKeySessionContextAttributes)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> AwsIamAccessKeySessionContextAttributes)
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
"CreationDate")
            Parser (Maybe Bool -> AwsIamAccessKeySessionContextAttributes)
-> Parser (Maybe Bool)
-> Parser AwsIamAccessKeySessionContextAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MfaAuthenticated")
      )

instance
  Prelude.Hashable
    AwsIamAccessKeySessionContextAttributes

instance
  Prelude.NFData
    AwsIamAccessKeySessionContextAttributes

instance
  Core.ToJSON
    AwsIamAccessKeySessionContextAttributes
  where
  toJSON :: AwsIamAccessKeySessionContextAttributes -> Value
toJSON AwsIamAccessKeySessionContextAttributes' {Maybe Bool
Maybe Text
mfaAuthenticated :: Maybe Bool
creationDate :: Maybe Text
$sel:mfaAuthenticated:AwsIamAccessKeySessionContextAttributes' :: AwsIamAccessKeySessionContextAttributes -> Maybe Bool
$sel:creationDate:AwsIamAccessKeySessionContextAttributes' :: AwsIamAccessKeySessionContextAttributes -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CreationDate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
creationDate,
            (Text
"MfaAuthenticated" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
mfaAuthenticated
          ]
      )