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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.Tag
import Amazonka.IAM.Types.User
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a virtual MFA device.
--
-- /See:/ 'newVirtualMFADevice' smart constructor.
data VirtualMFADevice = VirtualMFADevice'
  { -- | The base32 seed defined as specified in
    -- <https://tools.ietf.org/html/rfc3548.txt RFC3548>. The
    -- @Base32StringSeed@ is base64-encoded.
    VirtualMFADevice -> Maybe (Sensitive Base64)
base32StringSeed :: Prelude.Maybe (Data.Sensitive Data.Base64),
    -- | The date and time on which the virtual MFA device was enabled.
    VirtualMFADevice -> Maybe ISO8601
enableDate :: Prelude.Maybe Data.ISO8601,
    -- | A QR code PNG image that encodes
    -- @otpauth:\/\/totp\/$virtualMFADeviceName\@$AccountName?secret=$Base32String@
    -- where @$virtualMFADeviceName@ is one of the create call arguments.
    -- @AccountName@ is the user name if set (otherwise, the account ID
    -- otherwise), and @Base32String@ is the seed in base32 format. The
    -- @Base32String@ value is base64-encoded.
    VirtualMFADevice -> Maybe (Sensitive Base64)
qRCodePNG :: Prelude.Maybe (Data.Sensitive Data.Base64),
    -- | A list of tags that are attached to the virtual MFA device. For more
    -- information about tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    VirtualMFADevice -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The IAM user associated with this virtual MFA device.
    VirtualMFADevice -> Maybe User
user :: Prelude.Maybe User,
    -- | The serial number associated with @VirtualMFADevice@.
    VirtualMFADevice -> Text
serialNumber :: Prelude.Text
  }
  deriving (VirtualMFADevice -> VirtualMFADevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualMFADevice -> VirtualMFADevice -> Bool
$c/= :: VirtualMFADevice -> VirtualMFADevice -> Bool
== :: VirtualMFADevice -> VirtualMFADevice -> Bool
$c== :: VirtualMFADevice -> VirtualMFADevice -> Bool
Prelude.Eq, Int -> VirtualMFADevice -> ShowS
[VirtualMFADevice] -> ShowS
VirtualMFADevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualMFADevice] -> ShowS
$cshowList :: [VirtualMFADevice] -> ShowS
show :: VirtualMFADevice -> String
$cshow :: VirtualMFADevice -> String
showsPrec :: Int -> VirtualMFADevice -> ShowS
$cshowsPrec :: Int -> VirtualMFADevice -> ShowS
Prelude.Show, forall x. Rep VirtualMFADevice x -> VirtualMFADevice
forall x. VirtualMFADevice -> Rep VirtualMFADevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualMFADevice x -> VirtualMFADevice
$cfrom :: forall x. VirtualMFADevice -> Rep VirtualMFADevice x
Prelude.Generic)

-- |
-- Create a value of 'VirtualMFADevice' 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:
--
-- 'base32StringSeed', 'virtualMFADevice_base32StringSeed' - The base32 seed defined as specified in
-- <https://tools.ietf.org/html/rfc3548.txt RFC3548>. The
-- @Base32StringSeed@ is base64-encoded.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'enableDate', 'virtualMFADevice_enableDate' - The date and time on which the virtual MFA device was enabled.
--
-- 'qRCodePNG', 'virtualMFADevice_qRCodePNG' - A QR code PNG image that encodes
-- @otpauth:\/\/totp\/$virtualMFADeviceName\@$AccountName?secret=$Base32String@
-- where @$virtualMFADeviceName@ is one of the create call arguments.
-- @AccountName@ is the user name if set (otherwise, the account ID
-- otherwise), and @Base32String@ is the seed in base32 format. The
-- @Base32String@ value is base64-encoded.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'tags', 'virtualMFADevice_tags' - A list of tags that are attached to the virtual MFA device. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- 'user', 'virtualMFADevice_user' - The IAM user associated with this virtual MFA device.
--
-- 'serialNumber', 'virtualMFADevice_serialNumber' - The serial number associated with @VirtualMFADevice@.
newVirtualMFADevice ::
  -- | 'serialNumber'
  Prelude.Text ->
  VirtualMFADevice
newVirtualMFADevice :: Text -> VirtualMFADevice
newVirtualMFADevice Text
pSerialNumber_ =
  VirtualMFADevice'
    { $sel:base32StringSeed:VirtualMFADevice' :: Maybe (Sensitive Base64)
base32StringSeed =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enableDate:VirtualMFADevice' :: Maybe ISO8601
enableDate = forall a. Maybe a
Prelude.Nothing,
      $sel:qRCodePNG:VirtualMFADevice' :: Maybe (Sensitive Base64)
qRCodePNG = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:VirtualMFADevice' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:user:VirtualMFADevice' :: Maybe User
user = forall a. Maybe a
Prelude.Nothing,
      $sel:serialNumber:VirtualMFADevice' :: Text
serialNumber = Text
pSerialNumber_
    }

-- | The base32 seed defined as specified in
-- <https://tools.ietf.org/html/rfc3548.txt RFC3548>. The
-- @Base32StringSeed@ is base64-encoded.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
virtualMFADevice_base32StringSeed :: Lens.Lens' VirtualMFADevice (Prelude.Maybe Prelude.ByteString)
virtualMFADevice_base32StringSeed :: Lens' VirtualMFADevice (Maybe ByteString)
virtualMFADevice_base32StringSeed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Maybe (Sensitive Base64)
base32StringSeed :: Maybe (Sensitive Base64)
$sel:base32StringSeed:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
base32StringSeed} -> Maybe (Sensitive Base64)
base32StringSeed) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Maybe (Sensitive Base64)
a -> VirtualMFADevice
s {$sel:base32StringSeed:VirtualMFADevice' :: Maybe (Sensitive Base64)
base32StringSeed = Maybe (Sensitive Base64)
a} :: VirtualMFADevice) 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. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64)

-- | The date and time on which the virtual MFA device was enabled.
virtualMFADevice_enableDate :: Lens.Lens' VirtualMFADevice (Prelude.Maybe Prelude.UTCTime)
virtualMFADevice_enableDate :: Lens' VirtualMFADevice (Maybe UTCTime)
virtualMFADevice_enableDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Maybe ISO8601
enableDate :: Maybe ISO8601
$sel:enableDate:VirtualMFADevice' :: VirtualMFADevice -> Maybe ISO8601
enableDate} -> Maybe ISO8601
enableDate) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Maybe ISO8601
a -> VirtualMFADevice
s {$sel:enableDate:VirtualMFADevice' :: Maybe ISO8601
enableDate = Maybe ISO8601
a} :: VirtualMFADevice) 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

-- | A QR code PNG image that encodes
-- @otpauth:\/\/totp\/$virtualMFADeviceName\@$AccountName?secret=$Base32String@
-- where @$virtualMFADeviceName@ is one of the create call arguments.
-- @AccountName@ is the user name if set (otherwise, the account ID
-- otherwise), and @Base32String@ is the seed in base32 format. The
-- @Base32String@ value is base64-encoded.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
virtualMFADevice_qRCodePNG :: Lens.Lens' VirtualMFADevice (Prelude.Maybe Prelude.ByteString)
virtualMFADevice_qRCodePNG :: Lens' VirtualMFADevice (Maybe ByteString)
virtualMFADevice_qRCodePNG = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Maybe (Sensitive Base64)
qRCodePNG :: Maybe (Sensitive Base64)
$sel:qRCodePNG:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
qRCodePNG} -> Maybe (Sensitive Base64)
qRCodePNG) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Maybe (Sensitive Base64)
a -> VirtualMFADevice
s {$sel:qRCodePNG:VirtualMFADevice' :: Maybe (Sensitive Base64)
qRCodePNG = Maybe (Sensitive Base64)
a} :: VirtualMFADevice) 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. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64)

-- | A list of tags that are attached to the virtual MFA device. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
virtualMFADevice_tags :: Lens.Lens' VirtualMFADevice (Prelude.Maybe [Tag])
virtualMFADevice_tags :: Lens' VirtualMFADevice (Maybe [Tag])
virtualMFADevice_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:VirtualMFADevice' :: VirtualMFADevice -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Maybe [Tag]
a -> VirtualMFADevice
s {$sel:tags:VirtualMFADevice' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: VirtualMFADevice) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The IAM user associated with this virtual MFA device.
virtualMFADevice_user :: Lens.Lens' VirtualMFADevice (Prelude.Maybe User)
virtualMFADevice_user :: Lens' VirtualMFADevice (Maybe User)
virtualMFADevice_user = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Maybe User
user :: Maybe User
$sel:user:VirtualMFADevice' :: VirtualMFADevice -> Maybe User
user} -> Maybe User
user) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Maybe User
a -> VirtualMFADevice
s {$sel:user:VirtualMFADevice' :: Maybe User
user = Maybe User
a} :: VirtualMFADevice)

-- | The serial number associated with @VirtualMFADevice@.
virtualMFADevice_serialNumber :: Lens.Lens' VirtualMFADevice Prelude.Text
virtualMFADevice_serialNumber :: Lens' VirtualMFADevice Text
virtualMFADevice_serialNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMFADevice' {Text
serialNumber :: Text
$sel:serialNumber:VirtualMFADevice' :: VirtualMFADevice -> Text
serialNumber} -> Text
serialNumber) (\s :: VirtualMFADevice
s@VirtualMFADevice' {} Text
a -> VirtualMFADevice
s {$sel:serialNumber:VirtualMFADevice' :: Text
serialNumber = Text
a} :: VirtualMFADevice)

instance Data.FromXML VirtualMFADevice where
  parseXML :: [Node] -> Either String VirtualMFADevice
parseXML [Node]
x =
    Maybe (Sensitive Base64)
-> Maybe ISO8601
-> Maybe (Sensitive Base64)
-> Maybe [Tag]
-> Maybe User
-> Text
-> VirtualMFADevice
VirtualMFADevice'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Base32StringSeed")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"EnableDate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"QRCodePNG")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Tags"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"User")
      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")

instance Prelude.Hashable VirtualMFADevice where
  hashWithSalt :: Int -> VirtualMFADevice -> Int
hashWithSalt Int
_salt VirtualMFADevice' {Maybe [Tag]
Maybe (Sensitive Base64)
Maybe ISO8601
Maybe User
Text
serialNumber :: Text
user :: Maybe User
tags :: Maybe [Tag]
qRCodePNG :: Maybe (Sensitive Base64)
enableDate :: Maybe ISO8601
base32StringSeed :: Maybe (Sensitive Base64)
$sel:serialNumber:VirtualMFADevice' :: VirtualMFADevice -> Text
$sel:user:VirtualMFADevice' :: VirtualMFADevice -> Maybe User
$sel:tags:VirtualMFADevice' :: VirtualMFADevice -> Maybe [Tag]
$sel:qRCodePNG:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
$sel:enableDate:VirtualMFADevice' :: VirtualMFADevice -> Maybe ISO8601
$sel:base32StringSeed:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Base64)
base32StringSeed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
enableDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Base64)
qRCodePNG
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe User
user
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serialNumber

instance Prelude.NFData VirtualMFADevice where
  rnf :: VirtualMFADevice -> ()
rnf VirtualMFADevice' {Maybe [Tag]
Maybe (Sensitive Base64)
Maybe ISO8601
Maybe User
Text
serialNumber :: Text
user :: Maybe User
tags :: Maybe [Tag]
qRCodePNG :: Maybe (Sensitive Base64)
enableDate :: Maybe ISO8601
base32StringSeed :: Maybe (Sensitive Base64)
$sel:serialNumber:VirtualMFADevice' :: VirtualMFADevice -> Text
$sel:user:VirtualMFADevice' :: VirtualMFADevice -> Maybe User
$sel:tags:VirtualMFADevice' :: VirtualMFADevice -> Maybe [Tag]
$sel:qRCodePNG:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
$sel:enableDate:VirtualMFADevice' :: VirtualMFADevice -> Maybe ISO8601
$sel:base32StringSeed:VirtualMFADevice' :: VirtualMFADevice -> Maybe (Sensitive Base64)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Base64)
base32StringSeed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
enableDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Base64)
qRCodePNG
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe User
user
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serialNumber