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

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

-- | Describes the last time an access key was used.
--
-- This object does not include data in the response of a
-- CreateBucketAccessKey action.
--
-- /See:/ 'newAccessKeyLastUsed' smart constructor.
data AccessKeyLastUsed = AccessKeyLastUsed'
  { -- | The date and time when the access key was most recently used.
    --
    -- This value is null if the access key has not been used.
    AccessKeyLastUsed -> Maybe POSIX
lastUsedDate :: Prelude.Maybe Core.POSIX,
    -- | The name of the AWS service with which this access key was most recently
    -- used.
    --
    -- This value is @N\/A@ if the access key has not been used.
    AccessKeyLastUsed -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text,
    -- | The AWS Region where this access key was most recently used.
    --
    -- This value is @N\/A@ if the access key has not been used.
    AccessKeyLastUsed -> Maybe Text
region :: Prelude.Maybe 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 when the access key was most recently used.
--
-- This value is null if the access key has not been used.
--
-- 'serviceName', 'accessKeyLastUsed_serviceName' - The name of the AWS service with which this access key was most recently
-- used.
--
-- This value is @N\/A@ if the access key has not been used.
--
-- 'region', 'accessKeyLastUsed_region' - The AWS Region where this access key was most recently used.
--
-- This value is @N\/A@ if the access key has not been used.
newAccessKeyLastUsed ::
  AccessKeyLastUsed
newAccessKeyLastUsed :: AccessKeyLastUsed
newAccessKeyLastUsed =
  AccessKeyLastUsed' :: Maybe POSIX -> Maybe Text -> Maybe Text -> AccessKeyLastUsed
AccessKeyLastUsed'
    { $sel:lastUsedDate:AccessKeyLastUsed' :: Maybe POSIX
lastUsedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:AccessKeyLastUsed' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:AccessKeyLastUsed' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the access key was most recently used.
--
-- This value is null if the access key has not been used.
accessKeyLastUsed_lastUsedDate :: Lens.Lens' AccessKeyLastUsed (Prelude.Maybe Prelude.UTCTime)
accessKeyLastUsed_lastUsedDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_lastUsedDate = (AccessKeyLastUsed -> Maybe POSIX)
-> (AccessKeyLastUsed -> Maybe POSIX -> AccessKeyLastUsed)
-> Lens
     AccessKeyLastUsed AccessKeyLastUsed (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {Maybe POSIX
lastUsedDate :: Maybe POSIX
$sel:lastUsedDate:AccessKeyLastUsed' :: AccessKeyLastUsed -> Maybe POSIX
lastUsedDate} -> Maybe POSIX
lastUsedDate) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} Maybe POSIX
a -> AccessKeyLastUsed
s {$sel:lastUsedDate:AccessKeyLastUsed' :: Maybe POSIX
lastUsedDate = Maybe POSIX
a} :: AccessKeyLastUsed) ((Maybe POSIX -> f (Maybe POSIX))
 -> AccessKeyLastUsed -> f AccessKeyLastUsed)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessKeyLastUsed
-> f AccessKeyLastUsed
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the AWS service with which this access key was most recently
-- used.
--
-- This value is @N\/A@ if the access key has not been used.
accessKeyLastUsed_serviceName :: Lens.Lens' AccessKeyLastUsed (Prelude.Maybe Prelude.Text)
accessKeyLastUsed_serviceName :: (Maybe Text -> f (Maybe Text))
-> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_serviceName = (AccessKeyLastUsed -> Maybe Text)
-> (AccessKeyLastUsed -> Maybe Text -> AccessKeyLastUsed)
-> Lens
     AccessKeyLastUsed AccessKeyLastUsed (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:AccessKeyLastUsed' :: AccessKeyLastUsed -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} Maybe Text
a -> AccessKeyLastUsed
s {$sel:serviceName:AccessKeyLastUsed' :: Maybe Text
serviceName = Maybe Text
a} :: AccessKeyLastUsed)

-- | The AWS Region where this access key was most recently used.
--
-- This value is @N\/A@ if the access key has not been used.
accessKeyLastUsed_region :: Lens.Lens' AccessKeyLastUsed (Prelude.Maybe Prelude.Text)
accessKeyLastUsed_region :: (Maybe Text -> f (Maybe Text))
-> AccessKeyLastUsed -> f AccessKeyLastUsed
accessKeyLastUsed_region = (AccessKeyLastUsed -> Maybe Text)
-> (AccessKeyLastUsed -> Maybe Text -> AccessKeyLastUsed)
-> Lens
     AccessKeyLastUsed AccessKeyLastUsed (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyLastUsed' {Maybe Text
region :: Maybe Text
$sel:region:AccessKeyLastUsed' :: AccessKeyLastUsed -> Maybe Text
region} -> Maybe Text
region) (\s :: AccessKeyLastUsed
s@AccessKeyLastUsed' {} Maybe Text
a -> AccessKeyLastUsed
s {$sel:region:AccessKeyLastUsed' :: Maybe Text
region = Maybe Text
a} :: AccessKeyLastUsed)

instance Core.FromJSON AccessKeyLastUsed where
  parseJSON :: Value -> Parser AccessKeyLastUsed
parseJSON =
    String
-> (Object -> Parser AccessKeyLastUsed)
-> Value
-> Parser AccessKeyLastUsed
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessKeyLastUsed"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe Text -> AccessKeyLastUsed
AccessKeyLastUsed'
            (Maybe POSIX -> Maybe Text -> Maybe Text -> AccessKeyLastUsed)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> AccessKeyLastUsed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUsedDate")
            Parser (Maybe Text -> Maybe Text -> AccessKeyLastUsed)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AccessKeyLastUsed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serviceName")
            Parser (Maybe Text -> AccessKeyLastUsed)
-> Parser (Maybe Text) -> Parser AccessKeyLastUsed
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"region")
      )

instance Prelude.Hashable AccessKeyLastUsed

instance Prelude.NFData AccessKeyLastUsed