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

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

-- | Contains information about the last time an Amazon Web Services access
-- key was used since IAM began tracking this information on April 22,
-- 2015.
--
-- This data type is used as a response element in the GetAccessKeyLastUsed
-- operation.
--
-- /See:/ 'newAccessKeyLastUsed' smart constructor.
data AccessKeyLastUsed = AccessKeyLastUsed'
  { -- | The date and time, in
    -- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
    -- access key was most recently used. This field is null in the following
    -- situations:
    --
    -- -   The user does not have an access key.
    --
    -- -   An access key exists but has not been used since IAM began tracking
    --     this information.
    --
    -- -   There is no sign-in data associated with the user.
    AccessKeyLastUsed -> ISO8601
lastUsedDate :: Core.ISO8601,
    -- | The name of the Amazon Web Services service with which this access key
    -- was most recently used. The value of this field is \"N\/A\" in the
    -- following situations:
    --
    -- -   The user does not have an access key.
    --
    -- -   An access key exists but has not been used since IAM started
    --     tracking this information.
    --
    -- -   There is no sign-in data associated with the user.
    AccessKeyLastUsed -> Text
serviceName :: Prelude.Text,
    -- | The Amazon Web Services Region where this access key was most recently
    -- used. The value for this field is \"N\/A\" in the following situations:
    --
    -- -   The user does not have an access key.
    --
    -- -   An access key exists but has not been used since IAM began tracking
    --     this information.
    --
    -- -   There is no sign-in data associated with the user.
    --
    -- For more information about Amazon Web Services Regions, see
    -- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and endpoints>
    -- in the Amazon Web Services General Reference.
    AccessKeyLastUsed -> Text
region :: Prelude.Text
  }
  deriving (AccessKeyLastUsed -> AccessKeyLastUsed -> Bool
(AccessKeyLastUsed -> AccessKeyLastUsed -> Bool)
-> (AccessKeyLastUsed -> AccessKeyLastUsed -> Bool)
-> Eq AccessKeyLastUsed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessKeyLastUsed -> AccessKeyLastUsed -> Bool
$c/= :: AccessKeyLastUsed -> AccessKeyLastUsed -> Bool
== :: AccessKeyLastUsed -> AccessKeyLastUsed -> Bool
$c== :: AccessKeyLastUsed -> AccessKeyLastUsed -> Bool
Prelude.Eq, ReadPrec [AccessKeyLastUsed]
ReadPrec AccessKeyLastUsed
Int -> ReadS AccessKeyLastUsed
ReadS [AccessKeyLastUsed]
(Int -> ReadS AccessKeyLastUsed)
-> ReadS [AccessKeyLastUsed]
-> ReadPrec AccessKeyLastUsed
-> ReadPrec [AccessKeyLastUsed]
-> Read AccessKeyLastUsed
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessKeyLastUsed]
$creadListPrec :: ReadPrec [AccessKeyLastUsed]
readPrec :: ReadPrec AccessKeyLastUsed
$creadPrec :: ReadPrec AccessKeyLastUsed
readList :: ReadS [AccessKeyLastUsed]
$creadList :: ReadS [AccessKeyLastUsed]
readsPrec :: Int -> ReadS AccessKeyLastUsed
$creadsPrec :: Int -> ReadS AccessKeyLastUsed
Prelude.Read, Int -> AccessKeyLastUsed -> ShowS
[AccessKeyLastUsed] -> ShowS
AccessKeyLastUsed -> String
(Int -> AccessKeyLastUsed -> ShowS)
-> (AccessKeyLastUsed -> String)
-> ([AccessKeyLastUsed] -> ShowS)
-> Show AccessKeyLastUsed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessKeyLastUsed] -> ShowS
$cshowList :: [AccessKeyLastUsed] -> ShowS
show :: AccessKeyLastUsed -> String
$cshow :: AccessKeyLastUsed -> String
showsPrec :: Int -> AccessKeyLastUsed -> ShowS
$cshowsPrec :: Int -> AccessKeyLastUsed -> ShowS
Prelude.Show, (forall x. AccessKeyLastUsed -> Rep AccessKeyLastUsed x)
-> (forall x. Rep AccessKeyLastUsed x -> AccessKeyLastUsed)
-> Generic AccessKeyLastUsed
forall x. Rep AccessKeyLastUsed x -> AccessKeyLastUsed
forall x. AccessKeyLastUsed -> Rep AccessKeyLastUsed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessKeyLastUsed x -> AccessKeyLastUsed
$cfrom :: forall x. AccessKeyLastUsed -> Rep AccessKeyLastUsed x
Prelude.Generic)

-- |
-- Create a value of 'AccessKeyLastUsed' 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:
--
-- 'lastUsedDate', 'accessKeyLastUsed_lastUsedDate' - The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
-- access key was most recently used. This field is null in the following
-- situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM began tracking
--     this information.
--
-- -   There is no sign-in data associated with the user.
--
-- 'serviceName', 'accessKeyLastUsed_serviceName' - The name of the Amazon Web Services service with which this access key
-- was most recently used. The value of this field is \"N\/A\" in the
-- following situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM started
--     tracking this information.
--
-- -   There is no sign-in data associated with the user.
--
-- 'region', 'accessKeyLastUsed_region' - The Amazon Web Services Region where this access key was most recently
-- used. The value for this field is \"N\/A\" in the following situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM began tracking
--     this information.
--
-- -   There is no sign-in data associated with the user.
--
-- For more information about Amazon Web Services Regions, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and endpoints>
-- in the Amazon Web Services General Reference.
newAccessKeyLastUsed ::
  -- | 'lastUsedDate'
  Prelude.UTCTime ->
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'region'
  Prelude.Text ->
  AccessKeyLastUsed
newAccessKeyLastUsed :: UTCTime -> Text -> Text -> AccessKeyLastUsed
newAccessKeyLastUsed
  UTCTime
pLastUsedDate_
  Text
pServiceName_
  Text
pRegion_ =
    AccessKeyLastUsed' :: ISO8601 -> Text -> Text -> AccessKeyLastUsed
AccessKeyLastUsed'
      { $sel:lastUsedDate:AccessKeyLastUsed' :: ISO8601
lastUsedDate =
          Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastUsedDate_,
        $sel:serviceName:AccessKeyLastUsed' :: Text
serviceName = Text
pServiceName_,
        $sel:region:AccessKeyLastUsed' :: Text
region = Text
pRegion_
      }

-- | The date and time, in
-- <http://www.iso.org/iso/iso8601 ISO 8601 date-time format>, when the
-- access key was most recently used. This field is null in the following
-- situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM began tracking
--     this information.
--
-- -   There is no sign-in data associated with the user.
accessKeyLastUsed_lastUsedDate :: Lens.Lens' AccessKeyLastUsed Prelude.UTCTime
accessKeyLastUsed_lastUsedDate :: (UTCTime -> f UTCTime) -> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_lastUsedDate = (AccessKeyLastUsed -> ISO8601)
-> (AccessKeyLastUsed -> ISO8601 -> AccessKeyLastUsed)
-> Lens AccessKeyLastUsed AccessKeyLastUsed ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {ISO8601
lastUsedDate :: ISO8601
$sel:lastUsedDate:AccessKeyLastUsed' :: AccessKeyLastUsed -> ISO8601
lastUsedDate} -> ISO8601
lastUsedDate) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} ISO8601
a -> AccessKeyLastUsed
s {$sel:lastUsedDate:AccessKeyLastUsed' :: ISO8601
lastUsedDate = ISO8601
a} :: AccessKeyLastUsed) ((ISO8601 -> f ISO8601)
 -> AccessKeyLastUsed -> f AccessKeyLastUsed)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> AccessKeyLastUsed
-> f AccessKeyLastUsed
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the Amazon Web Services service with which this access key
-- was most recently used. The value of this field is \"N\/A\" in the
-- following situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM started
--     tracking this information.
--
-- -   There is no sign-in data associated with the user.
accessKeyLastUsed_serviceName :: Lens.Lens' AccessKeyLastUsed Prelude.Text
accessKeyLastUsed_serviceName :: (Text -> f Text) -> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_serviceName = (AccessKeyLastUsed -> Text)
-> (AccessKeyLastUsed -> Text -> AccessKeyLastUsed)
-> Lens AccessKeyLastUsed AccessKeyLastUsed Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {Text
serviceName :: Text
$sel:serviceName:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
serviceName} -> Text
serviceName) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} Text
a -> AccessKeyLastUsed
s {$sel:serviceName:AccessKeyLastUsed' :: Text
serviceName = Text
a} :: AccessKeyLastUsed)

-- | The Amazon Web Services Region where this access key was most recently
-- used. The value for this field is \"N\/A\" in the following situations:
--
-- -   The user does not have an access key.
--
-- -   An access key exists but has not been used since IAM began tracking
--     this information.
--
-- -   There is no sign-in data associated with the user.
--
-- For more information about Amazon Web Services Regions, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and endpoints>
-- in the Amazon Web Services General Reference.
accessKeyLastUsed_region :: Lens.Lens' AccessKeyLastUsed Prelude.Text
accessKeyLastUsed_region :: (Text -> f Text) -> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_region = (AccessKeyLastUsed -> Text)
-> (AccessKeyLastUsed -> Text -> AccessKeyLastUsed)
-> Lens AccessKeyLastUsed AccessKeyLastUsed Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {Text
region :: Text
$sel:region:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
region} -> Text
region) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} Text
a -> AccessKeyLastUsed
s {$sel:region:AccessKeyLastUsed' :: Text
region = Text
a} :: AccessKeyLastUsed)

instance Core.FromXML AccessKeyLastUsed where
  parseXML :: [Node] -> Either String AccessKeyLastUsed
parseXML [Node]
x =
    ISO8601 -> Text -> Text -> AccessKeyLastUsed
AccessKeyLastUsed'
      (ISO8601 -> Text -> Text -> AccessKeyLastUsed)
-> Either String ISO8601
-> Either String (Text -> Text -> AccessKeyLastUsed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"LastUsedDate")
      Either String (Text -> Text -> AccessKeyLastUsed)
-> Either String Text -> Either String (Text -> AccessKeyLastUsed)
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 -> AccessKeyLastUsed)
-> Either String Text -> Either String AccessKeyLastUsed
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
"Region")

instance Prelude.Hashable AccessKeyLastUsed

instance Prelude.NFData AccessKeyLastUsed