{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ResyncMFADevice
-- 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)
--
-- Synchronizes the specified MFA device with its IAM resource object on
-- the Amazon Web Services servers.
--
-- For more information about creating and working with virtual MFA
-- devices, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_VirtualMFA.html Using a virtual MFA device>
-- in the /IAM User Guide/.
module Amazonka.IAM.ResyncMFADevice
  ( -- * Creating a Request
    ResyncMFADevice (..),
    newResyncMFADevice,

    -- * Request Lenses
    resyncMFADevice_userName,
    resyncMFADevice_serialNumber,
    resyncMFADevice_authenticationCode1,
    resyncMFADevice_authenticationCode2,

    -- * Destructuring the Response
    ResyncMFADeviceResponse (..),
    newResyncMFADeviceResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newResyncMFADevice' smart constructor.
data ResyncMFADevice = ResyncMFADevice'
  { -- | The name of the user whose MFA device you want to resynchronize.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    ResyncMFADevice -> Text
userName :: Prelude.Text,
    -- | Serial number that uniquely identifies the MFA device.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    ResyncMFADevice -> Text
serialNumber :: Prelude.Text,
    -- | An authentication code emitted by the device.
    --
    -- The format for this parameter is a sequence of six digits.
    ResyncMFADevice -> Text
authenticationCode1 :: Prelude.Text,
    -- | A subsequent authentication code emitted by the device.
    --
    -- The format for this parameter is a sequence of six digits.
    ResyncMFADevice -> Text
authenticationCode2 :: Prelude.Text
  }
  deriving (ResyncMFADevice -> ResyncMFADevice -> Bool
(ResyncMFADevice -> ResyncMFADevice -> Bool)
-> (ResyncMFADevice -> ResyncMFADevice -> Bool)
-> Eq ResyncMFADevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResyncMFADevice -> ResyncMFADevice -> Bool
$c/= :: ResyncMFADevice -> ResyncMFADevice -> Bool
== :: ResyncMFADevice -> ResyncMFADevice -> Bool
$c== :: ResyncMFADevice -> ResyncMFADevice -> Bool
Prelude.Eq, ReadPrec [ResyncMFADevice]
ReadPrec ResyncMFADevice
Int -> ReadS ResyncMFADevice
ReadS [ResyncMFADevice]
(Int -> ReadS ResyncMFADevice)
-> ReadS [ResyncMFADevice]
-> ReadPrec ResyncMFADevice
-> ReadPrec [ResyncMFADevice]
-> Read ResyncMFADevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResyncMFADevice]
$creadListPrec :: ReadPrec [ResyncMFADevice]
readPrec :: ReadPrec ResyncMFADevice
$creadPrec :: ReadPrec ResyncMFADevice
readList :: ReadS [ResyncMFADevice]
$creadList :: ReadS [ResyncMFADevice]
readsPrec :: Int -> ReadS ResyncMFADevice
$creadsPrec :: Int -> ReadS ResyncMFADevice
Prelude.Read, Int -> ResyncMFADevice -> ShowS
[ResyncMFADevice] -> ShowS
ResyncMFADevice -> String
(Int -> ResyncMFADevice -> ShowS)
-> (ResyncMFADevice -> String)
-> ([ResyncMFADevice] -> ShowS)
-> Show ResyncMFADevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResyncMFADevice] -> ShowS
$cshowList :: [ResyncMFADevice] -> ShowS
show :: ResyncMFADevice -> String
$cshow :: ResyncMFADevice -> String
showsPrec :: Int -> ResyncMFADevice -> ShowS
$cshowsPrec :: Int -> ResyncMFADevice -> ShowS
Prelude.Show, (forall x. ResyncMFADevice -> Rep ResyncMFADevice x)
-> (forall x. Rep ResyncMFADevice x -> ResyncMFADevice)
-> Generic ResyncMFADevice
forall x. Rep ResyncMFADevice x -> ResyncMFADevice
forall x. ResyncMFADevice -> Rep ResyncMFADevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResyncMFADevice x -> ResyncMFADevice
$cfrom :: forall x. ResyncMFADevice -> Rep ResyncMFADevice x
Prelude.Generic)

-- |
-- Create a value of 'ResyncMFADevice' 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', 'resyncMFADevice_userName' - The name of the user whose MFA device you want to resynchronize.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'serialNumber', 'resyncMFADevice_serialNumber' - Serial number that uniquely identifies the MFA device.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'authenticationCode1', 'resyncMFADevice_authenticationCode1' - An authentication code emitted by the device.
--
-- The format for this parameter is a sequence of six digits.
--
-- 'authenticationCode2', 'resyncMFADevice_authenticationCode2' - A subsequent authentication code emitted by the device.
--
-- The format for this parameter is a sequence of six digits.
newResyncMFADevice ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'serialNumber'
  Prelude.Text ->
  -- | 'authenticationCode1'
  Prelude.Text ->
  -- | 'authenticationCode2'
  Prelude.Text ->
  ResyncMFADevice
newResyncMFADevice :: Text -> Text -> Text -> Text -> ResyncMFADevice
newResyncMFADevice
  Text
pUserName_
  Text
pSerialNumber_
  Text
pAuthenticationCode1_
  Text
pAuthenticationCode2_ =
    ResyncMFADevice' :: Text -> Text -> Text -> Text -> ResyncMFADevice
ResyncMFADevice'
      { $sel:userName:ResyncMFADevice' :: Text
userName = Text
pUserName_,
        $sel:serialNumber:ResyncMFADevice' :: Text
serialNumber = Text
pSerialNumber_,
        $sel:authenticationCode1:ResyncMFADevice' :: Text
authenticationCode1 = Text
pAuthenticationCode1_,
        $sel:authenticationCode2:ResyncMFADevice' :: Text
authenticationCode2 = Text
pAuthenticationCode2_
      }

-- | The name of the user whose MFA device you want to resynchronize.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
resyncMFADevice_userName :: Lens.Lens' ResyncMFADevice Prelude.Text
resyncMFADevice_userName :: (Text -> f Text) -> ResyncMFADevice -> f ResyncMFADevice
resyncMFADevice_userName = (ResyncMFADevice -> Text)
-> (ResyncMFADevice -> Text -> ResyncMFADevice)
-> Lens ResyncMFADevice ResyncMFADevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResyncMFADevice' {Text
userName :: Text
$sel:userName:ResyncMFADevice' :: ResyncMFADevice -> Text
userName} -> Text
userName) (\s :: ResyncMFADevice
s@ResyncMFADevice' {} Text
a -> ResyncMFADevice
s {$sel:userName:ResyncMFADevice' :: Text
userName = Text
a} :: ResyncMFADevice)

-- | Serial number that uniquely identifies the MFA device.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
resyncMFADevice_serialNumber :: Lens.Lens' ResyncMFADevice Prelude.Text
resyncMFADevice_serialNumber :: (Text -> f Text) -> ResyncMFADevice -> f ResyncMFADevice
resyncMFADevice_serialNumber = (ResyncMFADevice -> Text)
-> (ResyncMFADevice -> Text -> ResyncMFADevice)
-> Lens ResyncMFADevice ResyncMFADevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResyncMFADevice' {Text
serialNumber :: Text
$sel:serialNumber:ResyncMFADevice' :: ResyncMFADevice -> Text
serialNumber} -> Text
serialNumber) (\s :: ResyncMFADevice
s@ResyncMFADevice' {} Text
a -> ResyncMFADevice
s {$sel:serialNumber:ResyncMFADevice' :: Text
serialNumber = Text
a} :: ResyncMFADevice)

-- | An authentication code emitted by the device.
--
-- The format for this parameter is a sequence of six digits.
resyncMFADevice_authenticationCode1 :: Lens.Lens' ResyncMFADevice Prelude.Text
resyncMFADevice_authenticationCode1 :: (Text -> f Text) -> ResyncMFADevice -> f ResyncMFADevice
resyncMFADevice_authenticationCode1 = (ResyncMFADevice -> Text)
-> (ResyncMFADevice -> Text -> ResyncMFADevice)
-> Lens ResyncMFADevice ResyncMFADevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResyncMFADevice' {Text
authenticationCode1 :: Text
$sel:authenticationCode1:ResyncMFADevice' :: ResyncMFADevice -> Text
authenticationCode1} -> Text
authenticationCode1) (\s :: ResyncMFADevice
s@ResyncMFADevice' {} Text
a -> ResyncMFADevice
s {$sel:authenticationCode1:ResyncMFADevice' :: Text
authenticationCode1 = Text
a} :: ResyncMFADevice)

-- | A subsequent authentication code emitted by the device.
--
-- The format for this parameter is a sequence of six digits.
resyncMFADevice_authenticationCode2 :: Lens.Lens' ResyncMFADevice Prelude.Text
resyncMFADevice_authenticationCode2 :: (Text -> f Text) -> ResyncMFADevice -> f ResyncMFADevice
resyncMFADevice_authenticationCode2 = (ResyncMFADevice -> Text)
-> (ResyncMFADevice -> Text -> ResyncMFADevice)
-> Lens ResyncMFADevice ResyncMFADevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResyncMFADevice' {Text
authenticationCode2 :: Text
$sel:authenticationCode2:ResyncMFADevice' :: ResyncMFADevice -> Text
authenticationCode2} -> Text
authenticationCode2) (\s :: ResyncMFADevice
s@ResyncMFADevice' {} Text
a -> ResyncMFADevice
s {$sel:authenticationCode2:ResyncMFADevice' :: Text
authenticationCode2 = Text
a} :: ResyncMFADevice)

instance Core.AWSRequest ResyncMFADevice where
  type
    AWSResponse ResyncMFADevice =
      ResyncMFADeviceResponse
  request :: ResyncMFADevice -> Request ResyncMFADevice
request = Service -> ResyncMFADevice -> Request ResyncMFADevice
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ResyncMFADevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResyncMFADevice)))
response =
    AWSResponse ResyncMFADevice
-> Logger
-> Service
-> Proxy ResyncMFADevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResyncMFADevice)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse ResyncMFADevice
ResyncMFADeviceResponse
ResyncMFADeviceResponse'

instance Prelude.Hashable ResyncMFADevice

instance Prelude.NFData ResyncMFADevice

instance Core.ToHeaders ResyncMFADevice where
  toHeaders :: ResyncMFADevice -> [Header]
toHeaders = [Header] -> ResyncMFADevice -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ResyncMFADevice where
  toPath :: ResyncMFADevice -> ByteString
toPath = ByteString -> ResyncMFADevice -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ResyncMFADevice where
  toQuery :: ResyncMFADevice -> QueryString
toQuery ResyncMFADevice' {Text
authenticationCode2 :: Text
authenticationCode1 :: Text
serialNumber :: Text
userName :: Text
$sel:authenticationCode2:ResyncMFADevice' :: ResyncMFADevice -> Text
$sel:authenticationCode1:ResyncMFADevice' :: ResyncMFADevice -> Text
$sel:serialNumber:ResyncMFADevice' :: ResyncMFADevice -> Text
$sel:userName:ResyncMFADevice' :: ResyncMFADevice -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ResyncMFADevice" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userName,
        ByteString
"SerialNumber" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
serialNumber,
        ByteString
"AuthenticationCode1" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
authenticationCode1,
        ByteString
"AuthenticationCode2" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
authenticationCode2
      ]

-- | /See:/ 'newResyncMFADeviceResponse' smart constructor.
data ResyncMFADeviceResponse = ResyncMFADeviceResponse'
  {
  }
  deriving (ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool
(ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool)
-> (ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool)
-> Eq ResyncMFADeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool
$c/= :: ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool
== :: ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool
$c== :: ResyncMFADeviceResponse -> ResyncMFADeviceResponse -> Bool
Prelude.Eq, ReadPrec [ResyncMFADeviceResponse]
ReadPrec ResyncMFADeviceResponse
Int -> ReadS ResyncMFADeviceResponse
ReadS [ResyncMFADeviceResponse]
(Int -> ReadS ResyncMFADeviceResponse)
-> ReadS [ResyncMFADeviceResponse]
-> ReadPrec ResyncMFADeviceResponse
-> ReadPrec [ResyncMFADeviceResponse]
-> Read ResyncMFADeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResyncMFADeviceResponse]
$creadListPrec :: ReadPrec [ResyncMFADeviceResponse]
readPrec :: ReadPrec ResyncMFADeviceResponse
$creadPrec :: ReadPrec ResyncMFADeviceResponse
readList :: ReadS [ResyncMFADeviceResponse]
$creadList :: ReadS [ResyncMFADeviceResponse]
readsPrec :: Int -> ReadS ResyncMFADeviceResponse
$creadsPrec :: Int -> ReadS ResyncMFADeviceResponse
Prelude.Read, Int -> ResyncMFADeviceResponse -> ShowS
[ResyncMFADeviceResponse] -> ShowS
ResyncMFADeviceResponse -> String
(Int -> ResyncMFADeviceResponse -> ShowS)
-> (ResyncMFADeviceResponse -> String)
-> ([ResyncMFADeviceResponse] -> ShowS)
-> Show ResyncMFADeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResyncMFADeviceResponse] -> ShowS
$cshowList :: [ResyncMFADeviceResponse] -> ShowS
show :: ResyncMFADeviceResponse -> String
$cshow :: ResyncMFADeviceResponse -> String
showsPrec :: Int -> ResyncMFADeviceResponse -> ShowS
$cshowsPrec :: Int -> ResyncMFADeviceResponse -> ShowS
Prelude.Show, (forall x.
 ResyncMFADeviceResponse -> Rep ResyncMFADeviceResponse x)
-> (forall x.
    Rep ResyncMFADeviceResponse x -> ResyncMFADeviceResponse)
-> Generic ResyncMFADeviceResponse
forall x. Rep ResyncMFADeviceResponse x -> ResyncMFADeviceResponse
forall x. ResyncMFADeviceResponse -> Rep ResyncMFADeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResyncMFADeviceResponse x -> ResyncMFADeviceResponse
$cfrom :: forall x. ResyncMFADeviceResponse -> Rep ResyncMFADeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'ResyncMFADeviceResponse' 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.
newResyncMFADeviceResponse ::
  ResyncMFADeviceResponse
newResyncMFADeviceResponse :: ResyncMFADeviceResponse
newResyncMFADeviceResponse = ResyncMFADeviceResponse
ResyncMFADeviceResponse'

instance Prelude.NFData ResyncMFADeviceResponse