{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lightsail.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

-- | Describes the last time an access key was used.
--
-- This object does not include data in the response of a
-- <https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_CreateBucketAccessKey.html 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 Data.POSIX,
    -- | The Amazon Web Services 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,
    -- | The name of the Amazon Web Services 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
  }
  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 when the access key was most recently used.
--
-- This value is null if the access key has not been used.
--
-- 'region', 'accessKeyLastUsed_region' - The Amazon Web Services Region where this access key was most recently
-- used.
--
-- This value is @N\/A@ if the access key has not been used.
--
-- 'serviceName', 'accessKeyLastUsed_serviceName' - The name of the Amazon Web Services service with which 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'
    { $sel:lastUsedDate:AccessKeyLastUsed' :: Maybe POSIX
lastUsedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:region:AccessKeyLastUsed' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:AccessKeyLastUsed' :: Maybe Text
serviceName = 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 :: Lens' AccessKeyLastUsed (Maybe UTCTime)
accessKeyLastUsed_lastUsedDate = 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) 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 Amazon Web Services 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 :: Lens' AccessKeyLastUsed (Maybe Text)
accessKeyLastUsed_region = 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)

-- | The name of the Amazon Web Services 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 :: Lens' AccessKeyLastUsed (Maybe Text)
accessKeyLastUsed_serviceName = 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)

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

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

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