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

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.TrackedActionLastAccessed
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the most recent attempt to access the service.
--
-- This data type is used as a response element in the
-- GetServiceLastAccessedDetails operation.
--
-- /See:/ 'newServiceLastAccessed' smart constructor.
data ServiceLastAccessed = ServiceLastAccessed'
  { -- | 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 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>.
    ServiceLastAccessed -> Maybe ISO8601
lastAuthenticated :: Prelude.Maybe Core.ISO8601,
    -- | An object that contains details about the most recent attempt to access
    -- a tracked action within the service.
    --
    -- This field is null if there no tracked actions or if the principal did
    -- not use the tracked actions within the
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
    -- This field is also null if the report was generated at the service level
    -- and not the action level. For more information, see the @Granularity@
    -- field in GenerateServiceLastAccessedDetails.
    ServiceLastAccessed -> Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed :: Prelude.Maybe [TrackedActionLastAccessed],
    -- | The ARN of the authenticated entity (user or role) that last attempted
    -- to access the 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>.
    ServiceLastAccessed -> Maybe Text
lastAuthenticatedEntity :: Prelude.Maybe Prelude.Text,
    -- | The Region from which the authenticated entity (user or role) last
    -- attempted to access the 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>.
    ServiceLastAccessed -> Maybe Text
lastAuthenticatedRegion :: Prelude.Maybe Prelude.Text,
    -- | The total number of authenticated principals (root user, IAM users, or
    -- IAM roles) that have attempted to access the service.
    --
    -- This field is null if no principals 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>.
    ServiceLastAccessed -> Maybe Int
totalAuthenticatedEntities :: Prelude.Maybe Prelude.Int,
    -- | The name of the service in which access was attempted.
    ServiceLastAccessed -> Text
serviceName :: Prelude.Text,
    -- | The namespace of the service in which access was attempted.
    --
    -- To learn the service namespace of a service, see
    -- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
    -- in the /Service Authorization Reference/. Choose the name of the service
    -- to view details for that service. In the first paragraph, find the
    -- service prefix. For example, @(service prefix: a4b)@. For more
    -- information about service namespaces, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services Service Namespaces>
    -- in the /Amazon Web Services General Reference/.
    ServiceLastAccessed -> Text
serviceNamespace :: Prelude.Text
  }
  deriving (ServiceLastAccessed -> ServiceLastAccessed -> Bool
(ServiceLastAccessed -> ServiceLastAccessed -> Bool)
-> (ServiceLastAccessed -> ServiceLastAccessed -> Bool)
-> Eq ServiceLastAccessed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceLastAccessed -> ServiceLastAccessed -> Bool
$c/= :: ServiceLastAccessed -> ServiceLastAccessed -> Bool
== :: ServiceLastAccessed -> ServiceLastAccessed -> Bool
$c== :: ServiceLastAccessed -> ServiceLastAccessed -> Bool
Prelude.Eq, ReadPrec [ServiceLastAccessed]
ReadPrec ServiceLastAccessed
Int -> ReadS ServiceLastAccessed
ReadS [ServiceLastAccessed]
(Int -> ReadS ServiceLastAccessed)
-> ReadS [ServiceLastAccessed]
-> ReadPrec ServiceLastAccessed
-> ReadPrec [ServiceLastAccessed]
-> Read ServiceLastAccessed
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceLastAccessed]
$creadListPrec :: ReadPrec [ServiceLastAccessed]
readPrec :: ReadPrec ServiceLastAccessed
$creadPrec :: ReadPrec ServiceLastAccessed
readList :: ReadS [ServiceLastAccessed]
$creadList :: ReadS [ServiceLastAccessed]
readsPrec :: Int -> ReadS ServiceLastAccessed
$creadsPrec :: Int -> ReadS ServiceLastAccessed
Prelude.Read, Int -> ServiceLastAccessed -> ShowS
[ServiceLastAccessed] -> ShowS
ServiceLastAccessed -> String
(Int -> ServiceLastAccessed -> ShowS)
-> (ServiceLastAccessed -> String)
-> ([ServiceLastAccessed] -> ShowS)
-> Show ServiceLastAccessed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceLastAccessed] -> ShowS
$cshowList :: [ServiceLastAccessed] -> ShowS
show :: ServiceLastAccessed -> String
$cshow :: ServiceLastAccessed -> String
showsPrec :: Int -> ServiceLastAccessed -> ShowS
$cshowsPrec :: Int -> ServiceLastAccessed -> ShowS
Prelude.Show, (forall x. ServiceLastAccessed -> Rep ServiceLastAccessed x)
-> (forall x. Rep ServiceLastAccessed x -> ServiceLastAccessed)
-> Generic ServiceLastAccessed
forall x. Rep ServiceLastAccessed x -> ServiceLastAccessed
forall x. ServiceLastAccessed -> Rep ServiceLastAccessed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceLastAccessed x -> ServiceLastAccessed
$cfrom :: forall x. ServiceLastAccessed -> Rep ServiceLastAccessed x
Prelude.Generic)

-- |
-- Create a value of 'ServiceLastAccessed' 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', 'serviceLastAccessed_lastAuthenticated' - 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 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>.
--
-- 'trackedActionsLastAccessed', 'serviceLastAccessed_trackedActionsLastAccessed' - An object that contains details about the most recent attempt to access
-- a tracked action within the service.
--
-- This field is null if there no tracked actions or if the principal did
-- not use the tracked actions within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
-- This field is also null if the report was generated at the service level
-- and not the action level. For more information, see the @Granularity@
-- field in GenerateServiceLastAccessedDetails.
--
-- 'lastAuthenticatedEntity', 'serviceLastAccessed_lastAuthenticatedEntity' - The ARN of the authenticated entity (user or role) that last attempted
-- to access the 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>.
--
-- 'lastAuthenticatedRegion', 'serviceLastAccessed_lastAuthenticatedRegion' - The Region from which the authenticated entity (user or role) last
-- attempted to access the 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>.
--
-- 'totalAuthenticatedEntities', 'serviceLastAccessed_totalAuthenticatedEntities' - The total number of authenticated principals (root user, IAM users, or
-- IAM roles) that have attempted to access the service.
--
-- This field is null if no principals 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>.
--
-- 'serviceName', 'serviceLastAccessed_serviceName' - The name of the service in which access was attempted.
--
-- 'serviceNamespace', 'serviceLastAccessed_serviceNamespace' - The namespace of the service in which access was attempted.
--
-- To learn the service namespace of a service, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
-- in the /Service Authorization Reference/. Choose the name of the service
-- to view details for that service. In the first paragraph, find the
-- service prefix. For example, @(service prefix: a4b)@. For more
-- information about service namespaces, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
newServiceLastAccessed ::
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'serviceNamespace'
  Prelude.Text ->
  ServiceLastAccessed
newServiceLastAccessed :: Text -> Text -> ServiceLastAccessed
newServiceLastAccessed
  Text
pServiceName_
  Text
pServiceNamespace_ =
    ServiceLastAccessed' :: Maybe ISO8601
-> Maybe [TrackedActionLastAccessed]
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Text
-> Text
-> ServiceLastAccessed
ServiceLastAccessed'
      { $sel:lastAuthenticated:ServiceLastAccessed' :: Maybe ISO8601
lastAuthenticated =
          Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
        $sel:trackedActionsLastAccessed:ServiceLastAccessed' :: Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed = Maybe [TrackedActionLastAccessed]
forall a. Maybe a
Prelude.Nothing,
        $sel:lastAuthenticatedEntity:ServiceLastAccessed' :: Maybe Text
lastAuthenticatedEntity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:lastAuthenticatedRegion:ServiceLastAccessed' :: Maybe Text
lastAuthenticatedRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:totalAuthenticatedEntities:ServiceLastAccessed' :: Maybe Int
totalAuthenticatedEntities = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:serviceName:ServiceLastAccessed' :: Text
serviceName = Text
pServiceName_,
        $sel:serviceNamespace:ServiceLastAccessed' :: Text
serviceNamespace = Text
pServiceNamespace_
      }

-- | 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 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>.
serviceLastAccessed_lastAuthenticated :: Lens.Lens' ServiceLastAccessed (Prelude.Maybe Prelude.UTCTime)
serviceLastAccessed_lastAuthenticated :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_lastAuthenticated = (ServiceLastAccessed -> Maybe ISO8601)
-> (ServiceLastAccessed -> Maybe ISO8601 -> ServiceLastAccessed)
-> Lens
     ServiceLastAccessed
     ServiceLastAccessed
     (Maybe ISO8601)
     (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Maybe ISO8601
lastAuthenticated :: Maybe ISO8601
$sel:lastAuthenticated:ServiceLastAccessed' :: ServiceLastAccessed -> Maybe ISO8601
lastAuthenticated} -> Maybe ISO8601
lastAuthenticated) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Maybe ISO8601
a -> ServiceLastAccessed
s {$sel:lastAuthenticated:ServiceLastAccessed' :: Maybe ISO8601
lastAuthenticated = Maybe ISO8601
a} :: ServiceLastAccessed) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> ServiceLastAccessed -> f ServiceLastAccessed)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ServiceLastAccessed
-> f ServiceLastAccessed
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

-- | An object that contains details about the most recent attempt to access
-- a tracked action within the service.
--
-- This field is null if there no tracked actions or if the principal did
-- not use the tracked actions within the
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor.html#service-last-accessed-reporting-period reporting period>.
-- This field is also null if the report was generated at the service level
-- and not the action level. For more information, see the @Granularity@
-- field in GenerateServiceLastAccessedDetails.
serviceLastAccessed_trackedActionsLastAccessed :: Lens.Lens' ServiceLastAccessed (Prelude.Maybe [TrackedActionLastAccessed])
serviceLastAccessed_trackedActionsLastAccessed :: (Maybe [TrackedActionLastAccessed]
 -> f (Maybe [TrackedActionLastAccessed]))
-> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_trackedActionsLastAccessed = (ServiceLastAccessed -> Maybe [TrackedActionLastAccessed])
-> (ServiceLastAccessed
    -> Maybe [TrackedActionLastAccessed] -> ServiceLastAccessed)
-> Lens
     ServiceLastAccessed
     ServiceLastAccessed
     (Maybe [TrackedActionLastAccessed])
     (Maybe [TrackedActionLastAccessed])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed :: Maybe [TrackedActionLastAccessed]
$sel:trackedActionsLastAccessed:ServiceLastAccessed' :: ServiceLastAccessed -> Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed} -> Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Maybe [TrackedActionLastAccessed]
a -> ServiceLastAccessed
s {$sel:trackedActionsLastAccessed:ServiceLastAccessed' :: Maybe [TrackedActionLastAccessed]
trackedActionsLastAccessed = Maybe [TrackedActionLastAccessed]
a} :: ServiceLastAccessed) ((Maybe [TrackedActionLastAccessed]
  -> f (Maybe [TrackedActionLastAccessed]))
 -> ServiceLastAccessed -> f ServiceLastAccessed)
-> ((Maybe [TrackedActionLastAccessed]
     -> f (Maybe [TrackedActionLastAccessed]))
    -> Maybe [TrackedActionLastAccessed]
    -> f (Maybe [TrackedActionLastAccessed]))
-> (Maybe [TrackedActionLastAccessed]
    -> f (Maybe [TrackedActionLastAccessed]))
-> ServiceLastAccessed
-> f ServiceLastAccessed
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
-> Iso
     (Maybe [TrackedActionLastAccessed])
     (Maybe [TrackedActionLastAccessed])
     (Maybe [TrackedActionLastAccessed])
     (Maybe [TrackedActionLastAccessed])
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
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
  [TrackedActionLastAccessed]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the authenticated entity (user or role) that last attempted
-- to access the 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>.
serviceLastAccessed_lastAuthenticatedEntity :: Lens.Lens' ServiceLastAccessed (Prelude.Maybe Prelude.Text)
serviceLastAccessed_lastAuthenticatedEntity :: (Maybe Text -> f (Maybe Text))
-> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_lastAuthenticatedEntity = (ServiceLastAccessed -> Maybe Text)
-> (ServiceLastAccessed -> Maybe Text -> ServiceLastAccessed)
-> Lens
     ServiceLastAccessed ServiceLastAccessed (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Maybe Text
lastAuthenticatedEntity :: Maybe Text
$sel:lastAuthenticatedEntity:ServiceLastAccessed' :: ServiceLastAccessed -> Maybe Text
lastAuthenticatedEntity} -> Maybe Text
lastAuthenticatedEntity) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Maybe Text
a -> ServiceLastAccessed
s {$sel:lastAuthenticatedEntity:ServiceLastAccessed' :: Maybe Text
lastAuthenticatedEntity = Maybe Text
a} :: ServiceLastAccessed)

-- | The Region from which the authenticated entity (user or role) last
-- attempted to access the 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>.
serviceLastAccessed_lastAuthenticatedRegion :: Lens.Lens' ServiceLastAccessed (Prelude.Maybe Prelude.Text)
serviceLastAccessed_lastAuthenticatedRegion :: (Maybe Text -> f (Maybe Text))
-> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_lastAuthenticatedRegion = (ServiceLastAccessed -> Maybe Text)
-> (ServiceLastAccessed -> Maybe Text -> ServiceLastAccessed)
-> Lens
     ServiceLastAccessed ServiceLastAccessed (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Maybe Text
lastAuthenticatedRegion :: Maybe Text
$sel:lastAuthenticatedRegion:ServiceLastAccessed' :: ServiceLastAccessed -> Maybe Text
lastAuthenticatedRegion} -> Maybe Text
lastAuthenticatedRegion) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Maybe Text
a -> ServiceLastAccessed
s {$sel:lastAuthenticatedRegion:ServiceLastAccessed' :: Maybe Text
lastAuthenticatedRegion = Maybe Text
a} :: ServiceLastAccessed)

-- | The total number of authenticated principals (root user, IAM users, or
-- IAM roles) that have attempted to access the service.
--
-- This field is null if no principals 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>.
serviceLastAccessed_totalAuthenticatedEntities :: Lens.Lens' ServiceLastAccessed (Prelude.Maybe Prelude.Int)
serviceLastAccessed_totalAuthenticatedEntities :: (Maybe Int -> f (Maybe Int))
-> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_totalAuthenticatedEntities = (ServiceLastAccessed -> Maybe Int)
-> (ServiceLastAccessed -> Maybe Int -> ServiceLastAccessed)
-> Lens
     ServiceLastAccessed ServiceLastAccessed (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Maybe Int
totalAuthenticatedEntities :: Maybe Int
$sel:totalAuthenticatedEntities:ServiceLastAccessed' :: ServiceLastAccessed -> Maybe Int
totalAuthenticatedEntities} -> Maybe Int
totalAuthenticatedEntities) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Maybe Int
a -> ServiceLastAccessed
s {$sel:totalAuthenticatedEntities:ServiceLastAccessed' :: Maybe Int
totalAuthenticatedEntities = Maybe Int
a} :: ServiceLastAccessed)

-- | The name of the service in which access was attempted.
serviceLastAccessed_serviceName :: Lens.Lens' ServiceLastAccessed Prelude.Text
serviceLastAccessed_serviceName :: (Text -> f Text) -> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_serviceName = (ServiceLastAccessed -> Text)
-> (ServiceLastAccessed -> Text -> ServiceLastAccessed)
-> Lens ServiceLastAccessed ServiceLastAccessed Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Text
serviceName :: Text
$sel:serviceName:ServiceLastAccessed' :: ServiceLastAccessed -> Text
serviceName} -> Text
serviceName) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Text
a -> ServiceLastAccessed
s {$sel:serviceName:ServiceLastAccessed' :: Text
serviceName = Text
a} :: ServiceLastAccessed)

-- | The namespace of the service in which access was attempted.
--
-- To learn the service namespace of a service, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
-- in the /Service Authorization Reference/. Choose the name of the service
-- to view details for that service. In the first paragraph, find the
-- service prefix. For example, @(service prefix: a4b)@. For more
-- information about service namespaces, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
serviceLastAccessed_serviceNamespace :: Lens.Lens' ServiceLastAccessed Prelude.Text
serviceLastAccessed_serviceNamespace :: (Text -> f Text) -> ServiceLastAccessed -> f ServiceLastAccessed
serviceLastAccessed_serviceNamespace = (ServiceLastAccessed -> Text)
-> (ServiceLastAccessed -> Text -> ServiceLastAccessed)
-> Lens ServiceLastAccessed ServiceLastAccessed Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLastAccessed' {Text
serviceNamespace :: Text
$sel:serviceNamespace:ServiceLastAccessed' :: ServiceLastAccessed -> Text
serviceNamespace} -> Text
serviceNamespace) (\s :: ServiceLastAccessed
s@ServiceLastAccessed' {} Text
a -> ServiceLastAccessed
s {$sel:serviceNamespace:ServiceLastAccessed' :: Text
serviceNamespace = Text
a} :: ServiceLastAccessed)

instance Core.FromXML ServiceLastAccessed where
  parseXML :: [Node] -> Either String ServiceLastAccessed
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe [TrackedActionLastAccessed]
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Text
-> Text
-> ServiceLastAccessed
ServiceLastAccessed'
      (Maybe ISO8601
 -> Maybe [TrackedActionLastAccessed]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Text
 -> Text
 -> ServiceLastAccessed)
-> Either String (Maybe ISO8601)
-> Either
     String
     (Maybe [TrackedActionLastAccessed]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Text
      -> Text
      -> ServiceLastAccessed)
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
"LastAuthenticated")
      Either
  String
  (Maybe [TrackedActionLastAccessed]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Text
   -> Text
   -> ServiceLastAccessed)
-> Either String (Maybe [TrackedActionLastAccessed])
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Int -> Text -> Text -> ServiceLastAccessed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TrackedActionsLastAccessed"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [TrackedActionLastAccessed]))
-> Either String (Maybe [TrackedActionLastAccessed])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [TrackedActionLastAccessed])
-> [Node] -> Either String (Maybe [TrackedActionLastAccessed])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [TrackedActionLastAccessed]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Int -> Text -> Text -> ServiceLastAccessed)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Int -> Text -> Text -> ServiceLastAccessed)
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
"LastAuthenticatedEntity")
      Either
  String
  (Maybe Text -> Maybe Int -> Text -> Text -> ServiceLastAccessed)
-> Either String (Maybe Text)
-> Either String (Maybe Int -> Text -> Text -> ServiceLastAccessed)
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
"LastAuthenticatedRegion")
      Either String (Maybe Int -> Text -> Text -> ServiceLastAccessed)
-> Either String (Maybe Int)
-> Either String (Text -> Text -> ServiceLastAccessed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TotalAuthenticatedEntities")
      Either String (Text -> Text -> ServiceLastAccessed)
-> Either String Text
-> Either String (Text -> ServiceLastAccessed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ServiceName")
      Either String (Text -> ServiceLastAccessed)
-> Either String Text -> Either String ServiceLastAccessed
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ServiceNamespace")

instance Prelude.Hashable ServiceLastAccessed

instance Prelude.NFData ServiceLastAccessed