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

import Amazonka.AmplifyBackend.Types.UpdateBackendAuthForgotPasswordConfig
import Amazonka.AmplifyBackend.Types.UpdateBackendAuthMFAConfig
import Amazonka.AmplifyBackend.Types.UpdateBackendAuthOAuthConfig
import Amazonka.AmplifyBackend.Types.UpdateBackendAuthPasswordPolicyConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the Amazon Cognito user pool configuration for the
-- authorization resource to be configured for your Amplify project on an
-- update.
--
-- /See:/ 'newUpdateBackendAuthUserPoolConfig' smart constructor.
data UpdateBackendAuthUserPoolConfig = UpdateBackendAuthUserPoolConfig'
  { -- | Describes the password policy for your Amazon Cognito user pool,
    -- configured as a part of your Amplify project.
    UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy :: Prelude.Maybe UpdateBackendAuthPasswordPolicyConfig,
    -- | Describes whether to apply multi-factor authentication policies for your
    -- Amazon Cognito user pool configured as a part of your Amplify project.
    UpdateBackendAuthUserPoolConfig -> Maybe UpdateBackendAuthMFAConfig
mfa :: Prelude.Maybe UpdateBackendAuthMFAConfig,
    -- | Describes the forgot password policy for your Amazon Cognito user pool,
    -- configured as a part of your Amplify project.
    UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword :: Prelude.Maybe UpdateBackendAuthForgotPasswordConfig,
    -- | Describes the OAuth policy and rules for your Amazon Cognito user pool,
    -- configured as a part of your Amplify project.
    UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthOAuthConfig
oAuth :: Prelude.Maybe UpdateBackendAuthOAuthConfig
  }
  deriving (UpdateBackendAuthUserPoolConfig
-> UpdateBackendAuthUserPoolConfig -> Bool
(UpdateBackendAuthUserPoolConfig
 -> UpdateBackendAuthUserPoolConfig -> Bool)
-> (UpdateBackendAuthUserPoolConfig
    -> UpdateBackendAuthUserPoolConfig -> Bool)
-> Eq UpdateBackendAuthUserPoolConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBackendAuthUserPoolConfig
-> UpdateBackendAuthUserPoolConfig -> Bool
$c/= :: UpdateBackendAuthUserPoolConfig
-> UpdateBackendAuthUserPoolConfig -> Bool
== :: UpdateBackendAuthUserPoolConfig
-> UpdateBackendAuthUserPoolConfig -> Bool
$c== :: UpdateBackendAuthUserPoolConfig
-> UpdateBackendAuthUserPoolConfig -> Bool
Prelude.Eq, ReadPrec [UpdateBackendAuthUserPoolConfig]
ReadPrec UpdateBackendAuthUserPoolConfig
Int -> ReadS UpdateBackendAuthUserPoolConfig
ReadS [UpdateBackendAuthUserPoolConfig]
(Int -> ReadS UpdateBackendAuthUserPoolConfig)
-> ReadS [UpdateBackendAuthUserPoolConfig]
-> ReadPrec UpdateBackendAuthUserPoolConfig
-> ReadPrec [UpdateBackendAuthUserPoolConfig]
-> Read UpdateBackendAuthUserPoolConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBackendAuthUserPoolConfig]
$creadListPrec :: ReadPrec [UpdateBackendAuthUserPoolConfig]
readPrec :: ReadPrec UpdateBackendAuthUserPoolConfig
$creadPrec :: ReadPrec UpdateBackendAuthUserPoolConfig
readList :: ReadS [UpdateBackendAuthUserPoolConfig]
$creadList :: ReadS [UpdateBackendAuthUserPoolConfig]
readsPrec :: Int -> ReadS UpdateBackendAuthUserPoolConfig
$creadsPrec :: Int -> ReadS UpdateBackendAuthUserPoolConfig
Prelude.Read, Int -> UpdateBackendAuthUserPoolConfig -> ShowS
[UpdateBackendAuthUserPoolConfig] -> ShowS
UpdateBackendAuthUserPoolConfig -> String
(Int -> UpdateBackendAuthUserPoolConfig -> ShowS)
-> (UpdateBackendAuthUserPoolConfig -> String)
-> ([UpdateBackendAuthUserPoolConfig] -> ShowS)
-> Show UpdateBackendAuthUserPoolConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBackendAuthUserPoolConfig] -> ShowS
$cshowList :: [UpdateBackendAuthUserPoolConfig] -> ShowS
show :: UpdateBackendAuthUserPoolConfig -> String
$cshow :: UpdateBackendAuthUserPoolConfig -> String
showsPrec :: Int -> UpdateBackendAuthUserPoolConfig -> ShowS
$cshowsPrec :: Int -> UpdateBackendAuthUserPoolConfig -> ShowS
Prelude.Show, (forall x.
 UpdateBackendAuthUserPoolConfig
 -> Rep UpdateBackendAuthUserPoolConfig x)
-> (forall x.
    Rep UpdateBackendAuthUserPoolConfig x
    -> UpdateBackendAuthUserPoolConfig)
-> Generic UpdateBackendAuthUserPoolConfig
forall x.
Rep UpdateBackendAuthUserPoolConfig x
-> UpdateBackendAuthUserPoolConfig
forall x.
UpdateBackendAuthUserPoolConfig
-> Rep UpdateBackendAuthUserPoolConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateBackendAuthUserPoolConfig x
-> UpdateBackendAuthUserPoolConfig
$cfrom :: forall x.
UpdateBackendAuthUserPoolConfig
-> Rep UpdateBackendAuthUserPoolConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBackendAuthUserPoolConfig' 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:
--
-- 'passwordPolicy', 'updateBackendAuthUserPoolConfig_passwordPolicy' - Describes the password policy for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
--
-- 'mfa', 'updateBackendAuthUserPoolConfig_mfa' - Describes whether to apply multi-factor authentication policies for your
-- Amazon Cognito user pool configured as a part of your Amplify project.
--
-- 'forgotPassword', 'updateBackendAuthUserPoolConfig_forgotPassword' - Describes the forgot password policy for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
--
-- 'oAuth', 'updateBackendAuthUserPoolConfig_oAuth' - Describes the OAuth policy and rules for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
newUpdateBackendAuthUserPoolConfig ::
  UpdateBackendAuthUserPoolConfig
newUpdateBackendAuthUserPoolConfig :: UpdateBackendAuthUserPoolConfig
newUpdateBackendAuthUserPoolConfig =
  UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthPasswordPolicyConfig
-> Maybe UpdateBackendAuthMFAConfig
-> Maybe UpdateBackendAuthForgotPasswordConfig
-> Maybe UpdateBackendAuthOAuthConfig
-> UpdateBackendAuthUserPoolConfig
UpdateBackendAuthUserPoolConfig'
    { $sel:passwordPolicy:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy =
        Maybe UpdateBackendAuthPasswordPolicyConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:mfa:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthMFAConfig
mfa = Maybe UpdateBackendAuthMFAConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:forgotPassword:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword = Maybe UpdateBackendAuthForgotPasswordConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:oAuth:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthOAuthConfig
oAuth = Maybe UpdateBackendAuthOAuthConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the password policy for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
updateBackendAuthUserPoolConfig_passwordPolicy :: Lens.Lens' UpdateBackendAuthUserPoolConfig (Prelude.Maybe UpdateBackendAuthPasswordPolicyConfig)
updateBackendAuthUserPoolConfig_passwordPolicy :: (Maybe UpdateBackendAuthPasswordPolicyConfig
 -> f (Maybe UpdateBackendAuthPasswordPolicyConfig))
-> UpdateBackendAuthUserPoolConfig
-> f UpdateBackendAuthUserPoolConfig
updateBackendAuthUserPoolConfig_passwordPolicy = (UpdateBackendAuthUserPoolConfig
 -> Maybe UpdateBackendAuthPasswordPolicyConfig)
-> (UpdateBackendAuthUserPoolConfig
    -> Maybe UpdateBackendAuthPasswordPolicyConfig
    -> UpdateBackendAuthUserPoolConfig)
-> Lens
     UpdateBackendAuthUserPoolConfig
     UpdateBackendAuthUserPoolConfig
     (Maybe UpdateBackendAuthPasswordPolicyConfig)
     (Maybe UpdateBackendAuthPasswordPolicyConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthUserPoolConfig' {Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy :: Maybe UpdateBackendAuthPasswordPolicyConfig
$sel:passwordPolicy:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy} -> Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy) (\s :: UpdateBackendAuthUserPoolConfig
s@UpdateBackendAuthUserPoolConfig' {} Maybe UpdateBackendAuthPasswordPolicyConfig
a -> UpdateBackendAuthUserPoolConfig
s {$sel:passwordPolicy:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy = Maybe UpdateBackendAuthPasswordPolicyConfig
a} :: UpdateBackendAuthUserPoolConfig)

-- | Describes whether to apply multi-factor authentication policies for your
-- Amazon Cognito user pool configured as a part of your Amplify project.
updateBackendAuthUserPoolConfig_mfa :: Lens.Lens' UpdateBackendAuthUserPoolConfig (Prelude.Maybe UpdateBackendAuthMFAConfig)
updateBackendAuthUserPoolConfig_mfa :: (Maybe UpdateBackendAuthMFAConfig
 -> f (Maybe UpdateBackendAuthMFAConfig))
-> UpdateBackendAuthUserPoolConfig
-> f UpdateBackendAuthUserPoolConfig
updateBackendAuthUserPoolConfig_mfa = (UpdateBackendAuthUserPoolConfig
 -> Maybe UpdateBackendAuthMFAConfig)
-> (UpdateBackendAuthUserPoolConfig
    -> Maybe UpdateBackendAuthMFAConfig
    -> UpdateBackendAuthUserPoolConfig)
-> Lens
     UpdateBackendAuthUserPoolConfig
     UpdateBackendAuthUserPoolConfig
     (Maybe UpdateBackendAuthMFAConfig)
     (Maybe UpdateBackendAuthMFAConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthUserPoolConfig' {Maybe UpdateBackendAuthMFAConfig
mfa :: Maybe UpdateBackendAuthMFAConfig
$sel:mfa:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig -> Maybe UpdateBackendAuthMFAConfig
mfa} -> Maybe UpdateBackendAuthMFAConfig
mfa) (\s :: UpdateBackendAuthUserPoolConfig
s@UpdateBackendAuthUserPoolConfig' {} Maybe UpdateBackendAuthMFAConfig
a -> UpdateBackendAuthUserPoolConfig
s {$sel:mfa:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthMFAConfig
mfa = Maybe UpdateBackendAuthMFAConfig
a} :: UpdateBackendAuthUserPoolConfig)

-- | Describes the forgot password policy for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
updateBackendAuthUserPoolConfig_forgotPassword :: Lens.Lens' UpdateBackendAuthUserPoolConfig (Prelude.Maybe UpdateBackendAuthForgotPasswordConfig)
updateBackendAuthUserPoolConfig_forgotPassword :: (Maybe UpdateBackendAuthForgotPasswordConfig
 -> f (Maybe UpdateBackendAuthForgotPasswordConfig))
-> UpdateBackendAuthUserPoolConfig
-> f UpdateBackendAuthUserPoolConfig
updateBackendAuthUserPoolConfig_forgotPassword = (UpdateBackendAuthUserPoolConfig
 -> Maybe UpdateBackendAuthForgotPasswordConfig)
-> (UpdateBackendAuthUserPoolConfig
    -> Maybe UpdateBackendAuthForgotPasswordConfig
    -> UpdateBackendAuthUserPoolConfig)
-> Lens
     UpdateBackendAuthUserPoolConfig
     UpdateBackendAuthUserPoolConfig
     (Maybe UpdateBackendAuthForgotPasswordConfig)
     (Maybe UpdateBackendAuthForgotPasswordConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthUserPoolConfig' {Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword :: Maybe UpdateBackendAuthForgotPasswordConfig
$sel:forgotPassword:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword} -> Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword) (\s :: UpdateBackendAuthUserPoolConfig
s@UpdateBackendAuthUserPoolConfig' {} Maybe UpdateBackendAuthForgotPasswordConfig
a -> UpdateBackendAuthUserPoolConfig
s {$sel:forgotPassword:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword = Maybe UpdateBackendAuthForgotPasswordConfig
a} :: UpdateBackendAuthUserPoolConfig)

-- | Describes the OAuth policy and rules for your Amazon Cognito user pool,
-- configured as a part of your Amplify project.
updateBackendAuthUserPoolConfig_oAuth :: Lens.Lens' UpdateBackendAuthUserPoolConfig (Prelude.Maybe UpdateBackendAuthOAuthConfig)
updateBackendAuthUserPoolConfig_oAuth :: (Maybe UpdateBackendAuthOAuthConfig
 -> f (Maybe UpdateBackendAuthOAuthConfig))
-> UpdateBackendAuthUserPoolConfig
-> f UpdateBackendAuthUserPoolConfig
updateBackendAuthUserPoolConfig_oAuth = (UpdateBackendAuthUserPoolConfig
 -> Maybe UpdateBackendAuthOAuthConfig)
-> (UpdateBackendAuthUserPoolConfig
    -> Maybe UpdateBackendAuthOAuthConfig
    -> UpdateBackendAuthUserPoolConfig)
-> Lens
     UpdateBackendAuthUserPoolConfig
     UpdateBackendAuthUserPoolConfig
     (Maybe UpdateBackendAuthOAuthConfig)
     (Maybe UpdateBackendAuthOAuthConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthUserPoolConfig' {Maybe UpdateBackendAuthOAuthConfig
oAuth :: Maybe UpdateBackendAuthOAuthConfig
$sel:oAuth:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthOAuthConfig
oAuth} -> Maybe UpdateBackendAuthOAuthConfig
oAuth) (\s :: UpdateBackendAuthUserPoolConfig
s@UpdateBackendAuthUserPoolConfig' {} Maybe UpdateBackendAuthOAuthConfig
a -> UpdateBackendAuthUserPoolConfig
s {$sel:oAuth:UpdateBackendAuthUserPoolConfig' :: Maybe UpdateBackendAuthOAuthConfig
oAuth = Maybe UpdateBackendAuthOAuthConfig
a} :: UpdateBackendAuthUserPoolConfig)

instance
  Prelude.Hashable
    UpdateBackendAuthUserPoolConfig

instance
  Prelude.NFData
    UpdateBackendAuthUserPoolConfig

instance Core.ToJSON UpdateBackendAuthUserPoolConfig where
  toJSON :: UpdateBackendAuthUserPoolConfig -> Value
toJSON UpdateBackendAuthUserPoolConfig' {Maybe UpdateBackendAuthForgotPasswordConfig
Maybe UpdateBackendAuthMFAConfig
Maybe UpdateBackendAuthOAuthConfig
Maybe UpdateBackendAuthPasswordPolicyConfig
oAuth :: Maybe UpdateBackendAuthOAuthConfig
forgotPassword :: Maybe UpdateBackendAuthForgotPasswordConfig
mfa :: Maybe UpdateBackendAuthMFAConfig
passwordPolicy :: Maybe UpdateBackendAuthPasswordPolicyConfig
$sel:oAuth:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthOAuthConfig
$sel:forgotPassword:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthForgotPasswordConfig
$sel:mfa:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig -> Maybe UpdateBackendAuthMFAConfig
$sel:passwordPolicy:UpdateBackendAuthUserPoolConfig' :: UpdateBackendAuthUserPoolConfig
-> Maybe UpdateBackendAuthPasswordPolicyConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"passwordPolicy" Text -> UpdateBackendAuthPasswordPolicyConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UpdateBackendAuthPasswordPolicyConfig -> Pair)
-> Maybe UpdateBackendAuthPasswordPolicyConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateBackendAuthPasswordPolicyConfig
passwordPolicy,
            (Text
"mfa" Text -> UpdateBackendAuthMFAConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UpdateBackendAuthMFAConfig -> Pair)
-> Maybe UpdateBackendAuthMFAConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateBackendAuthMFAConfig
mfa,
            (Text
"forgotPassword" Text -> UpdateBackendAuthForgotPasswordConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UpdateBackendAuthForgotPasswordConfig -> Pair)
-> Maybe UpdateBackendAuthForgotPasswordConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateBackendAuthForgotPasswordConfig
forgotPassword,
            (Text
"oAuth" Text -> UpdateBackendAuthOAuthConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UpdateBackendAuthOAuthConfig -> Pair)
-> Maybe UpdateBackendAuthOAuthConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateBackendAuthOAuthConfig
oAuth
          ]
      )