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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.EntityInfo
import qualified Amazonka.Prelude as Prelude

-- | An object that contains details about when the IAM entities (users or
-- roles) were last used in an attempt to access the specified Amazon Web
-- Services service.
--
-- This data type is a response element in the
-- GetServiceLastAccessedDetailsWithEntities operation.
--
-- /See:/ 'newEntityDetails' smart constructor.
data EntityDetails = EntityDetails'
  { -- | The date and time,
    -- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
    -- authenticated entity last attempted to access Amazon Web Services.
    -- 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 tracking period>.
    EntityDetails -> Maybe ISO8601
lastAuthenticated :: Prelude.Maybe Data.ISO8601,
    -- | The @EntityInfo@ object that contains details about the entity (user or
    -- role).
    EntityDetails -> EntityInfo
entityInfo :: EntityInfo
  }
  deriving (EntityDetails -> EntityDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityDetails -> EntityDetails -> Bool
$c/= :: EntityDetails -> EntityDetails -> Bool
== :: EntityDetails -> EntityDetails -> Bool
$c== :: EntityDetails -> EntityDetails -> Bool
Prelude.Eq, ReadPrec [EntityDetails]
ReadPrec EntityDetails
Int -> ReadS EntityDetails
ReadS [EntityDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityDetails]
$creadListPrec :: ReadPrec [EntityDetails]
readPrec :: ReadPrec EntityDetails
$creadPrec :: ReadPrec EntityDetails
readList :: ReadS [EntityDetails]
$creadList :: ReadS [EntityDetails]
readsPrec :: Int -> ReadS EntityDetails
$creadsPrec :: Int -> ReadS EntityDetails
Prelude.Read, Int -> EntityDetails -> ShowS
[EntityDetails] -> ShowS
EntityDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityDetails] -> ShowS
$cshowList :: [EntityDetails] -> ShowS
show :: EntityDetails -> String
$cshow :: EntityDetails -> String
showsPrec :: Int -> EntityDetails -> ShowS
$cshowsPrec :: Int -> EntityDetails -> ShowS
Prelude.Show, forall x. Rep EntityDetails x -> EntityDetails
forall x. EntityDetails -> Rep EntityDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntityDetails x -> EntityDetails
$cfrom :: forall x. EntityDetails -> Rep EntityDetails x
Prelude.Generic)

-- |
-- Create a value of 'EntityDetails' 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:
--
-- 'lastAuthenticated', 'entityDetails_lastAuthenticated' - The date and time,
-- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
-- authenticated entity last attempted to access Amazon Web Services.
-- 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 tracking period>.
--
-- 'entityInfo', 'entityDetails_entityInfo' - The @EntityInfo@ object that contains details about the entity (user or
-- role).
newEntityDetails ::
  -- | 'entityInfo'
  EntityInfo ->
  EntityDetails
newEntityDetails :: EntityInfo -> EntityDetails
newEntityDetails EntityInfo
pEntityInfo_ =
  EntityDetails'
    { $sel:lastAuthenticated:EntityDetails' :: Maybe ISO8601
lastAuthenticated = forall a. Maybe a
Prelude.Nothing,
      $sel:entityInfo:EntityDetails' :: EntityInfo
entityInfo = EntityInfo
pEntityInfo_
    }

-- | The date and time,
-- in <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
-- authenticated entity last attempted to access Amazon Web Services.
-- 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 tracking period>.
entityDetails_lastAuthenticated :: Lens.Lens' EntityDetails (Prelude.Maybe Prelude.UTCTime)
entityDetails_lastAuthenticated :: Lens' EntityDetails (Maybe UTCTime)
entityDetails_lastAuthenticated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDetails' {Maybe ISO8601
lastAuthenticated :: Maybe ISO8601
$sel:lastAuthenticated:EntityDetails' :: EntityDetails -> Maybe ISO8601
lastAuthenticated} -> Maybe ISO8601
lastAuthenticated) (\s :: EntityDetails
s@EntityDetails' {} Maybe ISO8601
a -> EntityDetails
s {$sel:lastAuthenticated:EntityDetails' :: Maybe ISO8601
lastAuthenticated = Maybe ISO8601
a} :: EntityDetails) 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

-- | The @EntityInfo@ object that contains details about the entity (user or
-- role).
entityDetails_entityInfo :: Lens.Lens' EntityDetails EntityInfo
entityDetails_entityInfo :: Lens' EntityDetails EntityInfo
entityDetails_entityInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDetails' {EntityInfo
entityInfo :: EntityInfo
$sel:entityInfo:EntityDetails' :: EntityDetails -> EntityInfo
entityInfo} -> EntityInfo
entityInfo) (\s :: EntityDetails
s@EntityDetails' {} EntityInfo
a -> EntityDetails
s {$sel:entityInfo:EntityDetails' :: EntityInfo
entityInfo = EntityInfo
a} :: EntityDetails)

instance Data.FromXML EntityDetails where
  parseXML :: [Node] -> Either String EntityDetails
parseXML [Node]
x =
    Maybe ISO8601 -> EntityInfo -> EntityDetails
EntityDetails'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"LastAuthenticated")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"EntityInfo")

instance Prelude.Hashable EntityDetails where
  hashWithSalt :: Int -> EntityDetails -> Int
hashWithSalt Int
_salt EntityDetails' {Maybe ISO8601
EntityInfo
entityInfo :: EntityInfo
lastAuthenticated :: Maybe ISO8601
$sel:entityInfo:EntityDetails' :: EntityDetails -> EntityInfo
$sel:lastAuthenticated:EntityDetails' :: EntityDetails -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
lastAuthenticated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EntityInfo
entityInfo

instance Prelude.NFData EntityDetails where
  rnf :: EntityDetails -> ()
rnf EntityDetails' {Maybe ISO8601
EntityInfo
entityInfo :: EntityInfo
lastAuthenticated :: Maybe ISO8601
$sel:entityInfo:EntityDetails' :: EntityDetails -> EntityInfo
$sel:lastAuthenticated:EntityDetails' :: EntityDetails -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
lastAuthenticated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EntityInfo
entityInfo