{-# 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.UsernameConfigurationType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.UsernameConfigurationType where

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

-- | The username configuration type.
--
-- /See:/ 'newUsernameConfigurationType' smart constructor.
data UsernameConfigurationType = UsernameConfigurationType'
  { -- | Specifies whether user name case sensitivity will be applied for all
    -- users in the user pool through Amazon Cognito APIs.
    --
    -- Valid values include:
    --
    -- [True]
    --     Enables case sensitivity for all username input. When this option is
    --     set to @True@, users must sign in using the exact capitalization of
    --     their given username, such as “UserName”. This is the default value.
    --
    -- [False]
    --     Enables case insensitivity for all username input. For example, when
    --     this option is set to @False@, users can sign in using either
    --     \"username\" or \"Username\". This option also enables both
    --     @preferred_username@ and @email@ alias to be case insensitive, in
    --     addition to the @username@ attribute.
    UsernameConfigurationType -> Bool
caseSensitive :: Prelude.Bool
  }
  deriving (UsernameConfigurationType -> UsernameConfigurationType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsernameConfigurationType -> UsernameConfigurationType -> Bool
$c/= :: UsernameConfigurationType -> UsernameConfigurationType -> Bool
== :: UsernameConfigurationType -> UsernameConfigurationType -> Bool
$c== :: UsernameConfigurationType -> UsernameConfigurationType -> Bool
Prelude.Eq, ReadPrec [UsernameConfigurationType]
ReadPrec UsernameConfigurationType
Int -> ReadS UsernameConfigurationType
ReadS [UsernameConfigurationType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsernameConfigurationType]
$creadListPrec :: ReadPrec [UsernameConfigurationType]
readPrec :: ReadPrec UsernameConfigurationType
$creadPrec :: ReadPrec UsernameConfigurationType
readList :: ReadS [UsernameConfigurationType]
$creadList :: ReadS [UsernameConfigurationType]
readsPrec :: Int -> ReadS UsernameConfigurationType
$creadsPrec :: Int -> ReadS UsernameConfigurationType
Prelude.Read, Int -> UsernameConfigurationType -> ShowS
[UsernameConfigurationType] -> ShowS
UsernameConfigurationType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsernameConfigurationType] -> ShowS
$cshowList :: [UsernameConfigurationType] -> ShowS
show :: UsernameConfigurationType -> String
$cshow :: UsernameConfigurationType -> String
showsPrec :: Int -> UsernameConfigurationType -> ShowS
$cshowsPrec :: Int -> UsernameConfigurationType -> ShowS
Prelude.Show, forall x.
Rep UsernameConfigurationType x -> UsernameConfigurationType
forall x.
UsernameConfigurationType -> Rep UsernameConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UsernameConfigurationType x -> UsernameConfigurationType
$cfrom :: forall x.
UsernameConfigurationType -> Rep UsernameConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'UsernameConfigurationType' 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:
--
-- 'caseSensitive', 'usernameConfigurationType_caseSensitive' - Specifies whether user name case sensitivity will be applied for all
-- users in the user pool through Amazon Cognito APIs.
--
-- Valid values include:
--
-- [True]
--     Enables case sensitivity for all username input. When this option is
--     set to @True@, users must sign in using the exact capitalization of
--     their given username, such as “UserName”. This is the default value.
--
-- [False]
--     Enables case insensitivity for all username input. For example, when
--     this option is set to @False@, users can sign in using either
--     \"username\" or \"Username\". This option also enables both
--     @preferred_username@ and @email@ alias to be case insensitive, in
--     addition to the @username@ attribute.
newUsernameConfigurationType ::
  -- | 'caseSensitive'
  Prelude.Bool ->
  UsernameConfigurationType
newUsernameConfigurationType :: Bool -> UsernameConfigurationType
newUsernameConfigurationType Bool
pCaseSensitive_ =
  UsernameConfigurationType'
    { $sel:caseSensitive:UsernameConfigurationType' :: Bool
caseSensitive =
        Bool
pCaseSensitive_
    }

-- | Specifies whether user name case sensitivity will be applied for all
-- users in the user pool through Amazon Cognito APIs.
--
-- Valid values include:
--
-- [True]
--     Enables case sensitivity for all username input. When this option is
--     set to @True@, users must sign in using the exact capitalization of
--     their given username, such as “UserName”. This is the default value.
--
-- [False]
--     Enables case insensitivity for all username input. For example, when
--     this option is set to @False@, users can sign in using either
--     \"username\" or \"Username\". This option also enables both
--     @preferred_username@ and @email@ alias to be case insensitive, in
--     addition to the @username@ attribute.
usernameConfigurationType_caseSensitive :: Lens.Lens' UsernameConfigurationType Prelude.Bool
usernameConfigurationType_caseSensitive :: Lens' UsernameConfigurationType Bool
usernameConfigurationType_caseSensitive = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsernameConfigurationType' {Bool
caseSensitive :: Bool
$sel:caseSensitive:UsernameConfigurationType' :: UsernameConfigurationType -> Bool
caseSensitive} -> Bool
caseSensitive) (\s :: UsernameConfigurationType
s@UsernameConfigurationType' {} Bool
a -> UsernameConfigurationType
s {$sel:caseSensitive:UsernameConfigurationType' :: Bool
caseSensitive = Bool
a} :: UsernameConfigurationType)

instance Data.FromJSON UsernameConfigurationType where
  parseJSON :: Value -> Parser UsernameConfigurationType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UsernameConfigurationType"
      ( \Object
x ->
          Bool -> UsernameConfigurationType
UsernameConfigurationType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CaseSensitive")
      )

instance Prelude.Hashable UsernameConfigurationType where
  hashWithSalt :: Int -> UsernameConfigurationType -> Int
hashWithSalt Int
_salt UsernameConfigurationType' {Bool
caseSensitive :: Bool
$sel:caseSensitive:UsernameConfigurationType' :: UsernameConfigurationType -> Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
caseSensitive

instance Prelude.NFData UsernameConfigurationType where
  rnf :: UsernameConfigurationType -> ()
rnf UsernameConfigurationType' {Bool
caseSensitive :: Bool
$sel:caseSensitive:UsernameConfigurationType' :: UsernameConfigurationType -> Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Bool
caseSensitive

instance Data.ToJSON UsernameConfigurationType where
  toJSON :: UsernameConfigurationType -> Value
toJSON UsernameConfigurationType' {Bool
caseSensitive :: Bool
$sel:caseSensitive:UsernameConfigurationType' :: UsernameConfigurationType -> Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"CaseSensitive" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
caseSensitive)
          ]
      )