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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsIamAccessKeySessionContextAttributes
import Amazonka.SecurityHub.Types.AwsIamAccessKeySessionContextSessionIssuer

-- | Provides information about the session that the key was used for.
--
-- /See:/ 'newAwsIamAccessKeySessionContext' smart constructor.
data AwsIamAccessKeySessionContext = AwsIamAccessKeySessionContext'
  { -- | Attributes of the session that the key was used for.
    AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextAttributes
attributes :: Prelude.Maybe AwsIamAccessKeySessionContextAttributes,
    -- | Information about the entity that created the session.
    AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer :: Prelude.Maybe AwsIamAccessKeySessionContextSessionIssuer
  }
  deriving (AwsIamAccessKeySessionContext
-> AwsIamAccessKeySessionContext -> Bool
(AwsIamAccessKeySessionContext
 -> AwsIamAccessKeySessionContext -> Bool)
-> (AwsIamAccessKeySessionContext
    -> AwsIamAccessKeySessionContext -> Bool)
-> Eq AwsIamAccessKeySessionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamAccessKeySessionContext
-> AwsIamAccessKeySessionContext -> Bool
$c/= :: AwsIamAccessKeySessionContext
-> AwsIamAccessKeySessionContext -> Bool
== :: AwsIamAccessKeySessionContext
-> AwsIamAccessKeySessionContext -> Bool
$c== :: AwsIamAccessKeySessionContext
-> AwsIamAccessKeySessionContext -> Bool
Prelude.Eq, ReadPrec [AwsIamAccessKeySessionContext]
ReadPrec AwsIamAccessKeySessionContext
Int -> ReadS AwsIamAccessKeySessionContext
ReadS [AwsIamAccessKeySessionContext]
(Int -> ReadS AwsIamAccessKeySessionContext)
-> ReadS [AwsIamAccessKeySessionContext]
-> ReadPrec AwsIamAccessKeySessionContext
-> ReadPrec [AwsIamAccessKeySessionContext]
-> Read AwsIamAccessKeySessionContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamAccessKeySessionContext]
$creadListPrec :: ReadPrec [AwsIamAccessKeySessionContext]
readPrec :: ReadPrec AwsIamAccessKeySessionContext
$creadPrec :: ReadPrec AwsIamAccessKeySessionContext
readList :: ReadS [AwsIamAccessKeySessionContext]
$creadList :: ReadS [AwsIamAccessKeySessionContext]
readsPrec :: Int -> ReadS AwsIamAccessKeySessionContext
$creadsPrec :: Int -> ReadS AwsIamAccessKeySessionContext
Prelude.Read, Int -> AwsIamAccessKeySessionContext -> ShowS
[AwsIamAccessKeySessionContext] -> ShowS
AwsIamAccessKeySessionContext -> String
(Int -> AwsIamAccessKeySessionContext -> ShowS)
-> (AwsIamAccessKeySessionContext -> String)
-> ([AwsIamAccessKeySessionContext] -> ShowS)
-> Show AwsIamAccessKeySessionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamAccessKeySessionContext] -> ShowS
$cshowList :: [AwsIamAccessKeySessionContext] -> ShowS
show :: AwsIamAccessKeySessionContext -> String
$cshow :: AwsIamAccessKeySessionContext -> String
showsPrec :: Int -> AwsIamAccessKeySessionContext -> ShowS
$cshowsPrec :: Int -> AwsIamAccessKeySessionContext -> ShowS
Prelude.Show, (forall x.
 AwsIamAccessKeySessionContext
 -> Rep AwsIamAccessKeySessionContext x)
-> (forall x.
    Rep AwsIamAccessKeySessionContext x
    -> AwsIamAccessKeySessionContext)
-> Generic AwsIamAccessKeySessionContext
forall x.
Rep AwsIamAccessKeySessionContext x
-> AwsIamAccessKeySessionContext
forall x.
AwsIamAccessKeySessionContext
-> Rep AwsIamAccessKeySessionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsIamAccessKeySessionContext x
-> AwsIamAccessKeySessionContext
$cfrom :: forall x.
AwsIamAccessKeySessionContext
-> Rep AwsIamAccessKeySessionContext x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamAccessKeySessionContext' 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', 'awsIamAccessKeySessionContext_attributes' - Attributes of the session that the key was used for.
--
-- 'sessionIssuer', 'awsIamAccessKeySessionContext_sessionIssuer' - Information about the entity that created the session.
newAwsIamAccessKeySessionContext ::
  AwsIamAccessKeySessionContext
newAwsIamAccessKeySessionContext :: AwsIamAccessKeySessionContext
newAwsIamAccessKeySessionContext =
  AwsIamAccessKeySessionContext' :: Maybe AwsIamAccessKeySessionContextAttributes
-> Maybe AwsIamAccessKeySessionContextSessionIssuer
-> AwsIamAccessKeySessionContext
AwsIamAccessKeySessionContext'
    { $sel:attributes:AwsIamAccessKeySessionContext' :: Maybe AwsIamAccessKeySessionContextAttributes
attributes =
        Maybe AwsIamAccessKeySessionContextAttributes
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionIssuer:AwsIamAccessKeySessionContext' :: Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer = Maybe AwsIamAccessKeySessionContextSessionIssuer
forall a. Maybe a
Prelude.Nothing
    }

-- | Attributes of the session that the key was used for.
awsIamAccessKeySessionContext_attributes :: Lens.Lens' AwsIamAccessKeySessionContext (Prelude.Maybe AwsIamAccessKeySessionContextAttributes)
awsIamAccessKeySessionContext_attributes :: (Maybe AwsIamAccessKeySessionContextAttributes
 -> f (Maybe AwsIamAccessKeySessionContextAttributes))
-> AwsIamAccessKeySessionContext -> f AwsIamAccessKeySessionContext
awsIamAccessKeySessionContext_attributes = (AwsIamAccessKeySessionContext
 -> Maybe AwsIamAccessKeySessionContextAttributes)
-> (AwsIamAccessKeySessionContext
    -> Maybe AwsIamAccessKeySessionContextAttributes
    -> AwsIamAccessKeySessionContext)
-> Lens
     AwsIamAccessKeySessionContext
     AwsIamAccessKeySessionContext
     (Maybe AwsIamAccessKeySessionContextAttributes)
     (Maybe AwsIamAccessKeySessionContextAttributes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamAccessKeySessionContext' {Maybe AwsIamAccessKeySessionContextAttributes
attributes :: Maybe AwsIamAccessKeySessionContextAttributes
$sel:attributes:AwsIamAccessKeySessionContext' :: AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextAttributes
attributes} -> Maybe AwsIamAccessKeySessionContextAttributes
attributes) (\s :: AwsIamAccessKeySessionContext
s@AwsIamAccessKeySessionContext' {} Maybe AwsIamAccessKeySessionContextAttributes
a -> AwsIamAccessKeySessionContext
s {$sel:attributes:AwsIamAccessKeySessionContext' :: Maybe AwsIamAccessKeySessionContextAttributes
attributes = Maybe AwsIamAccessKeySessionContextAttributes
a} :: AwsIamAccessKeySessionContext)

-- | Information about the entity that created the session.
awsIamAccessKeySessionContext_sessionIssuer :: Lens.Lens' AwsIamAccessKeySessionContext (Prelude.Maybe AwsIamAccessKeySessionContextSessionIssuer)
awsIamAccessKeySessionContext_sessionIssuer :: (Maybe AwsIamAccessKeySessionContextSessionIssuer
 -> f (Maybe AwsIamAccessKeySessionContextSessionIssuer))
-> AwsIamAccessKeySessionContext -> f AwsIamAccessKeySessionContext
awsIamAccessKeySessionContext_sessionIssuer = (AwsIamAccessKeySessionContext
 -> Maybe AwsIamAccessKeySessionContextSessionIssuer)
-> (AwsIamAccessKeySessionContext
    -> Maybe AwsIamAccessKeySessionContextSessionIssuer
    -> AwsIamAccessKeySessionContext)
-> Lens
     AwsIamAccessKeySessionContext
     AwsIamAccessKeySessionContext
     (Maybe AwsIamAccessKeySessionContextSessionIssuer)
     (Maybe AwsIamAccessKeySessionContextSessionIssuer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamAccessKeySessionContext' {Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer :: Maybe AwsIamAccessKeySessionContextSessionIssuer
$sel:sessionIssuer:AwsIamAccessKeySessionContext' :: AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer} -> Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer) (\s :: AwsIamAccessKeySessionContext
s@AwsIamAccessKeySessionContext' {} Maybe AwsIamAccessKeySessionContextSessionIssuer
a -> AwsIamAccessKeySessionContext
s {$sel:sessionIssuer:AwsIamAccessKeySessionContext' :: Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer = Maybe AwsIamAccessKeySessionContextSessionIssuer
a} :: AwsIamAccessKeySessionContext)

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

instance
  Prelude.Hashable
    AwsIamAccessKeySessionContext

instance Prelude.NFData AwsIamAccessKeySessionContext

instance Core.ToJSON AwsIamAccessKeySessionContext where
  toJSON :: AwsIamAccessKeySessionContext -> Value
toJSON AwsIamAccessKeySessionContext' {Maybe AwsIamAccessKeySessionContextAttributes
Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer :: Maybe AwsIamAccessKeySessionContextSessionIssuer
attributes :: Maybe AwsIamAccessKeySessionContextAttributes
$sel:sessionIssuer:AwsIamAccessKeySessionContext' :: AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextSessionIssuer
$sel:attributes:AwsIamAccessKeySessionContext' :: AwsIamAccessKeySessionContext
-> Maybe AwsIamAccessKeySessionContextAttributes
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Attributes" Text -> AwsIamAccessKeySessionContextAttributes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsIamAccessKeySessionContextAttributes -> Pair)
-> Maybe AwsIamAccessKeySessionContextAttributes -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsIamAccessKeySessionContextAttributes
attributes,
            (Text
"SessionIssuer" Text -> AwsIamAccessKeySessionContextSessionIssuer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsIamAccessKeySessionContextSessionIssuer -> Pair)
-> Maybe AwsIamAccessKeySessionContextSessionIssuer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsIamAccessKeySessionContextSessionIssuer
sessionIssuer
          ]
      )