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

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

-- | The username configuration type.
--
-- /See:/ 'newUsernameConfigurationType' smart constructor.
data UsernameConfigurationType = UsernameConfigurationType'
  { -- | Specifies whether username case sensitivity will be applied for all
    -- users in the user pool through 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. For example, “UserName”.
    --     This is the default value.
    --
    -- -   __@False@__ : Enables case insensitivity for all username input. For
    --     example, when this option is set to @False@, users will be able to
    --     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
(UsernameConfigurationType -> UsernameConfigurationType -> Bool)
-> (UsernameConfigurationType -> UsernameConfigurationType -> Bool)
-> Eq UsernameConfigurationType
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]
(Int -> ReadS UsernameConfigurationType)
-> ReadS [UsernameConfigurationType]
-> ReadPrec UsernameConfigurationType
-> ReadPrec [UsernameConfigurationType]
-> Read 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
(Int -> UsernameConfigurationType -> ShowS)
-> (UsernameConfigurationType -> String)
-> ([UsernameConfigurationType] -> ShowS)
-> Show UsernameConfigurationType
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.
 UsernameConfigurationType -> Rep UsernameConfigurationType x)
-> (forall x.
    Rep UsernameConfigurationType x -> UsernameConfigurationType)
-> Generic UsernameConfigurationType
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 username case sensitivity will be applied for all
-- users in the user pool through 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. For example, “UserName”.
--     This is the default value.
--
-- -   __@False@__ : Enables case insensitivity for all username input. For
--     example, when this option is set to @False@, users will be able to
--     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' :: Bool -> UsernameConfigurationType
UsernameConfigurationType'
    { $sel:caseSensitive:UsernameConfigurationType' :: Bool
caseSensitive =
        Bool
pCaseSensitive_
    }

-- | Specifies whether username case sensitivity will be applied for all
-- users in the user pool through 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. For example, “UserName”.
--     This is the default value.
--
-- -   __@False@__ : Enables case insensitivity for all username input. For
--     example, when this option is set to @False@, users will be able to
--     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 :: (Bool -> f Bool)
-> UsernameConfigurationType -> f UsernameConfigurationType
usernameConfigurationType_caseSensitive = (UsernameConfigurationType -> Bool)
-> (UsernameConfigurationType -> Bool -> UsernameConfigurationType)
-> Lens
     UsernameConfigurationType UsernameConfigurationType Bool Bool
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 Core.FromJSON UsernameConfigurationType where
  parseJSON :: Value -> Parser UsernameConfigurationType
parseJSON =
    String
-> (Object -> Parser UsernameConfigurationType)
-> Value
-> Parser UsernameConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UsernameConfigurationType"
      ( \Object
x ->
          Bool -> UsernameConfigurationType
UsernameConfigurationType'
            (Bool -> UsernameConfigurationType)
-> Parser Bool -> Parser UsernameConfigurationType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CaseSensitive")
      )

instance Prelude.Hashable UsernameConfigurationType

instance Prelude.NFData UsernameConfigurationType

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