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

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

-- | The type used for enabling software token MFA at the user level. 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:/ 'newSoftwareTokenMfaSettingsType' smart constructor.
data SoftwareTokenMfaSettingsType = SoftwareTokenMfaSettingsType'
  { -- | Specifies whether software token 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.
    SoftwareTokenMfaSettingsType -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether software token MFA is the preferred MFA method.
    SoftwareTokenMfaSettingsType -> Maybe Bool
preferredMfa :: Prelude.Maybe Prelude.Bool
  }
  deriving (SoftwareTokenMfaSettingsType
-> SoftwareTokenMfaSettingsType -> Bool
(SoftwareTokenMfaSettingsType
 -> SoftwareTokenMfaSettingsType -> Bool)
-> (SoftwareTokenMfaSettingsType
    -> SoftwareTokenMfaSettingsType -> Bool)
-> Eq SoftwareTokenMfaSettingsType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SoftwareTokenMfaSettingsType
-> SoftwareTokenMfaSettingsType -> Bool
$c/= :: SoftwareTokenMfaSettingsType
-> SoftwareTokenMfaSettingsType -> Bool
== :: SoftwareTokenMfaSettingsType
-> SoftwareTokenMfaSettingsType -> Bool
$c== :: SoftwareTokenMfaSettingsType
-> SoftwareTokenMfaSettingsType -> Bool
Prelude.Eq, ReadPrec [SoftwareTokenMfaSettingsType]
ReadPrec SoftwareTokenMfaSettingsType
Int -> ReadS SoftwareTokenMfaSettingsType
ReadS [SoftwareTokenMfaSettingsType]
(Int -> ReadS SoftwareTokenMfaSettingsType)
-> ReadS [SoftwareTokenMfaSettingsType]
-> ReadPrec SoftwareTokenMfaSettingsType
-> ReadPrec [SoftwareTokenMfaSettingsType]
-> Read SoftwareTokenMfaSettingsType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SoftwareTokenMfaSettingsType]
$creadListPrec :: ReadPrec [SoftwareTokenMfaSettingsType]
readPrec :: ReadPrec SoftwareTokenMfaSettingsType
$creadPrec :: ReadPrec SoftwareTokenMfaSettingsType
readList :: ReadS [SoftwareTokenMfaSettingsType]
$creadList :: ReadS [SoftwareTokenMfaSettingsType]
readsPrec :: Int -> ReadS SoftwareTokenMfaSettingsType
$creadsPrec :: Int -> ReadS SoftwareTokenMfaSettingsType
Prelude.Read, Int -> SoftwareTokenMfaSettingsType -> ShowS
[SoftwareTokenMfaSettingsType] -> ShowS
SoftwareTokenMfaSettingsType -> String
(Int -> SoftwareTokenMfaSettingsType -> ShowS)
-> (SoftwareTokenMfaSettingsType -> String)
-> ([SoftwareTokenMfaSettingsType] -> ShowS)
-> Show SoftwareTokenMfaSettingsType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SoftwareTokenMfaSettingsType] -> ShowS
$cshowList :: [SoftwareTokenMfaSettingsType] -> ShowS
show :: SoftwareTokenMfaSettingsType -> String
$cshow :: SoftwareTokenMfaSettingsType -> String
showsPrec :: Int -> SoftwareTokenMfaSettingsType -> ShowS
$cshowsPrec :: Int -> SoftwareTokenMfaSettingsType -> ShowS
Prelude.Show, (forall x.
 SoftwareTokenMfaSettingsType -> Rep SoftwareTokenMfaSettingsType x)
-> (forall x.
    Rep SoftwareTokenMfaSettingsType x -> SoftwareTokenMfaSettingsType)
-> Generic SoftwareTokenMfaSettingsType
forall x.
Rep SoftwareTokenMfaSettingsType x -> SoftwareTokenMfaSettingsType
forall x.
SoftwareTokenMfaSettingsType -> Rep SoftwareTokenMfaSettingsType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SoftwareTokenMfaSettingsType x -> SoftwareTokenMfaSettingsType
$cfrom :: forall x.
SoftwareTokenMfaSettingsType -> Rep SoftwareTokenMfaSettingsType x
Prelude.Generic)

-- |
-- Create a value of 'SoftwareTokenMfaSettingsType' 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', 'softwareTokenMfaSettingsType_enabled' - Specifies whether software token 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', 'softwareTokenMfaSettingsType_preferredMfa' - Specifies whether software token MFA is the preferred MFA method.
newSoftwareTokenMfaSettingsType ::
  SoftwareTokenMfaSettingsType
newSoftwareTokenMfaSettingsType :: SoftwareTokenMfaSettingsType
newSoftwareTokenMfaSettingsType =
  SoftwareTokenMfaSettingsType' :: Maybe Bool -> Maybe Bool -> SoftwareTokenMfaSettingsType
SoftwareTokenMfaSettingsType'
    { $sel:enabled:SoftwareTokenMfaSettingsType' :: Maybe Bool
enabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:preferredMfa:SoftwareTokenMfaSettingsType' :: Maybe Bool
preferredMfa = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether software token 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.
softwareTokenMfaSettingsType_enabled :: Lens.Lens' SoftwareTokenMfaSettingsType (Prelude.Maybe Prelude.Bool)
softwareTokenMfaSettingsType_enabled :: (Maybe Bool -> f (Maybe Bool))
-> SoftwareTokenMfaSettingsType -> f SoftwareTokenMfaSettingsType
softwareTokenMfaSettingsType_enabled = (SoftwareTokenMfaSettingsType -> Maybe Bool)
-> (SoftwareTokenMfaSettingsType
    -> Maybe Bool -> SoftwareTokenMfaSettingsType)
-> Lens
     SoftwareTokenMfaSettingsType
     SoftwareTokenMfaSettingsType
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SoftwareTokenMfaSettingsType' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:SoftwareTokenMfaSettingsType' :: SoftwareTokenMfaSettingsType -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: SoftwareTokenMfaSettingsType
s@SoftwareTokenMfaSettingsType' {} Maybe Bool
a -> SoftwareTokenMfaSettingsType
s {$sel:enabled:SoftwareTokenMfaSettingsType' :: Maybe Bool
enabled = Maybe Bool
a} :: SoftwareTokenMfaSettingsType)

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

instance
  Prelude.Hashable
    SoftwareTokenMfaSettingsType

instance Prelude.NFData SoftwareTokenMfaSettingsType

instance Core.ToJSON SoftwareTokenMfaSettingsType where
  toJSON :: SoftwareTokenMfaSettingsType -> Value
toJSON SoftwareTokenMfaSettingsType' {Maybe Bool
preferredMfa :: Maybe Bool
enabled :: Maybe Bool
$sel:preferredMfa:SoftwareTokenMfaSettingsType' :: SoftwareTokenMfaSettingsType -> Maybe Bool
$sel:enabled:SoftwareTokenMfaSettingsType' :: SoftwareTokenMfaSettingsType -> 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
          ]
      )