{-# 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.CreateBackendAuthForgotPasswordConfig
-- 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.AmplifyBackend.Types.CreateBackendAuthForgotPasswordConfig 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'CreateBackendAuthForgotPasswordConfig' 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', 'createBackendAuthForgotPasswordConfig_emailSettings' - __(DEPRECATED)__ The configuration for the email sent when an app user
-- forgets their password.
--
-- 'smsSettings', 'createBackendAuthForgotPasswordConfig_smsSettings' - __(DEPRECATED)__ The configuration for the SMS message sent when an app
-- user forgets their password.
--
-- 'deliveryMethod', 'createBackendAuthForgotPasswordConfig_deliveryMethod' - __(DEPRECATED)__ Describes which mode to use (either SMS or email) to
-- deliver messages to app users who want to recover their password.
newCreateBackendAuthForgotPasswordConfig ::
  -- | 'deliveryMethod'
  DeliveryMethod ->
  CreateBackendAuthForgotPasswordConfig
newCreateBackendAuthForgotPasswordConfig :: DeliveryMethod -> CreateBackendAuthForgotPasswordConfig
newCreateBackendAuthForgotPasswordConfig
  DeliveryMethod
pDeliveryMethod_ =
    CreateBackendAuthForgotPasswordConfig'
      { $sel:emailSettings:CreateBackendAuthForgotPasswordConfig' :: Maybe EmailSettings
emailSettings =
          forall a. Maybe a
Prelude.Nothing,
        $sel:smsSettings:CreateBackendAuthForgotPasswordConfig' :: Maybe SmsSettings
smsSettings = forall a. Maybe a
Prelude.Nothing,
        $sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: DeliveryMethod
deliveryMethod = DeliveryMethod
pDeliveryMethod_
      }

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

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

-- | __(DEPRECATED)__ Describes which mode to use (either SMS or email) to
-- deliver messages to app users who want to recover their password.
createBackendAuthForgotPasswordConfig_deliveryMethod :: Lens.Lens' CreateBackendAuthForgotPasswordConfig DeliveryMethod
createBackendAuthForgotPasswordConfig_deliveryMethod :: Lens' CreateBackendAuthForgotPasswordConfig DeliveryMethod
createBackendAuthForgotPasswordConfig_deliveryMethod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthForgotPasswordConfig' {DeliveryMethod
deliveryMethod :: DeliveryMethod
$sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> DeliveryMethod
deliveryMethod} -> DeliveryMethod
deliveryMethod) (\s :: CreateBackendAuthForgotPasswordConfig
s@CreateBackendAuthForgotPasswordConfig' {} DeliveryMethod
a -> CreateBackendAuthForgotPasswordConfig
s {$sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: DeliveryMethod
deliveryMethod = DeliveryMethod
a} :: CreateBackendAuthForgotPasswordConfig)

instance
  Data.FromJSON
    CreateBackendAuthForgotPasswordConfig
  where
  parseJSON :: Value -> Parser CreateBackendAuthForgotPasswordConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CreateBackendAuthForgotPasswordConfig"
      ( \Object
x ->
          Maybe EmailSettings
-> Maybe SmsSettings
-> DeliveryMethod
-> CreateBackendAuthForgotPasswordConfig
CreateBackendAuthForgotPasswordConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"emailSettings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"smsSettings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"deliveryMethod")
      )

instance
  Prelude.Hashable
    CreateBackendAuthForgotPasswordConfig
  where
  hashWithSalt :: Int -> CreateBackendAuthForgotPasswordConfig -> Int
hashWithSalt
    Int
_salt
    CreateBackendAuthForgotPasswordConfig' {Maybe EmailSettings
Maybe SmsSettings
DeliveryMethod
deliveryMethod :: DeliveryMethod
smsSettings :: Maybe SmsSettings
emailSettings :: Maybe EmailSettings
$sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> DeliveryMethod
$sel:smsSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
$sel:emailSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EmailSettings
emailSettings
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SmsSettings
smsSettings
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DeliveryMethod
deliveryMethod

instance
  Prelude.NFData
    CreateBackendAuthForgotPasswordConfig
  where
  rnf :: CreateBackendAuthForgotPasswordConfig -> ()
rnf CreateBackendAuthForgotPasswordConfig' {Maybe EmailSettings
Maybe SmsSettings
DeliveryMethod
deliveryMethod :: DeliveryMethod
smsSettings :: Maybe SmsSettings
emailSettings :: Maybe EmailSettings
$sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> DeliveryMethod
$sel:smsSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
$sel:emailSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EmailSettings
emailSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SmsSettings
smsSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DeliveryMethod
deliveryMethod

instance
  Data.ToJSON
    CreateBackendAuthForgotPasswordConfig
  where
  toJSON :: CreateBackendAuthForgotPasswordConfig -> Value
toJSON CreateBackendAuthForgotPasswordConfig' {Maybe EmailSettings
Maybe SmsSettings
DeliveryMethod
deliveryMethod :: DeliveryMethod
smsSettings :: Maybe SmsSettings
emailSettings :: Maybe EmailSettings
$sel:deliveryMethod:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> DeliveryMethod
$sel:smsSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe SmsSettings
$sel:emailSettings:CreateBackendAuthForgotPasswordConfig' :: CreateBackendAuthForgotPasswordConfig -> Maybe EmailSettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"emailSettings" 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 EmailSettings
emailSettings,
            (Key
"smsSettings" 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 SmsSettings
smsSettings,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"deliveryMethod" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DeliveryMethod
deliveryMethod)
          ]
      )