{-# 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.CognitoIdentityProvider.Types.PasswordPolicyType
-- 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.CognitoIdentityProvider.Types.PasswordPolicyType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The password policy type.
--
-- /See:/ 'newPasswordPolicyType' smart constructor.
data PasswordPolicyType = PasswordPolicyType'
  { -- | In the password policy that you have set, refers to whether you have
    -- required users to use at least one number in their password.
    PasswordPolicyType -> Maybe Bool
requireNumbers :: Prelude.Maybe Prelude.Bool,
    -- | In the password policy that you have set, refers to whether you have
    -- required users to use at least one uppercase letter in their password.
    PasswordPolicyType -> Maybe Bool
requireUppercase :: Prelude.Maybe Prelude.Bool,
    -- | In the password policy that you have set, refers to whether you have
    -- required users to use at least one lowercase letter in their password.
    PasswordPolicyType -> Maybe Bool
requireLowercase :: Prelude.Maybe Prelude.Bool,
    -- | The minimum length of the password policy that you have set. Cannot be
    -- less than 6.
    PasswordPolicyType -> Maybe Natural
minimumLength :: Prelude.Maybe Prelude.Natural,
    -- | In the password policy that you have set, refers to whether you have
    -- required users to use at least one symbol in their password.
    PasswordPolicyType -> Maybe Bool
requireSymbols :: Prelude.Maybe Prelude.Bool,
    -- | In the password policy you have set, refers to the number of days a
    -- temporary password is valid. If the user does not sign-in during this
    -- time, their password will need to be reset by an administrator.
    --
    -- When you set @TemporaryPasswordValidityDays@ for a user pool, you will
    -- no longer be able to set the deprecated @UnusedAccountValidityDays@
    -- value for that user pool.
    PasswordPolicyType -> Maybe Natural
temporaryPasswordValidityDays :: Prelude.Maybe Prelude.Natural
  }
  deriving (PasswordPolicyType -> PasswordPolicyType -> Bool
(PasswordPolicyType -> PasswordPolicyType -> Bool)
-> (PasswordPolicyType -> PasswordPolicyType -> Bool)
-> Eq PasswordPolicyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PasswordPolicyType -> PasswordPolicyType -> Bool
$c/= :: PasswordPolicyType -> PasswordPolicyType -> Bool
== :: PasswordPolicyType -> PasswordPolicyType -> Bool
$c== :: PasswordPolicyType -> PasswordPolicyType -> Bool
Prelude.Eq, ReadPrec [PasswordPolicyType]
ReadPrec PasswordPolicyType
Int -> ReadS PasswordPolicyType
ReadS [PasswordPolicyType]
(Int -> ReadS PasswordPolicyType)
-> ReadS [PasswordPolicyType]
-> ReadPrec PasswordPolicyType
-> ReadPrec [PasswordPolicyType]
-> Read PasswordPolicyType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PasswordPolicyType]
$creadListPrec :: ReadPrec [PasswordPolicyType]
readPrec :: ReadPrec PasswordPolicyType
$creadPrec :: ReadPrec PasswordPolicyType
readList :: ReadS [PasswordPolicyType]
$creadList :: ReadS [PasswordPolicyType]
readsPrec :: Int -> ReadS PasswordPolicyType
$creadsPrec :: Int -> ReadS PasswordPolicyType
Prelude.Read, Int -> PasswordPolicyType -> ShowS
[PasswordPolicyType] -> ShowS
PasswordPolicyType -> String
(Int -> PasswordPolicyType -> ShowS)
-> (PasswordPolicyType -> String)
-> ([PasswordPolicyType] -> ShowS)
-> Show PasswordPolicyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PasswordPolicyType] -> ShowS
$cshowList :: [PasswordPolicyType] -> ShowS
show :: PasswordPolicyType -> String
$cshow :: PasswordPolicyType -> String
showsPrec :: Int -> PasswordPolicyType -> ShowS
$cshowsPrec :: Int -> PasswordPolicyType -> ShowS
Prelude.Show, (forall x. PasswordPolicyType -> Rep PasswordPolicyType x)
-> (forall x. Rep PasswordPolicyType x -> PasswordPolicyType)
-> Generic PasswordPolicyType
forall x. Rep PasswordPolicyType x -> PasswordPolicyType
forall x. PasswordPolicyType -> Rep PasswordPolicyType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PasswordPolicyType x -> PasswordPolicyType
$cfrom :: forall x. PasswordPolicyType -> Rep PasswordPolicyType x
Prelude.Generic)

-- |
-- Create a value of 'PasswordPolicyType' 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:
--
-- 'requireNumbers', 'passwordPolicyType_requireNumbers' - In the password policy that you have set, refers to whether you have
-- required users to use at least one number in their password.
--
-- 'requireUppercase', 'passwordPolicyType_requireUppercase' - In the password policy that you have set, refers to whether you have
-- required users to use at least one uppercase letter in their password.
--
-- 'requireLowercase', 'passwordPolicyType_requireLowercase' - In the password policy that you have set, refers to whether you have
-- required users to use at least one lowercase letter in their password.
--
-- 'minimumLength', 'passwordPolicyType_minimumLength' - The minimum length of the password policy that you have set. Cannot be
-- less than 6.
--
-- 'requireSymbols', 'passwordPolicyType_requireSymbols' - In the password policy that you have set, refers to whether you have
-- required users to use at least one symbol in their password.
--
-- 'temporaryPasswordValidityDays', 'passwordPolicyType_temporaryPasswordValidityDays' - In the password policy you have set, refers to the number of days a
-- temporary password is valid. If the user does not sign-in during this
-- time, their password will need to be reset by an administrator.
--
-- When you set @TemporaryPasswordValidityDays@ for a user pool, you will
-- no longer be able to set the deprecated @UnusedAccountValidityDays@
-- value for that user pool.
newPasswordPolicyType ::
  PasswordPolicyType
newPasswordPolicyType :: PasswordPolicyType
newPasswordPolicyType =
  PasswordPolicyType' :: Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Natural
-> Maybe Bool
-> Maybe Natural
-> PasswordPolicyType
PasswordPolicyType'
    { $sel:requireNumbers:PasswordPolicyType' :: Maybe Bool
requireNumbers =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:requireUppercase:PasswordPolicyType' :: Maybe Bool
requireUppercase = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:requireLowercase:PasswordPolicyType' :: Maybe Bool
requireLowercase = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:minimumLength:PasswordPolicyType' :: Maybe Natural
minimumLength = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:requireSymbols:PasswordPolicyType' :: Maybe Bool
requireSymbols = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:temporaryPasswordValidityDays:PasswordPolicyType' :: Maybe Natural
temporaryPasswordValidityDays = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | In the password policy that you have set, refers to whether you have
-- required users to use at least one number in their password.
passwordPolicyType_requireNumbers :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Bool)
passwordPolicyType_requireNumbers :: (Maybe Bool -> f (Maybe Bool))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_requireNumbers = (PasswordPolicyType -> Maybe Bool)
-> (PasswordPolicyType -> Maybe Bool -> PasswordPolicyType)
-> Lens
     PasswordPolicyType PasswordPolicyType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Bool
requireNumbers :: Maybe Bool
$sel:requireNumbers:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
requireNumbers} -> Maybe Bool
requireNumbers) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Bool
a -> PasswordPolicyType
s {$sel:requireNumbers:PasswordPolicyType' :: Maybe Bool
requireNumbers = Maybe Bool
a} :: PasswordPolicyType)

-- | In the password policy that you have set, refers to whether you have
-- required users to use at least one uppercase letter in their password.
passwordPolicyType_requireUppercase :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Bool)
passwordPolicyType_requireUppercase :: (Maybe Bool -> f (Maybe Bool))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_requireUppercase = (PasswordPolicyType -> Maybe Bool)
-> (PasswordPolicyType -> Maybe Bool -> PasswordPolicyType)
-> Lens
     PasswordPolicyType PasswordPolicyType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Bool
requireUppercase :: Maybe Bool
$sel:requireUppercase:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
requireUppercase} -> Maybe Bool
requireUppercase) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Bool
a -> PasswordPolicyType
s {$sel:requireUppercase:PasswordPolicyType' :: Maybe Bool
requireUppercase = Maybe Bool
a} :: PasswordPolicyType)

-- | In the password policy that you have set, refers to whether you have
-- required users to use at least one lowercase letter in their password.
passwordPolicyType_requireLowercase :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Bool)
passwordPolicyType_requireLowercase :: (Maybe Bool -> f (Maybe Bool))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_requireLowercase = (PasswordPolicyType -> Maybe Bool)
-> (PasswordPolicyType -> Maybe Bool -> PasswordPolicyType)
-> Lens
     PasswordPolicyType PasswordPolicyType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Bool
requireLowercase :: Maybe Bool
$sel:requireLowercase:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
requireLowercase} -> Maybe Bool
requireLowercase) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Bool
a -> PasswordPolicyType
s {$sel:requireLowercase:PasswordPolicyType' :: Maybe Bool
requireLowercase = Maybe Bool
a} :: PasswordPolicyType)

-- | The minimum length of the password policy that you have set. Cannot be
-- less than 6.
passwordPolicyType_minimumLength :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Natural)
passwordPolicyType_minimumLength :: (Maybe Natural -> f (Maybe Natural))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_minimumLength = (PasswordPolicyType -> Maybe Natural)
-> (PasswordPolicyType -> Maybe Natural -> PasswordPolicyType)
-> Lens
     PasswordPolicyType
     PasswordPolicyType
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Natural
minimumLength :: Maybe Natural
$sel:minimumLength:PasswordPolicyType' :: PasswordPolicyType -> Maybe Natural
minimumLength} -> Maybe Natural
minimumLength) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Natural
a -> PasswordPolicyType
s {$sel:minimumLength:PasswordPolicyType' :: Maybe Natural
minimumLength = Maybe Natural
a} :: PasswordPolicyType)

-- | In the password policy that you have set, refers to whether you have
-- required users to use at least one symbol in their password.
passwordPolicyType_requireSymbols :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Bool)
passwordPolicyType_requireSymbols :: (Maybe Bool -> f (Maybe Bool))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_requireSymbols = (PasswordPolicyType -> Maybe Bool)
-> (PasswordPolicyType -> Maybe Bool -> PasswordPolicyType)
-> Lens
     PasswordPolicyType PasswordPolicyType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Bool
requireSymbols :: Maybe Bool
$sel:requireSymbols:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
requireSymbols} -> Maybe Bool
requireSymbols) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Bool
a -> PasswordPolicyType
s {$sel:requireSymbols:PasswordPolicyType' :: Maybe Bool
requireSymbols = Maybe Bool
a} :: PasswordPolicyType)

-- | In the password policy you have set, refers to the number of days a
-- temporary password is valid. If the user does not sign-in during this
-- time, their password will need to be reset by an administrator.
--
-- When you set @TemporaryPasswordValidityDays@ for a user pool, you will
-- no longer be able to set the deprecated @UnusedAccountValidityDays@
-- value for that user pool.
passwordPolicyType_temporaryPasswordValidityDays :: Lens.Lens' PasswordPolicyType (Prelude.Maybe Prelude.Natural)
passwordPolicyType_temporaryPasswordValidityDays :: (Maybe Natural -> f (Maybe Natural))
-> PasswordPolicyType -> f PasswordPolicyType
passwordPolicyType_temporaryPasswordValidityDays = (PasswordPolicyType -> Maybe Natural)
-> (PasswordPolicyType -> Maybe Natural -> PasswordPolicyType)
-> Lens
     PasswordPolicyType
     PasswordPolicyType
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PasswordPolicyType' {Maybe Natural
temporaryPasswordValidityDays :: Maybe Natural
$sel:temporaryPasswordValidityDays:PasswordPolicyType' :: PasswordPolicyType -> Maybe Natural
temporaryPasswordValidityDays} -> Maybe Natural
temporaryPasswordValidityDays) (\s :: PasswordPolicyType
s@PasswordPolicyType' {} Maybe Natural
a -> PasswordPolicyType
s {$sel:temporaryPasswordValidityDays:PasswordPolicyType' :: Maybe Natural
temporaryPasswordValidityDays = Maybe Natural
a} :: PasswordPolicyType)

instance Core.FromJSON PasswordPolicyType where
  parseJSON :: Value -> Parser PasswordPolicyType
parseJSON =
    String
-> (Object -> Parser PasswordPolicyType)
-> Value
-> Parser PasswordPolicyType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PasswordPolicyType"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Natural
-> Maybe Bool
-> Maybe Natural
-> PasswordPolicyType
PasswordPolicyType'
            (Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Natural
 -> Maybe Bool
 -> Maybe Natural
 -> PasswordPolicyType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Natural
      -> Maybe Bool
      -> Maybe Natural
      -> PasswordPolicyType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequireNumbers")
            Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Natural
   -> Maybe Bool
   -> Maybe Natural
   -> PasswordPolicyType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Natural
      -> Maybe Bool
      -> Maybe Natural
      -> PasswordPolicyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequireUppercase")
            Parser
  (Maybe Bool
   -> Maybe Natural
   -> Maybe Bool
   -> Maybe Natural
   -> PasswordPolicyType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Natural
      -> Maybe Bool -> Maybe Natural -> PasswordPolicyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequireLowercase")
            Parser
  (Maybe Natural
   -> Maybe Bool -> Maybe Natural -> PasswordPolicyType)
-> Parser (Maybe Natural)
-> Parser (Maybe Bool -> Maybe Natural -> PasswordPolicyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinimumLength")
            Parser (Maybe Bool -> Maybe Natural -> PasswordPolicyType)
-> Parser (Maybe Bool)
-> Parser (Maybe Natural -> PasswordPolicyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequireSymbols")
            Parser (Maybe Natural -> PasswordPolicyType)
-> Parser (Maybe Natural) -> Parser PasswordPolicyType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TemporaryPasswordValidityDays")
      )

instance Prelude.Hashable PasswordPolicyType

instance Prelude.NFData PasswordPolicyType

instance Core.ToJSON PasswordPolicyType where
  toJSON :: PasswordPolicyType -> Value
toJSON PasswordPolicyType' {Maybe Bool
Maybe Natural
temporaryPasswordValidityDays :: Maybe Natural
requireSymbols :: Maybe Bool
minimumLength :: Maybe Natural
requireLowercase :: Maybe Bool
requireUppercase :: Maybe Bool
requireNumbers :: Maybe Bool
$sel:temporaryPasswordValidityDays:PasswordPolicyType' :: PasswordPolicyType -> Maybe Natural
$sel:requireSymbols:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
$sel:minimumLength:PasswordPolicyType' :: PasswordPolicyType -> Maybe Natural
$sel:requireLowercase:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
$sel:requireUppercase:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
$sel:requireNumbers:PasswordPolicyType' :: PasswordPolicyType -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RequireNumbers" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
requireNumbers,
            (Text
"RequireUppercase" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
requireUppercase,
            (Text
"RequireLowercase" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
requireLowercase,
            (Text
"MinimumLength" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minimumLength,
            (Text
"RequireSymbols" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
requireSymbols,
            (Text
"TemporaryPasswordValidityDays" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
temporaryPasswordValidityDays
          ]
      )