{-# 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.CognitoIdentityProvider.Types.MFAOptionType
-- 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.CognitoIdentityProvider.Types.MFAOptionType where

import Amazonka.CognitoIdentityProvider.Types.DeliveryMediumType
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

-- | /This data type is no longer supported./ Applies only to SMS
-- multi-factor authentication (MFA) configurations. Does not apply to
-- time-based one-time password (TOTP) software token MFA configurations.
--
-- /See:/ 'newMFAOptionType' smart constructor.
data MFAOptionType = MFAOptionType'
  { -- | The attribute name of the MFA option type. The only valid value is
    -- @phone_number@.
    MFAOptionType -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text,
    -- | The delivery medium to send the MFA code. You can use this parameter to
    -- set only the @SMS@ delivery medium value.
    MFAOptionType -> Maybe DeliveryMediumType
deliveryMedium :: Prelude.Maybe DeliveryMediumType
  }
  deriving (MFAOptionType -> MFAOptionType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MFAOptionType -> MFAOptionType -> Bool
$c/= :: MFAOptionType -> MFAOptionType -> Bool
== :: MFAOptionType -> MFAOptionType -> Bool
$c== :: MFAOptionType -> MFAOptionType -> Bool
Prelude.Eq, ReadPrec [MFAOptionType]
ReadPrec MFAOptionType
Int -> ReadS MFAOptionType
ReadS [MFAOptionType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MFAOptionType]
$creadListPrec :: ReadPrec [MFAOptionType]
readPrec :: ReadPrec MFAOptionType
$creadPrec :: ReadPrec MFAOptionType
readList :: ReadS [MFAOptionType]
$creadList :: ReadS [MFAOptionType]
readsPrec :: Int -> ReadS MFAOptionType
$creadsPrec :: Int -> ReadS MFAOptionType
Prelude.Read, Int -> MFAOptionType -> ShowS
[MFAOptionType] -> ShowS
MFAOptionType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MFAOptionType] -> ShowS
$cshowList :: [MFAOptionType] -> ShowS
show :: MFAOptionType -> String
$cshow :: MFAOptionType -> String
showsPrec :: Int -> MFAOptionType -> ShowS
$cshowsPrec :: Int -> MFAOptionType -> ShowS
Prelude.Show, forall x. Rep MFAOptionType x -> MFAOptionType
forall x. MFAOptionType -> Rep MFAOptionType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MFAOptionType x -> MFAOptionType
$cfrom :: forall x. MFAOptionType -> Rep MFAOptionType x
Prelude.Generic)

-- |
-- Create a value of 'MFAOptionType' 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:
--
-- 'attributeName', 'mfaOptionType_attributeName' - The attribute name of the MFA option type. The only valid value is
-- @phone_number@.
--
-- 'deliveryMedium', 'mfaOptionType_deliveryMedium' - The delivery medium to send the MFA code. You can use this parameter to
-- set only the @SMS@ delivery medium value.
newMFAOptionType ::
  MFAOptionType
newMFAOptionType :: MFAOptionType
newMFAOptionType =
  MFAOptionType'
    { $sel:attributeName:MFAOptionType' :: Maybe Text
attributeName = forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryMedium:MFAOptionType' :: Maybe DeliveryMediumType
deliveryMedium = forall a. Maybe a
Prelude.Nothing
    }

-- | The attribute name of the MFA option type. The only valid value is
-- @phone_number@.
mfaOptionType_attributeName :: Lens.Lens' MFAOptionType (Prelude.Maybe Prelude.Text)
mfaOptionType_attributeName :: Lens' MFAOptionType (Maybe Text)
mfaOptionType_attributeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MFAOptionType' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:MFAOptionType' :: MFAOptionType -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: MFAOptionType
s@MFAOptionType' {} Maybe Text
a -> MFAOptionType
s {$sel:attributeName:MFAOptionType' :: Maybe Text
attributeName = Maybe Text
a} :: MFAOptionType)

-- | The delivery medium to send the MFA code. You can use this parameter to
-- set only the @SMS@ delivery medium value.
mfaOptionType_deliveryMedium :: Lens.Lens' MFAOptionType (Prelude.Maybe DeliveryMediumType)
mfaOptionType_deliveryMedium :: Lens' MFAOptionType (Maybe DeliveryMediumType)
mfaOptionType_deliveryMedium = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MFAOptionType' {Maybe DeliveryMediumType
deliveryMedium :: Maybe DeliveryMediumType
$sel:deliveryMedium:MFAOptionType' :: MFAOptionType -> Maybe DeliveryMediumType
deliveryMedium} -> Maybe DeliveryMediumType
deliveryMedium) (\s :: MFAOptionType
s@MFAOptionType' {} Maybe DeliveryMediumType
a -> MFAOptionType
s {$sel:deliveryMedium:MFAOptionType' :: Maybe DeliveryMediumType
deliveryMedium = Maybe DeliveryMediumType
a} :: MFAOptionType)

instance Data.FromJSON MFAOptionType where
  parseJSON :: Value -> Parser MFAOptionType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MFAOptionType"
      ( \Object
x ->
          Maybe Text -> Maybe DeliveryMediumType -> MFAOptionType
MFAOptionType'
            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
"AttributeName")
            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
"DeliveryMedium")
      )

instance Prelude.Hashable MFAOptionType where
  hashWithSalt :: Int -> MFAOptionType -> Int
hashWithSalt Int
_salt MFAOptionType' {Maybe Text
Maybe DeliveryMediumType
deliveryMedium :: Maybe DeliveryMediumType
attributeName :: Maybe Text
$sel:deliveryMedium:MFAOptionType' :: MFAOptionType -> Maybe DeliveryMediumType
$sel:attributeName:MFAOptionType' :: MFAOptionType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attributeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DeliveryMediumType
deliveryMedium

instance Prelude.NFData MFAOptionType where
  rnf :: MFAOptionType -> ()
rnf MFAOptionType' {Maybe Text
Maybe DeliveryMediumType
deliveryMedium :: Maybe DeliveryMediumType
attributeName :: Maybe Text
$sel:deliveryMedium:MFAOptionType' :: MFAOptionType -> Maybe DeliveryMediumType
$sel:attributeName:MFAOptionType' :: MFAOptionType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attributeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DeliveryMediumType
deliveryMedium

instance Data.ToJSON MFAOptionType where
  toJSON :: MFAOptionType -> Value
toJSON MFAOptionType' {Maybe Text
Maybe DeliveryMediumType
deliveryMedium :: Maybe DeliveryMediumType
attributeName :: Maybe Text
$sel:deliveryMedium:MFAOptionType' :: MFAOptionType -> Maybe DeliveryMediumType
$sel:attributeName:MFAOptionType' :: MFAOptionType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attributeName,
            (Key
"DeliveryMedium" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeliveryMediumType
deliveryMedium
          ]
      )