{-# 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.WAFV2.Types.UsernameField
-- 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.WAFV2.Types.UsernameField 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

-- | Details about your login page username field, used in a
-- @ManagedRuleGroupConfig@.
--
-- /See:/ 'newUsernameField' smart constructor.
data UsernameField = UsernameField'
  { -- | The name of the username field. For example @\/form\/username@.
    UsernameField -> Text
identifier :: Prelude.Text
  }
  deriving (UsernameField -> UsernameField -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsernameField -> UsernameField -> Bool
$c/= :: UsernameField -> UsernameField -> Bool
== :: UsernameField -> UsernameField -> Bool
$c== :: UsernameField -> UsernameField -> Bool
Prelude.Eq, ReadPrec [UsernameField]
ReadPrec UsernameField
Int -> ReadS UsernameField
ReadS [UsernameField]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsernameField]
$creadListPrec :: ReadPrec [UsernameField]
readPrec :: ReadPrec UsernameField
$creadPrec :: ReadPrec UsernameField
readList :: ReadS [UsernameField]
$creadList :: ReadS [UsernameField]
readsPrec :: Int -> ReadS UsernameField
$creadsPrec :: Int -> ReadS UsernameField
Prelude.Read, Int -> UsernameField -> ShowS
[UsernameField] -> ShowS
UsernameField -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsernameField] -> ShowS
$cshowList :: [UsernameField] -> ShowS
show :: UsernameField -> String
$cshow :: UsernameField -> String
showsPrec :: Int -> UsernameField -> ShowS
$cshowsPrec :: Int -> UsernameField -> ShowS
Prelude.Show, forall x. Rep UsernameField x -> UsernameField
forall x. UsernameField -> Rep UsernameField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsernameField x -> UsernameField
$cfrom :: forall x. UsernameField -> Rep UsernameField x
Prelude.Generic)

-- |
-- Create a value of 'UsernameField' 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:
--
-- 'identifier', 'usernameField_identifier' - The name of the username field. For example @\/form\/username@.
newUsernameField ::
  -- | 'identifier'
  Prelude.Text ->
  UsernameField
newUsernameField :: Text -> UsernameField
newUsernameField Text
pIdentifier_ =
  UsernameField' {$sel:identifier:UsernameField' :: Text
identifier = Text
pIdentifier_}

-- | The name of the username field. For example @\/form\/username@.
usernameField_identifier :: Lens.Lens' UsernameField Prelude.Text
usernameField_identifier :: Lens' UsernameField Text
usernameField_identifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsernameField' {Text
identifier :: Text
$sel:identifier:UsernameField' :: UsernameField -> Text
identifier} -> Text
identifier) (\s :: UsernameField
s@UsernameField' {} Text
a -> UsernameField
s {$sel:identifier:UsernameField' :: Text
identifier = Text
a} :: UsernameField)

instance Data.FromJSON UsernameField where
  parseJSON :: Value -> Parser UsernameField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UsernameField"
      ( \Object
x ->
          Text -> UsernameField
UsernameField' 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
"Identifier")
      )

instance Prelude.Hashable UsernameField where
  hashWithSalt :: Int -> UsernameField -> Int
hashWithSalt Int
_salt UsernameField' {Text
identifier :: Text
$sel:identifier:UsernameField' :: UsernameField -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identifier

instance Prelude.NFData UsernameField where
  rnf :: UsernameField -> ()
rnf UsernameField' {Text
identifier :: Text
$sel:identifier:UsernameField' :: UsernameField -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
identifier

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