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

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

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

instance Data.FromJSON PasswordField where
  parseJSON :: Value -> Parser PasswordField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PasswordField"
      ( \Object
x ->
          Text -> PasswordField
PasswordField' 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 PasswordField where
  hashWithSalt :: Int -> PasswordField -> Int
hashWithSalt Int
_salt PasswordField' {Text
identifier :: Text
$sel:identifier:PasswordField' :: PasswordField -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identifier

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

instance Data.ToJSON PasswordField where
  toJSON :: PasswordField -> Value
toJSON PasswordField' {Text
identifier :: Text
$sel:identifier:PasswordField' :: PasswordField -> 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)]
      )