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

import Amazonka.CognitoIdentityProvider.Types.MessageTemplateType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration for creating a new user profile.
--
-- /See:/ 'newAdminCreateUserConfigType' smart constructor.
data AdminCreateUserConfigType = AdminCreateUserConfigType'
  { -- | Set to @True@ if only the administrator is allowed to create user
    -- profiles. Set to @False@ if users can sign themselves up via an app.
    AdminCreateUserConfigType -> Maybe Bool
allowAdminCreateUserOnly :: Prelude.Maybe Prelude.Bool,
    -- | The user account expiration limit, in days, after which the account is
    -- no longer usable. To reset the account after that time limit, you must
    -- call @AdminCreateUser@ again, specifying @\"RESEND\"@ for the
    -- @MessageAction@ parameter. The default value for this parameter is 7.
    --
    -- If you set a value for @TemporaryPasswordValidityDays@ in
    -- @PasswordPolicy@, that value will be used and
    -- @UnusedAccountValidityDays@ will be deprecated for that user pool.
    AdminCreateUserConfigType -> Maybe Natural
unusedAccountValidityDays :: Prelude.Maybe Prelude.Natural,
    -- | The message template to be used for the welcome message to new users.
    --
    -- See also
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-message-customizations.html#cognito-user-pool-settings-user-invitation-message-customization Customizing User Invitation Messages>.
    AdminCreateUserConfigType -> Maybe MessageTemplateType
inviteMessageTemplate :: Prelude.Maybe MessageTemplateType
  }
  deriving (AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool
(AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool)
-> (AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool)
-> Eq AdminCreateUserConfigType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool
$c/= :: AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool
== :: AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool
$c== :: AdminCreateUserConfigType -> AdminCreateUserConfigType -> Bool
Prelude.Eq, ReadPrec [AdminCreateUserConfigType]
ReadPrec AdminCreateUserConfigType
Int -> ReadS AdminCreateUserConfigType
ReadS [AdminCreateUserConfigType]
(Int -> ReadS AdminCreateUserConfigType)
-> ReadS [AdminCreateUserConfigType]
-> ReadPrec AdminCreateUserConfigType
-> ReadPrec [AdminCreateUserConfigType]
-> Read AdminCreateUserConfigType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AdminCreateUserConfigType]
$creadListPrec :: ReadPrec [AdminCreateUserConfigType]
readPrec :: ReadPrec AdminCreateUserConfigType
$creadPrec :: ReadPrec AdminCreateUserConfigType
readList :: ReadS [AdminCreateUserConfigType]
$creadList :: ReadS [AdminCreateUserConfigType]
readsPrec :: Int -> ReadS AdminCreateUserConfigType
$creadsPrec :: Int -> ReadS AdminCreateUserConfigType
Prelude.Read, Int -> AdminCreateUserConfigType -> ShowS
[AdminCreateUserConfigType] -> ShowS
AdminCreateUserConfigType -> String
(Int -> AdminCreateUserConfigType -> ShowS)
-> (AdminCreateUserConfigType -> String)
-> ([AdminCreateUserConfigType] -> ShowS)
-> Show AdminCreateUserConfigType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminCreateUserConfigType] -> ShowS
$cshowList :: [AdminCreateUserConfigType] -> ShowS
show :: AdminCreateUserConfigType -> String
$cshow :: AdminCreateUserConfigType -> String
showsPrec :: Int -> AdminCreateUserConfigType -> ShowS
$cshowsPrec :: Int -> AdminCreateUserConfigType -> ShowS
Prelude.Show, (forall x.
 AdminCreateUserConfigType -> Rep AdminCreateUserConfigType x)
-> (forall x.
    Rep AdminCreateUserConfigType x -> AdminCreateUserConfigType)
-> Generic AdminCreateUserConfigType
forall x.
Rep AdminCreateUserConfigType x -> AdminCreateUserConfigType
forall x.
AdminCreateUserConfigType -> Rep AdminCreateUserConfigType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AdminCreateUserConfigType x -> AdminCreateUserConfigType
$cfrom :: forall x.
AdminCreateUserConfigType -> Rep AdminCreateUserConfigType x
Prelude.Generic)

-- |
-- Create a value of 'AdminCreateUserConfigType' 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:
--
-- 'allowAdminCreateUserOnly', 'adminCreateUserConfigType_allowAdminCreateUserOnly' - Set to @True@ if only the administrator is allowed to create user
-- profiles. Set to @False@ if users can sign themselves up via an app.
--
-- 'unusedAccountValidityDays', 'adminCreateUserConfigType_unusedAccountValidityDays' - The user account expiration limit, in days, after which the account is
-- no longer usable. To reset the account after that time limit, you must
-- call @AdminCreateUser@ again, specifying @\"RESEND\"@ for the
-- @MessageAction@ parameter. The default value for this parameter is 7.
--
-- If you set a value for @TemporaryPasswordValidityDays@ in
-- @PasswordPolicy@, that value will be used and
-- @UnusedAccountValidityDays@ will be deprecated for that user pool.
--
-- 'inviteMessageTemplate', 'adminCreateUserConfigType_inviteMessageTemplate' - The message template to be used for the welcome message to new users.
--
-- See also
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-message-customizations.html#cognito-user-pool-settings-user-invitation-message-customization Customizing User Invitation Messages>.
newAdminCreateUserConfigType ::
  AdminCreateUserConfigType
newAdminCreateUserConfigType :: AdminCreateUserConfigType
newAdminCreateUserConfigType =
  AdminCreateUserConfigType' :: Maybe Bool
-> Maybe Natural
-> Maybe MessageTemplateType
-> AdminCreateUserConfigType
AdminCreateUserConfigType'
    { $sel:allowAdminCreateUserOnly:AdminCreateUserConfigType' :: Maybe Bool
allowAdminCreateUserOnly =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:unusedAccountValidityDays:AdminCreateUserConfigType' :: Maybe Natural
unusedAccountValidityDays = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:inviteMessageTemplate:AdminCreateUserConfigType' :: Maybe MessageTemplateType
inviteMessageTemplate = Maybe MessageTemplateType
forall a. Maybe a
Prelude.Nothing
    }

-- | Set to @True@ if only the administrator is allowed to create user
-- profiles. Set to @False@ if users can sign themselves up via an app.
adminCreateUserConfigType_allowAdminCreateUserOnly :: Lens.Lens' AdminCreateUserConfigType (Prelude.Maybe Prelude.Bool)
adminCreateUserConfigType_allowAdminCreateUserOnly :: (Maybe Bool -> f (Maybe Bool))
-> AdminCreateUserConfigType -> f AdminCreateUserConfigType
adminCreateUserConfigType_allowAdminCreateUserOnly = (AdminCreateUserConfigType -> Maybe Bool)
-> (AdminCreateUserConfigType
    -> Maybe Bool -> AdminCreateUserConfigType)
-> Lens
     AdminCreateUserConfigType
     AdminCreateUserConfigType
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminCreateUserConfigType' {Maybe Bool
allowAdminCreateUserOnly :: Maybe Bool
$sel:allowAdminCreateUserOnly:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe Bool
allowAdminCreateUserOnly} -> Maybe Bool
allowAdminCreateUserOnly) (\s :: AdminCreateUserConfigType
s@AdminCreateUserConfigType' {} Maybe Bool
a -> AdminCreateUserConfigType
s {$sel:allowAdminCreateUserOnly:AdminCreateUserConfigType' :: Maybe Bool
allowAdminCreateUserOnly = Maybe Bool
a} :: AdminCreateUserConfigType)

-- | The user account expiration limit, in days, after which the account is
-- no longer usable. To reset the account after that time limit, you must
-- call @AdminCreateUser@ again, specifying @\"RESEND\"@ for the
-- @MessageAction@ parameter. The default value for this parameter is 7.
--
-- If you set a value for @TemporaryPasswordValidityDays@ in
-- @PasswordPolicy@, that value will be used and
-- @UnusedAccountValidityDays@ will be deprecated for that user pool.
adminCreateUserConfigType_unusedAccountValidityDays :: Lens.Lens' AdminCreateUserConfigType (Prelude.Maybe Prelude.Natural)
adminCreateUserConfigType_unusedAccountValidityDays :: (Maybe Natural -> f (Maybe Natural))
-> AdminCreateUserConfigType -> f AdminCreateUserConfigType
adminCreateUserConfigType_unusedAccountValidityDays = (AdminCreateUserConfigType -> Maybe Natural)
-> (AdminCreateUserConfigType
    -> Maybe Natural -> AdminCreateUserConfigType)
-> Lens
     AdminCreateUserConfigType
     AdminCreateUserConfigType
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminCreateUserConfigType' {Maybe Natural
unusedAccountValidityDays :: Maybe Natural
$sel:unusedAccountValidityDays:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe Natural
unusedAccountValidityDays} -> Maybe Natural
unusedAccountValidityDays) (\s :: AdminCreateUserConfigType
s@AdminCreateUserConfigType' {} Maybe Natural
a -> AdminCreateUserConfigType
s {$sel:unusedAccountValidityDays:AdminCreateUserConfigType' :: Maybe Natural
unusedAccountValidityDays = Maybe Natural
a} :: AdminCreateUserConfigType)

-- | The message template to be used for the welcome message to new users.
--
-- See also
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-message-customizations.html#cognito-user-pool-settings-user-invitation-message-customization Customizing User Invitation Messages>.
adminCreateUserConfigType_inviteMessageTemplate :: Lens.Lens' AdminCreateUserConfigType (Prelude.Maybe MessageTemplateType)
adminCreateUserConfigType_inviteMessageTemplate :: (Maybe MessageTemplateType -> f (Maybe MessageTemplateType))
-> AdminCreateUserConfigType -> f AdminCreateUserConfigType
adminCreateUserConfigType_inviteMessageTemplate = (AdminCreateUserConfigType -> Maybe MessageTemplateType)
-> (AdminCreateUserConfigType
    -> Maybe MessageTemplateType -> AdminCreateUserConfigType)
-> Lens
     AdminCreateUserConfigType
     AdminCreateUserConfigType
     (Maybe MessageTemplateType)
     (Maybe MessageTemplateType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminCreateUserConfigType' {Maybe MessageTemplateType
inviteMessageTemplate :: Maybe MessageTemplateType
$sel:inviteMessageTemplate:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe MessageTemplateType
inviteMessageTemplate} -> Maybe MessageTemplateType
inviteMessageTemplate) (\s :: AdminCreateUserConfigType
s@AdminCreateUserConfigType' {} Maybe MessageTemplateType
a -> AdminCreateUserConfigType
s {$sel:inviteMessageTemplate:AdminCreateUserConfigType' :: Maybe MessageTemplateType
inviteMessageTemplate = Maybe MessageTemplateType
a} :: AdminCreateUserConfigType)

instance Core.FromJSON AdminCreateUserConfigType where
  parseJSON :: Value -> Parser AdminCreateUserConfigType
parseJSON =
    String
-> (Object -> Parser AdminCreateUserConfigType)
-> Value
-> Parser AdminCreateUserConfigType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AdminCreateUserConfigType"
      ( \Object
x ->
          Maybe Bool
-> Maybe Natural
-> Maybe MessageTemplateType
-> AdminCreateUserConfigType
AdminCreateUserConfigType'
            (Maybe Bool
 -> Maybe Natural
 -> Maybe MessageTemplateType
 -> AdminCreateUserConfigType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Natural
      -> Maybe MessageTemplateType -> AdminCreateUserConfigType)
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
"AllowAdminCreateUserOnly")
            Parser
  (Maybe Natural
   -> Maybe MessageTemplateType -> AdminCreateUserConfigType)
-> Parser (Maybe Natural)
-> Parser (Maybe MessageTemplateType -> AdminCreateUserConfigType)
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
"UnusedAccountValidityDays")
            Parser (Maybe MessageTemplateType -> AdminCreateUserConfigType)
-> Parser (Maybe MessageTemplateType)
-> Parser AdminCreateUserConfigType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MessageTemplateType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InviteMessageTemplate")
      )

instance Prelude.Hashable AdminCreateUserConfigType

instance Prelude.NFData AdminCreateUserConfigType

instance Core.ToJSON AdminCreateUserConfigType where
  toJSON :: AdminCreateUserConfigType -> Value
toJSON AdminCreateUserConfigType' {Maybe Bool
Maybe Natural
Maybe MessageTemplateType
inviteMessageTemplate :: Maybe MessageTemplateType
unusedAccountValidityDays :: Maybe Natural
allowAdminCreateUserOnly :: Maybe Bool
$sel:inviteMessageTemplate:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe MessageTemplateType
$sel:unusedAccountValidityDays:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe Natural
$sel:allowAdminCreateUserOnly:AdminCreateUserConfigType' :: AdminCreateUserConfigType -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AllowAdminCreateUserOnly" 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
allowAdminCreateUserOnly,
            (Text
"UnusedAccountValidityDays" 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
unusedAccountValidityDays,
            (Text
"InviteMessageTemplate" Text -> MessageTemplateType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MessageTemplateType -> Pair)
-> Maybe MessageTemplateType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MessageTemplateType
inviteMessageTemplate
          ]
      )