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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 :: Data.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
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]
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
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. 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'
      { $sel:lastUsedDate:AccessKeyLastUsed' :: ISO8601
lastUsedDate =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' AccessKeyLastUsed UTCTime
accessKeyLastUsed_lastUsedDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._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 :: Lens' AccessKeyLastUsed Text
accessKeyLastUsed_serviceName = 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 :: Lens' AccessKeyLastUsed Text
accessKeyLastUsed_region = 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 Data.FromXML AccessKeyLastUsed where
  parseXML :: [Node] -> Either String AccessKeyLastUsed
parseXML [Node]
x =
    ISO8601 -> Text -> Text -> AccessKeyLastUsed
AccessKeyLastUsed'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"LastUsedDate")
      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
"ServiceName")
      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
"Region")

instance Prelude.Hashable AccessKeyLastUsed where
  hashWithSalt :: Int -> AccessKeyLastUsed -> Int
hashWithSalt Int
_salt AccessKeyLastUsed' {Text
ISO8601
region :: Text
serviceName :: Text
lastUsedDate :: ISO8601
$sel:region:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
$sel:serviceName:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
$sel:lastUsedDate:AccessKeyLastUsed' :: AccessKeyLastUsed -> ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
lastUsedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
region

instance Prelude.NFData AccessKeyLastUsed where
  rnf :: AccessKeyLastUsed -> ()
rnf AccessKeyLastUsed' {Text
ISO8601
region :: Text
serviceName :: Text
lastUsedDate :: ISO8601
$sel:region:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
$sel:serviceName:AccessKeyLastUsed' :: AccessKeyLastUsed -> Text
$sel:lastUsedDate:AccessKeyLastUsed' :: AccessKeyLastUsed -> ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ISO8601
lastUsedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serviceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
region