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

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

-- | The type used for enabling SMS multi-factor authentication (MFA) at the
-- user level. Phone numbers don\'t need to be verified to be used for SMS
-- MFA. If an MFA type is activated 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,
-- deactivate 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 activated. If an MFA type is
    -- activated 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
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]
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
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. 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 activated. If an MFA type is
-- activated 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'
    { $sel:enabled:SMSMfaSettingsType' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:preferredMfa:SMSMfaSettingsType' :: Maybe Bool
preferredMfa = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether SMS text message MFA is activated. If an MFA type is
-- activated 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 :: Lens' SMSMfaSettingsType (Maybe Bool)
sMSMfaSettingsType_enabled = 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 :: Lens' SMSMfaSettingsType (Maybe Bool)
sMSMfaSettingsType_preferredMfa = 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 where
  hashWithSalt :: Int -> SMSMfaSettingsType -> Int
hashWithSalt Int
_salt SMSMfaSettingsType' {Maybe Bool
preferredMfa :: Maybe Bool
enabled :: Maybe Bool
$sel:preferredMfa:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
$sel:enabled:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
preferredMfa

instance Prelude.NFData SMSMfaSettingsType where
  rnf :: SMSMfaSettingsType -> ()
rnf SMSMfaSettingsType' {Maybe Bool
preferredMfa :: Maybe Bool
enabled :: Maybe Bool
$sel:preferredMfa:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
$sel:enabled:SMSMfaSettingsType' :: SMSMfaSettingsType -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
preferredMfa

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Enabled" 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 Bool
enabled,
            (Key
"PreferredMfa" 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 Bool
preferredMfa
          ]
      )