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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The type used for enabling SMS MFA at the user level. Phone numbers
-- don\'t need to be verified to be used for SMS MFA. If an MFA type is
-- enabled for a user, the user will be prompted for MFA during all sign in
-- attempts, unless device tracking is turned on and the device has been
-- trusted. If you would like MFA to be applied selectively based on the
-- assessed risk level of sign in attempts, disable MFA for users and turn
-- on Adaptive Authentication for the user pool.
--
-- /See:/ 'newSMSMfaSettingsType' smart constructor.
data SMSMfaSettingsType = SMSMfaSettingsType'
  { -- | Specifies whether SMS text message MFA is enabled. If an MFA type is
    -- enabled for a user, the user will be prompted for MFA during all sign in
    -- attempts, unless device tracking is turned on and the device has been
    -- trusted.
    SMSMfaSettingsType -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether SMS is the preferred MFA method.
    SMSMfaSettingsType -> Maybe Bool
preferredMfa :: Prelude.Maybe Prelude.Bool
  }
  deriving (SMSMfaSettingsType -> SMSMfaSettingsType -> Bool
(SMSMfaSettingsType -> SMSMfaSettingsType -> Bool)
-> (SMSMfaSettingsType -> SMSMfaSettingsType -> Bool)
-> Eq SMSMfaSettingsType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SMSMfaSettingsType -> SMSMfaSettingsType -> Bool
$c/= :: SMSMfaSettingsType -> SMSMfaSettingsType -> Bool
== :: SMSMfaSettingsType -> SMSMfaSettingsType -> Bool
$c== :: SMSMfaSettingsType -> SMSMfaSettingsType -> Bool
Prelude.Eq, ReadPrec [SMSMfaSettingsType]
ReadPrec SMSMfaSettingsType
Int -> ReadS SMSMfaSettingsType
ReadS [SMSMfaSettingsType]
(Int -> ReadS SMSMfaSettingsType)
-> ReadS [SMSMfaSettingsType]
-> ReadPrec SMSMfaSettingsType
-> ReadPrec [SMSMfaSettingsType]
-> Read SMSMfaSettingsType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SMSMfaSettingsType]
$creadListPrec :: ReadPrec [SMSMfaSettingsType]
readPrec :: ReadPrec SMSMfaSettingsType
$creadPrec :: ReadPrec SMSMfaSettingsType
readList :: ReadS [SMSMfaSettingsType]
$creadList :: ReadS [SMSMfaSettingsType]
readsPrec :: Int -> ReadS SMSMfaSettingsType
$creadsPrec :: Int -> ReadS SMSMfaSettingsType
Prelude.Read, Int -> SMSMfaSettingsType -> ShowS
[SMSMfaSettingsType] -> ShowS
SMSMfaSettingsType -> String
(Int -> SMSMfaSettingsType -> ShowS)
-> (SMSMfaSettingsType -> String)
-> ([SMSMfaSettingsType] -> ShowS)
-> Show SMSMfaSettingsType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SMSMfaSettingsType] -> ShowS
$cshowList :: [SMSMfaSettingsType] -> ShowS
show :: SMSMfaSettingsType -> String
$cshow :: SMSMfaSettingsType -> String
showsPrec :: Int -> SMSMfaSettingsType -> ShowS
$cshowsPrec :: Int -> SMSMfaSettingsType -> ShowS
Prelude.Show, (forall x. SMSMfaSettingsType -> Rep SMSMfaSettingsType x)
-> (forall x. Rep SMSMfaSettingsType x -> SMSMfaSettingsType)
-> Generic SMSMfaSettingsType
forall x. Rep SMSMfaSettingsType x -> SMSMfaSettingsType
forall x. SMSMfaSettingsType -> Rep SMSMfaSettingsType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SMSMfaSettingsType x -> SMSMfaSettingsType
$cfrom :: forall x. SMSMfaSettingsType -> Rep SMSMfaSettingsType x
Prelude.Generic)

-- |
-- Create a value of 'SMSMfaSettingsType' 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:
--
-- 'enabled', 'sMSMfaSettingsType_enabled' - Specifies whether SMS text message MFA is enabled. If an MFA type is
-- enabled for a user, the user will be prompted for MFA during all sign in
-- attempts, unless device tracking is turned on and the device has been
-- trusted.
--
-- 'preferredMfa', 'sMSMfaSettingsType_preferredMfa' - Specifies whether SMS is the preferred MFA method.
newSMSMfaSettingsType ::
  SMSMfaSettingsType
newSMSMfaSettingsType :: SMSMfaSettingsType
newSMSMfaSettingsType =
  SMSMfaSettingsType' :: Maybe Bool -> Maybe Bool -> SMSMfaSettingsType
SMSMfaSettingsType'
    { $sel:enabled:SMSMfaSettingsType' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:preferredMfa:SMSMfaSettingsType' :: Maybe Bool
preferredMfa = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether SMS text message MFA is enabled. If an MFA type is
-- enabled for a user, the user will be prompted for MFA during all sign in
-- attempts, unless device tracking is turned on and the device has been
-- trusted.
sMSMfaSettingsType_enabled :: Lens.Lens' SMSMfaSettingsType (Prelude.Maybe Prelude.Bool)
sMSMfaSettingsType_enabled :: (Maybe Bool -> f (Maybe Bool))
-> SMSMfaSettingsType -> f SMSMfaSettingsType
sMSMfaSettingsType_enabled = (SMSMfaSettingsType -> Maybe Bool)
-> (SMSMfaSettingsType -> Maybe Bool -> SMSMfaSettingsType)
-> Lens
     SMSMfaSettingsType SMSMfaSettingsType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSMfaSettingsType' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: SMSMfaSettingsType
s@SMSMfaSettingsType' {} Maybe Bool
a -> SMSMfaSettingsType
s {$sel:enabled:SMSMfaSettingsType' :: Maybe Bool
enabled = Maybe Bool
a} :: SMSMfaSettingsType)

-- | Specifies whether SMS is the preferred MFA method.
sMSMfaSettingsType_preferredMfa :: Lens.Lens' SMSMfaSettingsType (Prelude.Maybe Prelude.Bool)
sMSMfaSettingsType_preferredMfa :: (Maybe Bool -> f (Maybe Bool))
-> SMSMfaSettingsType -> f SMSMfaSettingsType
sMSMfaSettingsType_preferredMfa = (SMSMfaSettingsType -> Maybe Bool)
-> (SMSMfaSettingsType -> Maybe Bool -> SMSMfaSettingsType)
-> Lens
     SMSMfaSettingsType SMSMfaSettingsType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSMfaSettingsType' {Maybe Bool
preferredMfa :: Maybe Bool
$sel:preferredMfa:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
preferredMfa} -> Maybe Bool
preferredMfa) (\s :: SMSMfaSettingsType
s@SMSMfaSettingsType' {} Maybe Bool
a -> SMSMfaSettingsType
s {$sel:preferredMfa:SMSMfaSettingsType' :: Maybe Bool
preferredMfa = Maybe Bool
a} :: SMSMfaSettingsType)

instance Prelude.Hashable SMSMfaSettingsType

instance Prelude.NFData SMSMfaSettingsType

instance Core.ToJSON SMSMfaSettingsType where
  toJSON :: SMSMfaSettingsType -> Value
toJSON SMSMfaSettingsType' {Maybe Bool
preferredMfa :: Maybe Bool
enabled :: Maybe Bool
$sel:preferredMfa:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
$sel:enabled:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"PreferredMfa" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
preferredMfa
          ]
      )