{-# 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.AmplifyBackend.Types.CreateBackendAuthMFAConfig
-- 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.AmplifyBackend.Types.CreateBackendAuthMFAConfig where

import Amazonka.AmplifyBackend.Types.MFAMode
import Amazonka.AmplifyBackend.Types.Settings
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes whether to apply multi-factor authentication policies for your
-- Amazon Cognito user pool configured as a part of your Amplify project.
--
-- /See:/ 'newCreateBackendAuthMFAConfig' smart constructor.
data CreateBackendAuthMFAConfig = CreateBackendAuthMFAConfig'
  { -- | Describes the configuration settings and methods for your Amplify app
    -- users to use MFA.
    CreateBackendAuthMFAConfig -> Maybe Settings
settings :: Prelude.Maybe Settings,
    -- | Describes whether MFA should be [ON, OFF, or OPTIONAL] for
    -- authentication in your Amplify project.
    CreateBackendAuthMFAConfig -> MFAMode
mfaMode :: MFAMode
  }
  deriving (CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool
(CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool)
-> (CreateBackendAuthMFAConfig
    -> CreateBackendAuthMFAConfig -> Bool)
-> Eq CreateBackendAuthMFAConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool
$c/= :: CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool
== :: CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool
$c== :: CreateBackendAuthMFAConfig -> CreateBackendAuthMFAConfig -> Bool
Prelude.Eq, ReadPrec [CreateBackendAuthMFAConfig]
ReadPrec CreateBackendAuthMFAConfig
Int -> ReadS CreateBackendAuthMFAConfig
ReadS [CreateBackendAuthMFAConfig]
(Int -> ReadS CreateBackendAuthMFAConfig)
-> ReadS [CreateBackendAuthMFAConfig]
-> ReadPrec CreateBackendAuthMFAConfig
-> ReadPrec [CreateBackendAuthMFAConfig]
-> Read CreateBackendAuthMFAConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBackendAuthMFAConfig]
$creadListPrec :: ReadPrec [CreateBackendAuthMFAConfig]
readPrec :: ReadPrec CreateBackendAuthMFAConfig
$creadPrec :: ReadPrec CreateBackendAuthMFAConfig
readList :: ReadS [CreateBackendAuthMFAConfig]
$creadList :: ReadS [CreateBackendAuthMFAConfig]
readsPrec :: Int -> ReadS CreateBackendAuthMFAConfig
$creadsPrec :: Int -> ReadS CreateBackendAuthMFAConfig
Prelude.Read, Int -> CreateBackendAuthMFAConfig -> ShowS
[CreateBackendAuthMFAConfig] -> ShowS
CreateBackendAuthMFAConfig -> String
(Int -> CreateBackendAuthMFAConfig -> ShowS)
-> (CreateBackendAuthMFAConfig -> String)
-> ([CreateBackendAuthMFAConfig] -> ShowS)
-> Show CreateBackendAuthMFAConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBackendAuthMFAConfig] -> ShowS
$cshowList :: [CreateBackendAuthMFAConfig] -> ShowS
show :: CreateBackendAuthMFAConfig -> String
$cshow :: CreateBackendAuthMFAConfig -> String
showsPrec :: Int -> CreateBackendAuthMFAConfig -> ShowS
$cshowsPrec :: Int -> CreateBackendAuthMFAConfig -> ShowS
Prelude.Show, (forall x.
 CreateBackendAuthMFAConfig -> Rep CreateBackendAuthMFAConfig x)
-> (forall x.
    Rep CreateBackendAuthMFAConfig x -> CreateBackendAuthMFAConfig)
-> Generic CreateBackendAuthMFAConfig
forall x.
Rep CreateBackendAuthMFAConfig x -> CreateBackendAuthMFAConfig
forall x.
CreateBackendAuthMFAConfig -> Rep CreateBackendAuthMFAConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateBackendAuthMFAConfig x -> CreateBackendAuthMFAConfig
$cfrom :: forall x.
CreateBackendAuthMFAConfig -> Rep CreateBackendAuthMFAConfig x
Prelude.Generic)

-- |
-- Create a value of 'CreateBackendAuthMFAConfig' 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:
--
-- 'settings', 'createBackendAuthMFAConfig_settings' - Describes the configuration settings and methods for your Amplify app
-- users to use MFA.
--
-- 'mfaMode', 'createBackendAuthMFAConfig_mfaMode' - Describes whether MFA should be [ON, OFF, or OPTIONAL] for
-- authentication in your Amplify project.
newCreateBackendAuthMFAConfig ::
  -- | 'mfaMode'
  MFAMode ->
  CreateBackendAuthMFAConfig
newCreateBackendAuthMFAConfig :: MFAMode -> CreateBackendAuthMFAConfig
newCreateBackendAuthMFAConfig MFAMode
pMFAMode_ =
  CreateBackendAuthMFAConfig' :: Maybe Settings -> MFAMode -> CreateBackendAuthMFAConfig
CreateBackendAuthMFAConfig'
    { $sel:settings:CreateBackendAuthMFAConfig' :: Maybe Settings
settings =
        Maybe Settings
forall a. Maybe a
Prelude.Nothing,
      $sel:mfaMode:CreateBackendAuthMFAConfig' :: MFAMode
mfaMode = MFAMode
pMFAMode_
    }

-- | Describes the configuration settings and methods for your Amplify app
-- users to use MFA.
createBackendAuthMFAConfig_settings :: Lens.Lens' CreateBackendAuthMFAConfig (Prelude.Maybe Settings)
createBackendAuthMFAConfig_settings :: (Maybe Settings -> f (Maybe Settings))
-> CreateBackendAuthMFAConfig -> f CreateBackendAuthMFAConfig
createBackendAuthMFAConfig_settings = (CreateBackendAuthMFAConfig -> Maybe Settings)
-> (CreateBackendAuthMFAConfig
    -> Maybe Settings -> CreateBackendAuthMFAConfig)
-> Lens
     CreateBackendAuthMFAConfig
     CreateBackendAuthMFAConfig
     (Maybe Settings)
     (Maybe Settings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthMFAConfig' {Maybe Settings
settings :: Maybe Settings
$sel:settings:CreateBackendAuthMFAConfig' :: CreateBackendAuthMFAConfig -> Maybe Settings
settings} -> Maybe Settings
settings) (\s :: CreateBackendAuthMFAConfig
s@CreateBackendAuthMFAConfig' {} Maybe Settings
a -> CreateBackendAuthMFAConfig
s {$sel:settings:CreateBackendAuthMFAConfig' :: Maybe Settings
settings = Maybe Settings
a} :: CreateBackendAuthMFAConfig)

-- | Describes whether MFA should be [ON, OFF, or OPTIONAL] for
-- authentication in your Amplify project.
createBackendAuthMFAConfig_mfaMode :: Lens.Lens' CreateBackendAuthMFAConfig MFAMode
createBackendAuthMFAConfig_mfaMode :: (MFAMode -> f MFAMode)
-> CreateBackendAuthMFAConfig -> f CreateBackendAuthMFAConfig
createBackendAuthMFAConfig_mfaMode = (CreateBackendAuthMFAConfig -> MFAMode)
-> (CreateBackendAuthMFAConfig
    -> MFAMode -> CreateBackendAuthMFAConfig)
-> Lens
     CreateBackendAuthMFAConfig
     CreateBackendAuthMFAConfig
     MFAMode
     MFAMode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthMFAConfig' {MFAMode
mfaMode :: MFAMode
$sel:mfaMode:CreateBackendAuthMFAConfig' :: CreateBackendAuthMFAConfig -> MFAMode
mfaMode} -> MFAMode
mfaMode) (\s :: CreateBackendAuthMFAConfig
s@CreateBackendAuthMFAConfig' {} MFAMode
a -> CreateBackendAuthMFAConfig
s {$sel:mfaMode:CreateBackendAuthMFAConfig' :: MFAMode
mfaMode = MFAMode
a} :: CreateBackendAuthMFAConfig)

instance Core.FromJSON CreateBackendAuthMFAConfig where
  parseJSON :: Value -> Parser CreateBackendAuthMFAConfig
parseJSON =
    String
-> (Object -> Parser CreateBackendAuthMFAConfig)
-> Value
-> Parser CreateBackendAuthMFAConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CreateBackendAuthMFAConfig"
      ( \Object
x ->
          Maybe Settings -> MFAMode -> CreateBackendAuthMFAConfig
CreateBackendAuthMFAConfig'
            (Maybe Settings -> MFAMode -> CreateBackendAuthMFAConfig)
-> Parser (Maybe Settings)
-> Parser (MFAMode -> CreateBackendAuthMFAConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Settings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"settings")
            Parser (MFAMode -> CreateBackendAuthMFAConfig)
-> Parser MFAMode -> Parser CreateBackendAuthMFAConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MFAMode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MFAMode")
      )

instance Prelude.Hashable CreateBackendAuthMFAConfig

instance Prelude.NFData CreateBackendAuthMFAConfig

instance Core.ToJSON CreateBackendAuthMFAConfig where
  toJSON :: CreateBackendAuthMFAConfig -> Value
toJSON CreateBackendAuthMFAConfig' {Maybe Settings
MFAMode
mfaMode :: MFAMode
settings :: Maybe Settings
$sel:mfaMode:CreateBackendAuthMFAConfig' :: CreateBackendAuthMFAConfig -> MFAMode
$sel:settings:CreateBackendAuthMFAConfig' :: CreateBackendAuthMFAConfig -> Maybe Settings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"settings" Text -> Settings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Settings -> Pair) -> Maybe Settings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Settings
settings,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MFAMode" Text -> MFAMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MFAMode
mfaMode)
          ]
      )