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

import Amazonka.AmplifyBackend.Types.DeliveryMethod
import Amazonka.AmplifyBackend.Types.EmailSettings
import Amazonka.AmplifyBackend.Types.SmsSettings
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the forgot password policy for authenticating into the Amplify
-- app.
--
-- /See:/ 'newUpdateBackendAuthForgotPasswordConfig' smart constructor.
data UpdateBackendAuthForgotPasswordConfig = UpdateBackendAuthForgotPasswordConfig'
  { -- | The configuration for the email sent when an app user forgets their
    -- password.
    UpdateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
emailSettings :: Prelude.Maybe EmailSettings,
    -- | The configuration for the SMS message sent when an Amplify app user
    -- forgets their password.
    UpdateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
smsSettings :: Prelude.Maybe SmsSettings,
    -- | Describes which mode to use (either SMS or email) to deliver messages to
    -- app users that want to recover their password.
    UpdateBackendAuthForgotPasswordConfig -> Maybe DeliveryMethod
deliveryMethod :: Prelude.Maybe DeliveryMethod
  }
  deriving (UpdateBackendAuthForgotPasswordConfig
-> UpdateBackendAuthForgotPasswordConfig -> Bool
(UpdateBackendAuthForgotPasswordConfig
 -> UpdateBackendAuthForgotPasswordConfig -> Bool)
-> (UpdateBackendAuthForgotPasswordConfig
    -> UpdateBackendAuthForgotPasswordConfig -> Bool)
-> Eq UpdateBackendAuthForgotPasswordConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBackendAuthForgotPasswordConfig
-> UpdateBackendAuthForgotPasswordConfig -> Bool
$c/= :: UpdateBackendAuthForgotPasswordConfig
-> UpdateBackendAuthForgotPasswordConfig -> Bool
== :: UpdateBackendAuthForgotPasswordConfig
-> UpdateBackendAuthForgotPasswordConfig -> Bool
$c== :: UpdateBackendAuthForgotPasswordConfig
-> UpdateBackendAuthForgotPasswordConfig -> Bool
Prelude.Eq, ReadPrec [UpdateBackendAuthForgotPasswordConfig]
ReadPrec UpdateBackendAuthForgotPasswordConfig
Int -> ReadS UpdateBackendAuthForgotPasswordConfig
ReadS [UpdateBackendAuthForgotPasswordConfig]
(Int -> ReadS UpdateBackendAuthForgotPasswordConfig)
-> ReadS [UpdateBackendAuthForgotPasswordConfig]
-> ReadPrec UpdateBackendAuthForgotPasswordConfig
-> ReadPrec [UpdateBackendAuthForgotPasswordConfig]
-> Read UpdateBackendAuthForgotPasswordConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBackendAuthForgotPasswordConfig]
$creadListPrec :: ReadPrec [UpdateBackendAuthForgotPasswordConfig]
readPrec :: ReadPrec UpdateBackendAuthForgotPasswordConfig
$creadPrec :: ReadPrec UpdateBackendAuthForgotPasswordConfig
readList :: ReadS [UpdateBackendAuthForgotPasswordConfig]
$creadList :: ReadS [UpdateBackendAuthForgotPasswordConfig]
readsPrec :: Int -> ReadS UpdateBackendAuthForgotPasswordConfig
$creadsPrec :: Int -> ReadS UpdateBackendAuthForgotPasswordConfig
Prelude.Read, Int -> UpdateBackendAuthForgotPasswordConfig -> ShowS
[UpdateBackendAuthForgotPasswordConfig] -> ShowS
UpdateBackendAuthForgotPasswordConfig -> String
(Int -> UpdateBackendAuthForgotPasswordConfig -> ShowS)
-> (UpdateBackendAuthForgotPasswordConfig -> String)
-> ([UpdateBackendAuthForgotPasswordConfig] -> ShowS)
-> Show UpdateBackendAuthForgotPasswordConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBackendAuthForgotPasswordConfig] -> ShowS
$cshowList :: [UpdateBackendAuthForgotPasswordConfig] -> ShowS
show :: UpdateBackendAuthForgotPasswordConfig -> String
$cshow :: UpdateBackendAuthForgotPasswordConfig -> String
showsPrec :: Int -> UpdateBackendAuthForgotPasswordConfig -> ShowS
$cshowsPrec :: Int -> UpdateBackendAuthForgotPasswordConfig -> ShowS
Prelude.Show, (forall x.
 UpdateBackendAuthForgotPasswordConfig
 -> Rep UpdateBackendAuthForgotPasswordConfig x)
-> (forall x.
    Rep UpdateBackendAuthForgotPasswordConfig x
    -> UpdateBackendAuthForgotPasswordConfig)
-> Generic UpdateBackendAuthForgotPasswordConfig
forall x.
Rep UpdateBackendAuthForgotPasswordConfig x
-> UpdateBackendAuthForgotPasswordConfig
forall x.
UpdateBackendAuthForgotPasswordConfig
-> Rep UpdateBackendAuthForgotPasswordConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateBackendAuthForgotPasswordConfig x
-> UpdateBackendAuthForgotPasswordConfig
$cfrom :: forall x.
UpdateBackendAuthForgotPasswordConfig
-> Rep UpdateBackendAuthForgotPasswordConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBackendAuthForgotPasswordConfig' 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:
--
-- 'emailSettings', 'updateBackendAuthForgotPasswordConfig_emailSettings' - The configuration for the email sent when an app user forgets their
-- password.
--
-- 'smsSettings', 'updateBackendAuthForgotPasswordConfig_smsSettings' - The configuration for the SMS message sent when an Amplify app user
-- forgets their password.
--
-- 'deliveryMethod', 'updateBackendAuthForgotPasswordConfig_deliveryMethod' - Describes which mode to use (either SMS or email) to deliver messages to
-- app users that want to recover their password.
newUpdateBackendAuthForgotPasswordConfig ::
  UpdateBackendAuthForgotPasswordConfig
newUpdateBackendAuthForgotPasswordConfig :: UpdateBackendAuthForgotPasswordConfig
newUpdateBackendAuthForgotPasswordConfig =
  UpdateBackendAuthForgotPasswordConfig' :: Maybe EmailSettings
-> Maybe SmsSettings
-> Maybe DeliveryMethod
-> UpdateBackendAuthForgotPasswordConfig
UpdateBackendAuthForgotPasswordConfig'
    { $sel:emailSettings:UpdateBackendAuthForgotPasswordConfig' :: Maybe EmailSettings
emailSettings =
        Maybe EmailSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:smsSettings:UpdateBackendAuthForgotPasswordConfig' :: Maybe SmsSettings
smsSettings = Maybe SmsSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryMethod:UpdateBackendAuthForgotPasswordConfig' :: Maybe DeliveryMethod
deliveryMethod = Maybe DeliveryMethod
forall a. Maybe a
Prelude.Nothing
    }

-- | The configuration for the email sent when an app user forgets their
-- password.
updateBackendAuthForgotPasswordConfig_emailSettings :: Lens.Lens' UpdateBackendAuthForgotPasswordConfig (Prelude.Maybe EmailSettings)
updateBackendAuthForgotPasswordConfig_emailSettings :: (Maybe EmailSettings -> f (Maybe EmailSettings))
-> UpdateBackendAuthForgotPasswordConfig
-> f UpdateBackendAuthForgotPasswordConfig
updateBackendAuthForgotPasswordConfig_emailSettings = (UpdateBackendAuthForgotPasswordConfig -> Maybe EmailSettings)
-> (UpdateBackendAuthForgotPasswordConfig
    -> Maybe EmailSettings -> UpdateBackendAuthForgotPasswordConfig)
-> Lens
     UpdateBackendAuthForgotPasswordConfig
     UpdateBackendAuthForgotPasswordConfig
     (Maybe EmailSettings)
     (Maybe EmailSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthForgotPasswordConfig' {Maybe EmailSettings
emailSettings :: Maybe EmailSettings
$sel:emailSettings:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
emailSettings} -> Maybe EmailSettings
emailSettings) (\s :: UpdateBackendAuthForgotPasswordConfig
s@UpdateBackendAuthForgotPasswordConfig' {} Maybe EmailSettings
a -> UpdateBackendAuthForgotPasswordConfig
s {$sel:emailSettings:UpdateBackendAuthForgotPasswordConfig' :: Maybe EmailSettings
emailSettings = Maybe EmailSettings
a} :: UpdateBackendAuthForgotPasswordConfig)

-- | The configuration for the SMS message sent when an Amplify app user
-- forgets their password.
updateBackendAuthForgotPasswordConfig_smsSettings :: Lens.Lens' UpdateBackendAuthForgotPasswordConfig (Prelude.Maybe SmsSettings)
updateBackendAuthForgotPasswordConfig_smsSettings :: (Maybe SmsSettings -> f (Maybe SmsSettings))
-> UpdateBackendAuthForgotPasswordConfig
-> f UpdateBackendAuthForgotPasswordConfig
updateBackendAuthForgotPasswordConfig_smsSettings = (UpdateBackendAuthForgotPasswordConfig -> Maybe SmsSettings)
-> (UpdateBackendAuthForgotPasswordConfig
    -> Maybe SmsSettings -> UpdateBackendAuthForgotPasswordConfig)
-> Lens
     UpdateBackendAuthForgotPasswordConfig
     UpdateBackendAuthForgotPasswordConfig
     (Maybe SmsSettings)
     (Maybe SmsSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthForgotPasswordConfig' {Maybe SmsSettings
smsSettings :: Maybe SmsSettings
$sel:smsSettings:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
smsSettings} -> Maybe SmsSettings
smsSettings) (\s :: UpdateBackendAuthForgotPasswordConfig
s@UpdateBackendAuthForgotPasswordConfig' {} Maybe SmsSettings
a -> UpdateBackendAuthForgotPasswordConfig
s {$sel:smsSettings:UpdateBackendAuthForgotPasswordConfig' :: Maybe SmsSettings
smsSettings = Maybe SmsSettings
a} :: UpdateBackendAuthForgotPasswordConfig)

-- | Describes which mode to use (either SMS or email) to deliver messages to
-- app users that want to recover their password.
updateBackendAuthForgotPasswordConfig_deliveryMethod :: Lens.Lens' UpdateBackendAuthForgotPasswordConfig (Prelude.Maybe DeliveryMethod)
updateBackendAuthForgotPasswordConfig_deliveryMethod :: (Maybe DeliveryMethod -> f (Maybe DeliveryMethod))
-> UpdateBackendAuthForgotPasswordConfig
-> f UpdateBackendAuthForgotPasswordConfig
updateBackendAuthForgotPasswordConfig_deliveryMethod = (UpdateBackendAuthForgotPasswordConfig -> Maybe DeliveryMethod)
-> (UpdateBackendAuthForgotPasswordConfig
    -> Maybe DeliveryMethod -> UpdateBackendAuthForgotPasswordConfig)
-> Lens
     UpdateBackendAuthForgotPasswordConfig
     UpdateBackendAuthForgotPasswordConfig
     (Maybe DeliveryMethod)
     (Maybe DeliveryMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthForgotPasswordConfig' {Maybe DeliveryMethod
deliveryMethod :: Maybe DeliveryMethod
$sel:deliveryMethod:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe DeliveryMethod
deliveryMethod} -> Maybe DeliveryMethod
deliveryMethod) (\s :: UpdateBackendAuthForgotPasswordConfig
s@UpdateBackendAuthForgotPasswordConfig' {} Maybe DeliveryMethod
a -> UpdateBackendAuthForgotPasswordConfig
s {$sel:deliveryMethod:UpdateBackendAuthForgotPasswordConfig' :: Maybe DeliveryMethod
deliveryMethod = Maybe DeliveryMethod
a} :: UpdateBackendAuthForgotPasswordConfig)

instance
  Prelude.Hashable
    UpdateBackendAuthForgotPasswordConfig

instance
  Prelude.NFData
    UpdateBackendAuthForgotPasswordConfig

instance
  Core.ToJSON
    UpdateBackendAuthForgotPasswordConfig
  where
  toJSON :: UpdateBackendAuthForgotPasswordConfig -> Value
toJSON UpdateBackendAuthForgotPasswordConfig' {Maybe DeliveryMethod
Maybe EmailSettings
Maybe SmsSettings
deliveryMethod :: Maybe DeliveryMethod
smsSettings :: Maybe SmsSettings
emailSettings :: Maybe EmailSettings
$sel:deliveryMethod:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe DeliveryMethod
$sel:smsSettings:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
$sel:emailSettings:UpdateBackendAuthForgotPasswordConfig' :: UpdateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"emailSettings" Text -> EmailSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EmailSettings -> Pair) -> Maybe EmailSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EmailSettings
emailSettings,
            (Text
"smsSettings" Text -> SmsSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SmsSettings -> Pair) -> Maybe SmsSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SmsSettings
smsSettings,
            (Text
"deliveryMethod" Text -> DeliveryMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeliveryMethod -> Pair) -> Maybe DeliveryMethod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeliveryMethod
deliveryMethod
          ]
      )