{-# 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.MFADevice
-- 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.MFADevice 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 an MFA device.
--
-- This data type is used as a response element in the ListMFADevices
-- operation.
--
-- /See:/ 'newMFADevice' smart constructor.
data MFADevice = MFADevice'
  { -- | The user with whom the MFA device is associated.
    MFADevice -> Text
userName :: Prelude.Text,
    -- | The serial number that uniquely identifies the MFA device. For virtual
    -- MFA devices, the serial number is the device ARN.
    MFADevice -> Text
serialNumber :: Prelude.Text,
    -- | The date when the MFA device was enabled for the user.
    MFADevice -> ISO8601
enableDate :: Data.ISO8601
  }
  deriving (MFADevice -> MFADevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MFADevice -> MFADevice -> Bool
$c/= :: MFADevice -> MFADevice -> Bool
== :: MFADevice -> MFADevice -> Bool
$c== :: MFADevice -> MFADevice -> Bool
Prelude.Eq, ReadPrec [MFADevice]
ReadPrec MFADevice
Int -> ReadS MFADevice
ReadS [MFADevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MFADevice]
$creadListPrec :: ReadPrec [MFADevice]
readPrec :: ReadPrec MFADevice
$creadPrec :: ReadPrec MFADevice
readList :: ReadS [MFADevice]
$creadList :: ReadS [MFADevice]
readsPrec :: Int -> ReadS MFADevice
$creadsPrec :: Int -> ReadS MFADevice
Prelude.Read, Int -> MFADevice -> ShowS
[MFADevice] -> ShowS
MFADevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MFADevice] -> ShowS
$cshowList :: [MFADevice] -> ShowS
show :: MFADevice -> String
$cshow :: MFADevice -> String
showsPrec :: Int -> MFADevice -> ShowS
$cshowsPrec :: Int -> MFADevice -> ShowS
Prelude.Show, forall x. Rep MFADevice x -> MFADevice
forall x. MFADevice -> Rep MFADevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MFADevice x -> MFADevice
$cfrom :: forall x. MFADevice -> Rep MFADevice x
Prelude.Generic)

-- |
-- Create a value of 'MFADevice' 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:
--
-- 'userName', 'mfaDevice_userName' - The user with whom the MFA device is associated.
--
-- 'serialNumber', 'mfaDevice_serialNumber' - The serial number that uniquely identifies the MFA device. For virtual
-- MFA devices, the serial number is the device ARN.
--
-- 'enableDate', 'mfaDevice_enableDate' - The date when the MFA device was enabled for the user.
newMFADevice ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'serialNumber'
  Prelude.Text ->
  -- | 'enableDate'
  Prelude.UTCTime ->
  MFADevice
newMFADevice :: Text -> Text -> UTCTime -> MFADevice
newMFADevice Text
pUserName_ Text
pSerialNumber_ UTCTime
pEnableDate_ =
  MFADevice'
    { $sel:userName:MFADevice' :: Text
userName = Text
pUserName_,
      $sel:serialNumber:MFADevice' :: Text
serialNumber = Text
pSerialNumber_,
      $sel:enableDate:MFADevice' :: ISO8601
enableDate = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEnableDate_
    }

-- | The user with whom the MFA device is associated.
mfaDevice_userName :: Lens.Lens' MFADevice Prelude.Text
mfaDevice_userName :: Lens' MFADevice Text
mfaDevice_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MFADevice' {Text
userName :: Text
$sel:userName:MFADevice' :: MFADevice -> Text
userName} -> Text
userName) (\s :: MFADevice
s@MFADevice' {} Text
a -> MFADevice
s {$sel:userName:MFADevice' :: Text
userName = Text
a} :: MFADevice)

-- | The serial number that uniquely identifies the MFA device. For virtual
-- MFA devices, the serial number is the device ARN.
mfaDevice_serialNumber :: Lens.Lens' MFADevice Prelude.Text
mfaDevice_serialNumber :: Lens' MFADevice Text
mfaDevice_serialNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MFADevice' {Text
serialNumber :: Text
$sel:serialNumber:MFADevice' :: MFADevice -> Text
serialNumber} -> Text
serialNumber) (\s :: MFADevice
s@MFADevice' {} Text
a -> MFADevice
s {$sel:serialNumber:MFADevice' :: Text
serialNumber = Text
a} :: MFADevice)

-- | The date when the MFA device was enabled for the user.
mfaDevice_enableDate :: Lens.Lens' MFADevice Prelude.UTCTime
mfaDevice_enableDate :: Lens' MFADevice UTCTime
mfaDevice_enableDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MFADevice' {ISO8601
enableDate :: ISO8601
$sel:enableDate:MFADevice' :: MFADevice -> ISO8601
enableDate} -> ISO8601
enableDate) (\s :: MFADevice
s@MFADevice' {} ISO8601
a -> MFADevice
s {$sel:enableDate:MFADevice' :: ISO8601
enableDate = ISO8601
a} :: MFADevice) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML MFADevice where
  parseXML :: [Node] -> Either String MFADevice
parseXML [Node]
x =
    Text -> Text -> ISO8601 -> MFADevice
MFADevice'
      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
"UserName")
      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
"SerialNumber")
      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
"EnableDate")

instance Prelude.Hashable MFADevice where
  hashWithSalt :: Int -> MFADevice -> Int
hashWithSalt Int
_salt MFADevice' {Text
ISO8601
enableDate :: ISO8601
serialNumber :: Text
userName :: Text
$sel:enableDate:MFADevice' :: MFADevice -> ISO8601
$sel:serialNumber:MFADevice' :: MFADevice -> Text
$sel:userName:MFADevice' :: MFADevice -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serialNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
enableDate

instance Prelude.NFData MFADevice where
  rnf :: MFADevice -> ()
rnf MFADevice' {Text
ISO8601
enableDate :: ISO8601
serialNumber :: Text
userName :: Text
$sel:enableDate:MFADevice' :: MFADevice -> ISO8601
$sel:serialNumber:MFADevice' :: MFADevice -> Text
$sel:userName:MFADevice' :: MFADevice -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serialNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
enableDate