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

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

-- | The password policy configuration for the backend to your Amplify
-- project.
--
-- /See:/ 'newCreateBackendAuthPasswordPolicyConfig' smart constructor.
data CreateBackendAuthPasswordPolicyConfig = CreateBackendAuthPasswordPolicyConfig'
  { -- | Additional constraints for the password used to access the backend of
    -- your Amplify project.
    CreateBackendAuthPasswordPolicyConfig
-> Maybe [AdditionalConstraintsElement]
additionalConstraints :: Prelude.Maybe [AdditionalConstraintsElement],
    -- | The minimum length of the password used to access the backend of your
    -- Amplify project.
    CreateBackendAuthPasswordPolicyConfig -> Double
minimumLength :: Prelude.Double
  }
  deriving (CreateBackendAuthPasswordPolicyConfig
-> CreateBackendAuthPasswordPolicyConfig -> Bool
(CreateBackendAuthPasswordPolicyConfig
 -> CreateBackendAuthPasswordPolicyConfig -> Bool)
-> (CreateBackendAuthPasswordPolicyConfig
    -> CreateBackendAuthPasswordPolicyConfig -> Bool)
-> Eq CreateBackendAuthPasswordPolicyConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBackendAuthPasswordPolicyConfig
-> CreateBackendAuthPasswordPolicyConfig -> Bool
$c/= :: CreateBackendAuthPasswordPolicyConfig
-> CreateBackendAuthPasswordPolicyConfig -> Bool
== :: CreateBackendAuthPasswordPolicyConfig
-> CreateBackendAuthPasswordPolicyConfig -> Bool
$c== :: CreateBackendAuthPasswordPolicyConfig
-> CreateBackendAuthPasswordPolicyConfig -> Bool
Prelude.Eq, ReadPrec [CreateBackendAuthPasswordPolicyConfig]
ReadPrec CreateBackendAuthPasswordPolicyConfig
Int -> ReadS CreateBackendAuthPasswordPolicyConfig
ReadS [CreateBackendAuthPasswordPolicyConfig]
(Int -> ReadS CreateBackendAuthPasswordPolicyConfig)
-> ReadS [CreateBackendAuthPasswordPolicyConfig]
-> ReadPrec CreateBackendAuthPasswordPolicyConfig
-> ReadPrec [CreateBackendAuthPasswordPolicyConfig]
-> Read CreateBackendAuthPasswordPolicyConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBackendAuthPasswordPolicyConfig]
$creadListPrec :: ReadPrec [CreateBackendAuthPasswordPolicyConfig]
readPrec :: ReadPrec CreateBackendAuthPasswordPolicyConfig
$creadPrec :: ReadPrec CreateBackendAuthPasswordPolicyConfig
readList :: ReadS [CreateBackendAuthPasswordPolicyConfig]
$creadList :: ReadS [CreateBackendAuthPasswordPolicyConfig]
readsPrec :: Int -> ReadS CreateBackendAuthPasswordPolicyConfig
$creadsPrec :: Int -> ReadS CreateBackendAuthPasswordPolicyConfig
Prelude.Read, Int -> CreateBackendAuthPasswordPolicyConfig -> ShowS
[CreateBackendAuthPasswordPolicyConfig] -> ShowS
CreateBackendAuthPasswordPolicyConfig -> String
(Int -> CreateBackendAuthPasswordPolicyConfig -> ShowS)
-> (CreateBackendAuthPasswordPolicyConfig -> String)
-> ([CreateBackendAuthPasswordPolicyConfig] -> ShowS)
-> Show CreateBackendAuthPasswordPolicyConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBackendAuthPasswordPolicyConfig] -> ShowS
$cshowList :: [CreateBackendAuthPasswordPolicyConfig] -> ShowS
show :: CreateBackendAuthPasswordPolicyConfig -> String
$cshow :: CreateBackendAuthPasswordPolicyConfig -> String
showsPrec :: Int -> CreateBackendAuthPasswordPolicyConfig -> ShowS
$cshowsPrec :: Int -> CreateBackendAuthPasswordPolicyConfig -> ShowS
Prelude.Show, (forall x.
 CreateBackendAuthPasswordPolicyConfig
 -> Rep CreateBackendAuthPasswordPolicyConfig x)
-> (forall x.
    Rep CreateBackendAuthPasswordPolicyConfig x
    -> CreateBackendAuthPasswordPolicyConfig)
-> Generic CreateBackendAuthPasswordPolicyConfig
forall x.
Rep CreateBackendAuthPasswordPolicyConfig x
-> CreateBackendAuthPasswordPolicyConfig
forall x.
CreateBackendAuthPasswordPolicyConfig
-> Rep CreateBackendAuthPasswordPolicyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateBackendAuthPasswordPolicyConfig x
-> CreateBackendAuthPasswordPolicyConfig
$cfrom :: forall x.
CreateBackendAuthPasswordPolicyConfig
-> Rep CreateBackendAuthPasswordPolicyConfig x
Prelude.Generic)

-- |
-- Create a value of 'CreateBackendAuthPasswordPolicyConfig' 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', 'createBackendAuthPasswordPolicyConfig_additionalConstraints' - Additional constraints for the password used to access the backend of
-- your Amplify project.
--
-- 'minimumLength', 'createBackendAuthPasswordPolicyConfig_minimumLength' - The minimum length of the password used to access the backend of your
-- Amplify project.
newCreateBackendAuthPasswordPolicyConfig ::
  -- | 'minimumLength'
  Prelude.Double ->
  CreateBackendAuthPasswordPolicyConfig
newCreateBackendAuthPasswordPolicyConfig :: Double -> CreateBackendAuthPasswordPolicyConfig
newCreateBackendAuthPasswordPolicyConfig
  Double
pMinimumLength_ =
    CreateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
-> Double -> CreateBackendAuthPasswordPolicyConfig
CreateBackendAuthPasswordPolicyConfig'
      { $sel:additionalConstraints:CreateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
additionalConstraints =
          Maybe [AdditionalConstraintsElement]
forall a. Maybe a
Prelude.Nothing,
        $sel:minimumLength:CreateBackendAuthPasswordPolicyConfig' :: Double
minimumLength = Double
pMinimumLength_
      }

-- | Additional constraints for the password used to access the backend of
-- your Amplify project.
createBackendAuthPasswordPolicyConfig_additionalConstraints :: Lens.Lens' CreateBackendAuthPasswordPolicyConfig (Prelude.Maybe [AdditionalConstraintsElement])
createBackendAuthPasswordPolicyConfig_additionalConstraints :: (Maybe [AdditionalConstraintsElement]
 -> f (Maybe [AdditionalConstraintsElement]))
-> CreateBackendAuthPasswordPolicyConfig
-> f CreateBackendAuthPasswordPolicyConfig
createBackendAuthPasswordPolicyConfig_additionalConstraints = (CreateBackendAuthPasswordPolicyConfig
 -> Maybe [AdditionalConstraintsElement])
-> (CreateBackendAuthPasswordPolicyConfig
    -> Maybe [AdditionalConstraintsElement]
    -> CreateBackendAuthPasswordPolicyConfig)
-> Lens
     CreateBackendAuthPasswordPolicyConfig
     CreateBackendAuthPasswordPolicyConfig
     (Maybe [AdditionalConstraintsElement])
     (Maybe [AdditionalConstraintsElement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthPasswordPolicyConfig' {Maybe [AdditionalConstraintsElement]
additionalConstraints :: Maybe [AdditionalConstraintsElement]
$sel:additionalConstraints:CreateBackendAuthPasswordPolicyConfig' :: CreateBackendAuthPasswordPolicyConfig
-> Maybe [AdditionalConstraintsElement]
additionalConstraints} -> Maybe [AdditionalConstraintsElement]
additionalConstraints) (\s :: CreateBackendAuthPasswordPolicyConfig
s@CreateBackendAuthPasswordPolicyConfig' {} Maybe [AdditionalConstraintsElement]
a -> CreateBackendAuthPasswordPolicyConfig
s {$sel:additionalConstraints:CreateBackendAuthPasswordPolicyConfig' :: Maybe [AdditionalConstraintsElement]
additionalConstraints = Maybe [AdditionalConstraintsElement]
a} :: CreateBackendAuthPasswordPolicyConfig) ((Maybe [AdditionalConstraintsElement]
  -> f (Maybe [AdditionalConstraintsElement]))
 -> CreateBackendAuthPasswordPolicyConfig
 -> f CreateBackendAuthPasswordPolicyConfig)
-> ((Maybe [AdditionalConstraintsElement]
     -> f (Maybe [AdditionalConstraintsElement]))
    -> Maybe [AdditionalConstraintsElement]
    -> f (Maybe [AdditionalConstraintsElement]))
-> (Maybe [AdditionalConstraintsElement]
    -> f (Maybe [AdditionalConstraintsElement]))
-> CreateBackendAuthPasswordPolicyConfig
-> f CreateBackendAuthPasswordPolicyConfig
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

-- | The minimum length of the password used to access the backend of your
-- Amplify project.
createBackendAuthPasswordPolicyConfig_minimumLength :: Lens.Lens' CreateBackendAuthPasswordPolicyConfig Prelude.Double
createBackendAuthPasswordPolicyConfig_minimumLength :: (Double -> f Double)
-> CreateBackendAuthPasswordPolicyConfig
-> f CreateBackendAuthPasswordPolicyConfig
createBackendAuthPasswordPolicyConfig_minimumLength = (CreateBackendAuthPasswordPolicyConfig -> Double)
-> (CreateBackendAuthPasswordPolicyConfig
    -> Double -> CreateBackendAuthPasswordPolicyConfig)
-> Lens
     CreateBackendAuthPasswordPolicyConfig
     CreateBackendAuthPasswordPolicyConfig
     Double
     Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackendAuthPasswordPolicyConfig' {Double
minimumLength :: Double
$sel:minimumLength:CreateBackendAuthPasswordPolicyConfig' :: CreateBackendAuthPasswordPolicyConfig -> Double
minimumLength} -> Double
minimumLength) (\s :: CreateBackendAuthPasswordPolicyConfig
s@CreateBackendAuthPasswordPolicyConfig' {} Double
a -> CreateBackendAuthPasswordPolicyConfig
s {$sel:minimumLength:CreateBackendAuthPasswordPolicyConfig' :: Double
minimumLength = Double
a} :: CreateBackendAuthPasswordPolicyConfig)

instance
  Core.FromJSON
    CreateBackendAuthPasswordPolicyConfig
  where
  parseJSON :: Value -> Parser CreateBackendAuthPasswordPolicyConfig
parseJSON =
    String
-> (Object -> Parser CreateBackendAuthPasswordPolicyConfig)
-> Value
-> Parser CreateBackendAuthPasswordPolicyConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CreateBackendAuthPasswordPolicyConfig"
      ( \Object
x ->
          Maybe [AdditionalConstraintsElement]
-> Double -> CreateBackendAuthPasswordPolicyConfig
CreateBackendAuthPasswordPolicyConfig'
            (Maybe [AdditionalConstraintsElement]
 -> Double -> CreateBackendAuthPasswordPolicyConfig)
-> Parser (Maybe [AdditionalConstraintsElement])
-> Parser (Double -> CreateBackendAuthPasswordPolicyConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [AdditionalConstraintsElement]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"additionalConstraints"
                            Parser (Maybe (Maybe [AdditionalConstraintsElement]))
-> Maybe [AdditionalConstraintsElement]
-> Parser (Maybe [AdditionalConstraintsElement])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AdditionalConstraintsElement]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Double -> CreateBackendAuthPasswordPolicyConfig)
-> Parser Double -> Parser CreateBackendAuthPasswordPolicyConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"minimumLength")
      )

instance
  Prelude.Hashable
    CreateBackendAuthPasswordPolicyConfig

instance
  Prelude.NFData
    CreateBackendAuthPasswordPolicyConfig

instance
  Core.ToJSON
    CreateBackendAuthPasswordPolicyConfig
  where
  toJSON :: CreateBackendAuthPasswordPolicyConfig -> Value
toJSON CreateBackendAuthPasswordPolicyConfig' {Double
Maybe [AdditionalConstraintsElement]
minimumLength :: Double
additionalConstraints :: Maybe [AdditionalConstraintsElement]
$sel:minimumLength:CreateBackendAuthPasswordPolicyConfig' :: CreateBackendAuthPasswordPolicyConfig -> Double
$sel:additionalConstraints:CreateBackendAuthPasswordPolicyConfig' :: CreateBackendAuthPasswordPolicyConfig
-> 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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"minimumLength" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
minimumLength)
          ]
      )