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

import Amazonka.AmplifyBackend.Types.AdditionalConstraintsElement
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the password policy for your Amazon Cognito user pool
-- configured as a part of your Amplify project.
--
-- /See:/ 'newUpdateBackendAuthPasswordPolicyConfig' smart constructor.
data UpdateBackendAuthPasswordPolicyConfig = UpdateBackendAuthPasswordPolicyConfig'
  { -- | Describes additional constraints on password requirements to sign in to
    -- the auth resource, configured as a part of your Amplify project.
    UpdateBackendAuthPasswordPolicyConfig
-> Maybe [AdditionalConstraintsElement]
additionalConstraints :: Prelude.Maybe [AdditionalConstraintsElement],
    -- | Describes the minimum length of the password required to sign in to the
    -- auth resource, configured as a part of your Amplify project.
    UpdateBackendAuthPasswordPolicyConfig -> Maybe Double
minimumLength :: Prelude.Maybe Prelude.Double
  }
  deriving (UpdateBackendAuthPasswordPolicyConfig
-> UpdateBackendAuthPasswordPolicyConfig -> Bool
(UpdateBackendAuthPasswordPolicyConfig
 -> UpdateBackendAuthPasswordPolicyConfig -> Bool)
-> (UpdateBackendAuthPasswordPolicyConfig
    -> UpdateBackendAuthPasswordPolicyConfig -> Bool)
-> Eq UpdateBackendAuthPasswordPolicyConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateBackendAuthPasswordPolicyConfig
-> UpdateBackendAuthPasswordPolicyConfig -> Bool
$c/= :: UpdateBackendAuthPasswordPolicyConfig
-> UpdateBackendAuthPasswordPolicyConfig -> Bool
== :: UpdateBackendAuthPasswordPolicyConfig
-> UpdateBackendAuthPasswordPolicyConfig -> Bool
$c== :: UpdateBackendAuthPasswordPolicyConfig
-> UpdateBackendAuthPasswordPolicyConfig -> Bool
Prelude.Eq, ReadPrec [UpdateBackendAuthPasswordPolicyConfig]
ReadPrec UpdateBackendAuthPasswordPolicyConfig
Int -> ReadS UpdateBackendAuthPasswordPolicyConfig
ReadS [UpdateBackendAuthPasswordPolicyConfig]
(Int -> ReadS UpdateBackendAuthPasswordPolicyConfig)
-> ReadS [UpdateBackendAuthPasswordPolicyConfig]
-> ReadPrec UpdateBackendAuthPasswordPolicyConfig
-> ReadPrec [UpdateBackendAuthPasswordPolicyConfig]
-> Read UpdateBackendAuthPasswordPolicyConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateBackendAuthPasswordPolicyConfig]
$creadListPrec :: ReadPrec [UpdateBackendAuthPasswordPolicyConfig]
readPrec :: ReadPrec UpdateBackendAuthPasswordPolicyConfig
$creadPrec :: ReadPrec UpdateBackendAuthPasswordPolicyConfig
readList :: ReadS [UpdateBackendAuthPasswordPolicyConfig]
$creadList :: ReadS [UpdateBackendAuthPasswordPolicyConfig]
readsPrec :: Int -> ReadS UpdateBackendAuthPasswordPolicyConfig
$creadsPrec :: Int -> ReadS UpdateBackendAuthPasswordPolicyConfig
Prelude.Read, Int -> UpdateBackendAuthPasswordPolicyConfig -> ShowS
[UpdateBackendAuthPasswordPolicyConfig] -> ShowS
UpdateBackendAuthPasswordPolicyConfig -> String
(Int -> UpdateBackendAuthPasswordPolicyConfig -> ShowS)
-> (UpdateBackendAuthPasswordPolicyConfig -> String)
-> ([UpdateBackendAuthPasswordPolicyConfig] -> ShowS)
-> Show UpdateBackendAuthPasswordPolicyConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateBackendAuthPasswordPolicyConfig] -> ShowS
$cshowList :: [UpdateBackendAuthPasswordPolicyConfig] -> ShowS
show :: UpdateBackendAuthPasswordPolicyConfig -> String
$cshow :: UpdateBackendAuthPasswordPolicyConfig -> String
showsPrec :: Int -> UpdateBackendAuthPasswordPolicyConfig -> ShowS
$cshowsPrec :: Int -> UpdateBackendAuthPasswordPolicyConfig -> ShowS
Prelude.Show, (forall x.
 UpdateBackendAuthPasswordPolicyConfig
 -> Rep UpdateBackendAuthPasswordPolicyConfig x)
-> (forall x.
    Rep UpdateBackendAuthPasswordPolicyConfig x
    -> UpdateBackendAuthPasswordPolicyConfig)
-> Generic UpdateBackendAuthPasswordPolicyConfig
forall x.
Rep UpdateBackendAuthPasswordPolicyConfig x
-> UpdateBackendAuthPasswordPolicyConfig
forall x.
UpdateBackendAuthPasswordPolicyConfig
-> Rep UpdateBackendAuthPasswordPolicyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateBackendAuthPasswordPolicyConfig x
-> UpdateBackendAuthPasswordPolicyConfig
$cfrom :: forall x.
UpdateBackendAuthPasswordPolicyConfig
-> Rep UpdateBackendAuthPasswordPolicyConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateBackendAuthPasswordPolicyConfig' 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:
--
-- 'additionalConstraints', 'updateBackendAuthPasswordPolicyConfig_additionalConstraints' - Describes additional constraints on password requirements to sign in to
-- the auth resource, configured as a part of your Amplify project.
--
-- 'minimumLength', 'updateBackendAuthPasswordPolicyConfig_minimumLength' - Describes the minimum length of the password required to sign in to the
-- auth resource, configured as a part of your Amplify project.
newUpdateBackendAuthPasswordPolicyConfig ::
  UpdateBackendAuthPasswordPolicyConfig
newUpdateBackendAuthPasswordPolicyConfig :: UpdateBackendAuthPasswordPolicyConfig
newUpdateBackendAuthPasswordPolicyConfig =
  UpdateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
-> Maybe Double -> UpdateBackendAuthPasswordPolicyConfig
UpdateBackendAuthPasswordPolicyConfig'
    { $sel:additionalConstraints:UpdateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
additionalConstraints =
        Maybe [AdditionalConstraintsElement]
forall a. Maybe a
Prelude.Nothing,
      $sel:minimumLength:UpdateBackendAuthPasswordPolicyConfig' :: Maybe Double
minimumLength = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes additional constraints on password requirements to sign in to
-- the auth resource, configured as a part of your Amplify project.
updateBackendAuthPasswordPolicyConfig_additionalConstraints :: Lens.Lens' UpdateBackendAuthPasswordPolicyConfig (Prelude.Maybe [AdditionalConstraintsElement])
updateBackendAuthPasswordPolicyConfig_additionalConstraints :: (Maybe [AdditionalConstraintsElement]
 -> f (Maybe [AdditionalConstraintsElement]))
-> UpdateBackendAuthPasswordPolicyConfig
-> f UpdateBackendAuthPasswordPolicyConfig
updateBackendAuthPasswordPolicyConfig_additionalConstraints = (UpdateBackendAuthPasswordPolicyConfig
 -> Maybe [AdditionalConstraintsElement])
-> (UpdateBackendAuthPasswordPolicyConfig
    -> Maybe [AdditionalConstraintsElement]
    -> UpdateBackendAuthPasswordPolicyConfig)
-> Lens
     UpdateBackendAuthPasswordPolicyConfig
     UpdateBackendAuthPasswordPolicyConfig
     (Maybe [AdditionalConstraintsElement])
     (Maybe [AdditionalConstraintsElement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthPasswordPolicyConfig' {Maybe [AdditionalConstraintsElement]
additionalConstraints :: Maybe [AdditionalConstraintsElement]
$sel:additionalConstraints:UpdateBackendAuthPasswordPolicyConfig' :: UpdateBackendAuthPasswordPolicyConfig
-> Maybe [AdditionalConstraintsElement]
additionalConstraints} -> Maybe [AdditionalConstraintsElement]
additionalConstraints) (\s :: UpdateBackendAuthPasswordPolicyConfig
s@UpdateBackendAuthPasswordPolicyConfig' {} Maybe [AdditionalConstraintsElement]
a -> UpdateBackendAuthPasswordPolicyConfig
s {$sel:additionalConstraints:UpdateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
additionalConstraints = Maybe [AdditionalConstraintsElement]
a} :: UpdateBackendAuthPasswordPolicyConfig) ((Maybe [AdditionalConstraintsElement]
  -> f (Maybe [AdditionalConstraintsElement]))
 -> UpdateBackendAuthPasswordPolicyConfig
 -> f UpdateBackendAuthPasswordPolicyConfig)
-> ((Maybe [AdditionalConstraintsElement]
     -> f (Maybe [AdditionalConstraintsElement]))
    -> Maybe [AdditionalConstraintsElement]
    -> f (Maybe [AdditionalConstraintsElement]))
-> (Maybe [AdditionalConstraintsElement]
    -> f (Maybe [AdditionalConstraintsElement]))
-> UpdateBackendAuthPasswordPolicyConfig
-> f UpdateBackendAuthPasswordPolicyConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
-> Iso
     (Maybe [AdditionalConstraintsElement])
     (Maybe [AdditionalConstraintsElement])
     (Maybe [AdditionalConstraintsElement])
     (Maybe [AdditionalConstraintsElement])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
  [AdditionalConstraintsElement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Describes the minimum length of the password required to sign in to the
-- auth resource, configured as a part of your Amplify project.
updateBackendAuthPasswordPolicyConfig_minimumLength :: Lens.Lens' UpdateBackendAuthPasswordPolicyConfig (Prelude.Maybe Prelude.Double)
updateBackendAuthPasswordPolicyConfig_minimumLength :: (Maybe Double -> f (Maybe Double))
-> UpdateBackendAuthPasswordPolicyConfig
-> f UpdateBackendAuthPasswordPolicyConfig
updateBackendAuthPasswordPolicyConfig_minimumLength = (UpdateBackendAuthPasswordPolicyConfig -> Maybe Double)
-> (UpdateBackendAuthPasswordPolicyConfig
    -> Maybe Double -> UpdateBackendAuthPasswordPolicyConfig)
-> Lens
     UpdateBackendAuthPasswordPolicyConfig
     UpdateBackendAuthPasswordPolicyConfig
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBackendAuthPasswordPolicyConfig' {Maybe Double
minimumLength :: Maybe Double
$sel:minimumLength:UpdateBackendAuthPasswordPolicyConfig' :: UpdateBackendAuthPasswordPolicyConfig -> Maybe Double
minimumLength} -> Maybe Double
minimumLength) (\s :: UpdateBackendAuthPasswordPolicyConfig
s@UpdateBackendAuthPasswordPolicyConfig' {} Maybe Double
a -> UpdateBackendAuthPasswordPolicyConfig
s {$sel:minimumLength:UpdateBackendAuthPasswordPolicyConfig' :: Maybe Double
minimumLength = Maybe Double
a} :: UpdateBackendAuthPasswordPolicyConfig)

instance
  Prelude.Hashable
    UpdateBackendAuthPasswordPolicyConfig

instance
  Prelude.NFData
    UpdateBackendAuthPasswordPolicyConfig

instance
  Core.ToJSON
    UpdateBackendAuthPasswordPolicyConfig
  where
  toJSON :: UpdateBackendAuthPasswordPolicyConfig -> Value
toJSON UpdateBackendAuthPasswordPolicyConfig' {Maybe Double
Maybe [AdditionalConstraintsElement]
minimumLength :: Maybe Double
additionalConstraints :: Maybe [AdditionalConstraintsElement]
$sel:minimumLength:UpdateBackendAuthPasswordPolicyConfig' :: UpdateBackendAuthPasswordPolicyConfig -> Maybe Double
$sel:additionalConstraints:UpdateBackendAuthPasswordPolicyConfig' :: UpdateBackendAuthPasswordPolicyConfig
-> Maybe [AdditionalConstraintsElement]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"additionalConstraints" Text -> [AdditionalConstraintsElement] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AdditionalConstraintsElement] -> Pair)
-> Maybe [AdditionalConstraintsElement] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AdditionalConstraintsElement]
additionalConstraints,
            (Text
"minimumLength" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minimumLength
          ]
      )