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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.ISO8601
  }
  deriving (MFADevice -> MFADevice -> Bool
(MFADevice -> MFADevice -> Bool)
-> (MFADevice -> MFADevice -> Bool) -> Eq MFADevice
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]
(Int -> ReadS MFADevice)
-> ReadS [MFADevice]
-> ReadPrec MFADevice
-> ReadPrec [MFADevice]
-> Read 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
(Int -> MFADevice -> ShowS)
-> (MFADevice -> String)
-> ([MFADevice] -> ShowS)
-> Show MFADevice
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. MFADevice -> Rep MFADevice x)
-> (forall x. Rep MFADevice x -> MFADevice) -> Generic MFADevice
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' :: Text -> Text -> ISO8601 -> MFADevice
MFADevice'
    { $sel:userName:MFADevice' :: Text
userName = Text
pUserName_,
      $sel:serialNumber:MFADevice' :: Text
serialNumber = Text
pSerialNumber_,
      $sel:enableDate:MFADevice' :: ISO8601
enableDate = 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
pEnableDate_
    }

-- | The user with whom the MFA device is associated.
mfaDevice_userName :: Lens.Lens' MFADevice Prelude.Text
mfaDevice_userName :: (Text -> f Text) -> MFADevice -> f MFADevice
mfaDevice_userName = (MFADevice -> Text)
-> (MFADevice -> Text -> MFADevice)
-> Lens MFADevice MFADevice Text Text
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 :: (Text -> f Text) -> MFADevice -> f MFADevice
mfaDevice_serialNumber = (MFADevice -> Text)
-> (MFADevice -> Text -> MFADevice)
-> Lens MFADevice MFADevice Text Text
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 :: (UTCTime -> f UTCTime) -> MFADevice -> f MFADevice
mfaDevice_enableDate = (MFADevice -> ISO8601)
-> (MFADevice -> ISO8601 -> MFADevice)
-> Lens MFADevice MFADevice ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> MFADevice -> f MFADevice)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> MFADevice
-> f MFADevice
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

instance Core.FromXML MFADevice where
  parseXML :: [Node] -> Either String MFADevice
parseXML [Node]
x =
    Text -> Text -> ISO8601 -> MFADevice
MFADevice'
      (Text -> Text -> ISO8601 -> MFADevice)
-> Either String Text
-> Either String (Text -> ISO8601 -> MFADevice)
forall (f :: * -> *) a b. Functor 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
"UserName")
      Either String (Text -> ISO8601 -> MFADevice)
-> Either String Text -> Either String (ISO8601 -> MFADevice)
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
"SerialNumber")
      Either String (ISO8601 -> MFADevice)
-> Either String ISO8601 -> Either String MFADevice
forall (f :: * -> *) a b. Applicative f => 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
"EnableDate")

instance Prelude.Hashable MFADevice

instance Prelude.NFData MFADevice