{-# 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.IAM.Types.TrackedActionLastAccessed
-- 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.IAM.Types.TrackedActionLastAccessed where

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

-- | Contains details about the most recent attempt to access an action
-- within the service.
--
-- This data type is used as a response element in the
-- GetServiceLastAccessedDetails operation.
--
-- /See:/ 'newTrackedActionLastAccessed' smart constructor.
data TrackedActionLastAccessed = TrackedActionLastAccessed'
  { -- | The date and time,
    -- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when an
    -- authenticated entity most recently attempted to access the tracked
    -- service. Amazon Web Services does not report unauthenticated requests.
    --
    -- This field is null if no IAM entities attempted to access the service
    -- within the
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
    TrackedActionLastAccessed -> Maybe ISO8601
lastAccessedTime :: Prelude.Maybe Core.ISO8601,
    -- | The name of the tracked action to which access was attempted. Tracked
    -- actions are actions that report activity to IAM.
    TrackedActionLastAccessed -> Maybe Text
actionName :: Prelude.Maybe Prelude.Text,
    TrackedActionLastAccessed -> Maybe Text
lastAccessedEntity :: Prelude.Maybe Prelude.Text,
    -- | The Region from which the authenticated entity (user or role) last
    -- attempted to access the tracked action. Amazon Web Services does not
    -- report unauthenticated requests.
    --
    -- This field is null if no IAM entities attempted to access the service
    -- within the
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
    TrackedActionLastAccessed -> Maybe Text
lastAccessedRegion :: Prelude.Maybe Prelude.Text
  }
  deriving (TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool
(TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool)
-> (TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool)
-> Eq TrackedActionLastAccessed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool
$c/= :: TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool
== :: TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool
$c== :: TrackedActionLastAccessed -> TrackedActionLastAccessed -> Bool
Prelude.Eq, ReadPrec [TrackedActionLastAccessed]
ReadPrec TrackedActionLastAccessed
Int -> ReadS TrackedActionLastAccessed
ReadS [TrackedActionLastAccessed]
(Int -> ReadS TrackedActionLastAccessed)
-> ReadS [TrackedActionLastAccessed]
-> ReadPrec TrackedActionLastAccessed
-> ReadPrec [TrackedActionLastAccessed]
-> Read TrackedActionLastAccessed
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrackedActionLastAccessed]
$creadListPrec :: ReadPrec [TrackedActionLastAccessed]
readPrec :: ReadPrec TrackedActionLastAccessed
$creadPrec :: ReadPrec TrackedActionLastAccessed
readList :: ReadS [TrackedActionLastAccessed]
$creadList :: ReadS [TrackedActionLastAccessed]
readsPrec :: Int -> ReadS TrackedActionLastAccessed
$creadsPrec :: Int -> ReadS TrackedActionLastAccessed
Prelude.Read, Int -> TrackedActionLastAccessed -> ShowS
[TrackedActionLastAccessed] -> ShowS
TrackedActionLastAccessed -> String
(Int -> TrackedActionLastAccessed -> ShowS)
-> (TrackedActionLastAccessed -> String)
-> ([TrackedActionLastAccessed] -> ShowS)
-> Show TrackedActionLastAccessed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrackedActionLastAccessed] -> ShowS
$cshowList :: [TrackedActionLastAccessed] -> ShowS
show :: TrackedActionLastAccessed -> String
$cshow :: TrackedActionLastAccessed -> String
showsPrec :: Int -> TrackedActionLastAccessed -> ShowS
$cshowsPrec :: Int -> TrackedActionLastAccessed -> ShowS
Prelude.Show, (forall x.
 TrackedActionLastAccessed -> Rep TrackedActionLastAccessed x)
-> (forall x.
    Rep TrackedActionLastAccessed x -> TrackedActionLastAccessed)
-> Generic TrackedActionLastAccessed
forall x.
Rep TrackedActionLastAccessed x -> TrackedActionLastAccessed
forall x.
TrackedActionLastAccessed -> Rep TrackedActionLastAccessed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TrackedActionLastAccessed x -> TrackedActionLastAccessed
$cfrom :: forall x.
TrackedActionLastAccessed -> Rep TrackedActionLastAccessed x
Prelude.Generic)

-- |
-- Create a value of 'TrackedActionLastAccessed' 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:
--
-- 'lastAccessedTime', 'trackedActionLastAccessed_lastAccessedTime' - The date and time,
-- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when an
-- authenticated entity most recently attempted to access the tracked
-- service. Amazon Web Services does not report unauthenticated requests.
--
-- This field is null if no IAM entities attempted to access the service
-- within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
--
-- 'actionName', 'trackedActionLastAccessed_actionName' - The name of the tracked action to which access was attempted. Tracked
-- actions are actions that report activity to IAM.
--
-- 'lastAccessedEntity', 'trackedActionLastAccessed_lastAccessedEntity' - Undocumented member.
--
-- 'lastAccessedRegion', 'trackedActionLastAccessed_lastAccessedRegion' - The Region from which the authenticated entity (user or role) last
-- attempted to access the tracked action. Amazon Web Services does not
-- report unauthenticated requests.
--
-- This field is null if no IAM entities attempted to access the service
-- within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
newTrackedActionLastAccessed ::
  TrackedActionLastAccessed
newTrackedActionLastAccessed :: TrackedActionLastAccessed
newTrackedActionLastAccessed =
  TrackedActionLastAccessed' :: Maybe ISO8601
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TrackedActionLastAccessed
TrackedActionLastAccessed'
    { $sel:lastAccessedTime:TrackedActionLastAccessed' :: Maybe ISO8601
lastAccessedTime =
        Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:TrackedActionLastAccessed' :: Maybe Text
actionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastAccessedEntity:TrackedActionLastAccessed' :: Maybe Text
lastAccessedEntity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastAccessedRegion:TrackedActionLastAccessed' :: Maybe Text
lastAccessedRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time,
-- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when an
-- authenticated entity most recently attempted to access the tracked
-- service. Amazon Web Services does not report unauthenticated requests.
--
-- This field is null if no IAM entities attempted to access the service
-- within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
trackedActionLastAccessed_lastAccessedTime :: Lens.Lens' TrackedActionLastAccessed (Prelude.Maybe Prelude.UTCTime)
trackedActionLastAccessed_lastAccessedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TrackedActionLastAccessed -> f TrackedActionLastAccessed
trackedActionLastAccessed_lastAccessedTime = (TrackedActionLastAccessed -> Maybe ISO8601)
-> (TrackedActionLastAccessed
    -> Maybe ISO8601 -> TrackedActionLastAccessed)
-> Lens
     TrackedActionLastAccessed
     TrackedActionLastAccessed
     (Maybe ISO8601)
     (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackedActionLastAccessed' {Maybe ISO8601
lastAccessedTime :: Maybe ISO8601
$sel:lastAccessedTime:TrackedActionLastAccessed' :: TrackedActionLastAccessed -> Maybe ISO8601
lastAccessedTime} -> Maybe ISO8601
lastAccessedTime) (\s :: TrackedActionLastAccessed
s@TrackedActionLastAccessed' {} Maybe ISO8601
a -> TrackedActionLastAccessed
s {$sel:lastAccessedTime:TrackedActionLastAccessed' :: Maybe ISO8601
lastAccessedTime = Maybe ISO8601
a} :: TrackedActionLastAccessed) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> TrackedActionLastAccessed -> f TrackedActionLastAccessed)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TrackedActionLastAccessed
-> f TrackedActionLastAccessed
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the tracked action to which access was attempted. Tracked
-- actions are actions that report activity to IAM.
trackedActionLastAccessed_actionName :: Lens.Lens' TrackedActionLastAccessed (Prelude.Maybe Prelude.Text)
trackedActionLastAccessed_actionName :: (Maybe Text -> f (Maybe Text))
-> TrackedActionLastAccessed -> f TrackedActionLastAccessed
trackedActionLastAccessed_actionName = (TrackedActionLastAccessed -> Maybe Text)
-> (TrackedActionLastAccessed
    -> Maybe Text -> TrackedActionLastAccessed)
-> Lens
     TrackedActionLastAccessed
     TrackedActionLastAccessed
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackedActionLastAccessed' {Maybe Text
actionName :: Maybe Text
$sel:actionName:TrackedActionLastAccessed' :: TrackedActionLastAccessed -> Maybe Text
actionName} -> Maybe Text
actionName) (\s :: TrackedActionLastAccessed
s@TrackedActionLastAccessed' {} Maybe Text
a -> TrackedActionLastAccessed
s {$sel:actionName:TrackedActionLastAccessed' :: Maybe Text
actionName = Maybe Text
a} :: TrackedActionLastAccessed)

-- | Undocumented member.
trackedActionLastAccessed_lastAccessedEntity :: Lens.Lens' TrackedActionLastAccessed (Prelude.Maybe Prelude.Text)
trackedActionLastAccessed_lastAccessedEntity :: (Maybe Text -> f (Maybe Text))
-> TrackedActionLastAccessed -> f TrackedActionLastAccessed
trackedActionLastAccessed_lastAccessedEntity = (TrackedActionLastAccessed -> Maybe Text)
-> (TrackedActionLastAccessed
    -> Maybe Text -> TrackedActionLastAccessed)
-> Lens
     TrackedActionLastAccessed
     TrackedActionLastAccessed
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackedActionLastAccessed' {Maybe Text
lastAccessedEntity :: Maybe Text
$sel:lastAccessedEntity:TrackedActionLastAccessed' :: TrackedActionLastAccessed -> Maybe Text
lastAccessedEntity} -> Maybe Text
lastAccessedEntity) (\s :: TrackedActionLastAccessed
s@TrackedActionLastAccessed' {} Maybe Text
a -> TrackedActionLastAccessed
s {$sel:lastAccessedEntity:TrackedActionLastAccessed' :: Maybe Text
lastAccessedEntity = Maybe Text
a} :: TrackedActionLastAccessed)

-- | The Region from which the authenticated entity (user or role) last
-- attempted to access the tracked action. Amazon Web Services does not
-- report unauthenticated requests.
--
-- This field is null if no IAM entities attempted to access the service
-- within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
trackedActionLastAccessed_lastAccessedRegion :: Lens.Lens' TrackedActionLastAccessed (Prelude.Maybe Prelude.Text)
trackedActionLastAccessed_lastAccessedRegion :: (Maybe Text -> f (Maybe Text))
-> TrackedActionLastAccessed -> f TrackedActionLastAccessed
trackedActionLastAccessed_lastAccessedRegion = (TrackedActionLastAccessed -> Maybe Text)
-> (TrackedActionLastAccessed
    -> Maybe Text -> TrackedActionLastAccessed)
-> Lens
     TrackedActionLastAccessed
     TrackedActionLastAccessed
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackedActionLastAccessed' {Maybe Text
lastAccessedRegion :: Maybe Text
$sel:lastAccessedRegion:TrackedActionLastAccessed' :: TrackedActionLastAccessed -> Maybe Text
lastAccessedRegion} -> Maybe Text
lastAccessedRegion) (\s :: TrackedActionLastAccessed
s@TrackedActionLastAccessed' {} Maybe Text
a -> TrackedActionLastAccessed
s {$sel:lastAccessedRegion:TrackedActionLastAccessed' :: Maybe Text
lastAccessedRegion = Maybe Text
a} :: TrackedActionLastAccessed)

instance Core.FromXML TrackedActionLastAccessed where
  parseXML :: [Node] -> Either String TrackedActionLastAccessed
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TrackedActionLastAccessed
TrackedActionLastAccessed'
      (Maybe ISO8601
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> TrackedActionLastAccessed)
-> Either String (Maybe ISO8601)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> TrackedActionLastAccessed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LastAccessedTime")
      Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> TrackedActionLastAccessed)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> TrackedActionLastAccessed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ActionName")
      Either
  String (Maybe Text -> Maybe Text -> TrackedActionLastAccessed)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> TrackedActionLastAccessed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LastAccessedEntity")
      Either String (Maybe Text -> TrackedActionLastAccessed)
-> Either String (Maybe Text)
-> Either String TrackedActionLastAccessed
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LastAccessedRegion")

instance Prelude.Hashable TrackedActionLastAccessed

instance Prelude.NFData TrackedActionLastAccessed