{-# 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.CaptchaConfig
-- 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.CaptchaConfig 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
import Amazonka.WAFV2.Types.ImmunityTimeProperty

-- | Specifies how WAF should handle @CAPTCHA@ evaluations. This is available
-- at the web ACL level and in each rule.
--
-- /See:/ 'newCaptchaConfig' smart constructor.
data CaptchaConfig = CaptchaConfig'
  { -- | Determines how long a @CAPTCHA@ timestamp in the token remains valid
    -- after the client successfully solves a @CAPTCHA@ puzzle.
    CaptchaConfig -> Maybe ImmunityTimeProperty
immunityTimeProperty :: Prelude.Maybe ImmunityTimeProperty
  }
  deriving (CaptchaConfig -> CaptchaConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptchaConfig -> CaptchaConfig -> Bool
$c/= :: CaptchaConfig -> CaptchaConfig -> Bool
== :: CaptchaConfig -> CaptchaConfig -> Bool
$c== :: CaptchaConfig -> CaptchaConfig -> Bool
Prelude.Eq, ReadPrec [CaptchaConfig]
ReadPrec CaptchaConfig
Int -> ReadS CaptchaConfig
ReadS [CaptchaConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptchaConfig]
$creadListPrec :: ReadPrec [CaptchaConfig]
readPrec :: ReadPrec CaptchaConfig
$creadPrec :: ReadPrec CaptchaConfig
readList :: ReadS [CaptchaConfig]
$creadList :: ReadS [CaptchaConfig]
readsPrec :: Int -> ReadS CaptchaConfig
$creadsPrec :: Int -> ReadS CaptchaConfig
Prelude.Read, Int -> CaptchaConfig -> ShowS
[CaptchaConfig] -> ShowS
CaptchaConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptchaConfig] -> ShowS
$cshowList :: [CaptchaConfig] -> ShowS
show :: CaptchaConfig -> String
$cshow :: CaptchaConfig -> String
showsPrec :: Int -> CaptchaConfig -> ShowS
$cshowsPrec :: Int -> CaptchaConfig -> ShowS
Prelude.Show, forall x. Rep CaptchaConfig x -> CaptchaConfig
forall x. CaptchaConfig -> Rep CaptchaConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptchaConfig x -> CaptchaConfig
$cfrom :: forall x. CaptchaConfig -> Rep CaptchaConfig x
Prelude.Generic)

-- |
-- Create a value of 'CaptchaConfig' 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:
--
-- 'immunityTimeProperty', 'captchaConfig_immunityTimeProperty' - Determines how long a @CAPTCHA@ timestamp in the token remains valid
-- after the client successfully solves a @CAPTCHA@ puzzle.
newCaptchaConfig ::
  CaptchaConfig
newCaptchaConfig :: CaptchaConfig
newCaptchaConfig =
  CaptchaConfig'
    { $sel:immunityTimeProperty:CaptchaConfig' :: Maybe ImmunityTimeProperty
immunityTimeProperty =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Determines how long a @CAPTCHA@ timestamp in the token remains valid
-- after the client successfully solves a @CAPTCHA@ puzzle.
captchaConfig_immunityTimeProperty :: Lens.Lens' CaptchaConfig (Prelude.Maybe ImmunityTimeProperty)
captchaConfig_immunityTimeProperty :: Lens' CaptchaConfig (Maybe ImmunityTimeProperty)
captchaConfig_immunityTimeProperty = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptchaConfig' {Maybe ImmunityTimeProperty
immunityTimeProperty :: Maybe ImmunityTimeProperty
$sel:immunityTimeProperty:CaptchaConfig' :: CaptchaConfig -> Maybe ImmunityTimeProperty
immunityTimeProperty} -> Maybe ImmunityTimeProperty
immunityTimeProperty) (\s :: CaptchaConfig
s@CaptchaConfig' {} Maybe ImmunityTimeProperty
a -> CaptchaConfig
s {$sel:immunityTimeProperty:CaptchaConfig' :: Maybe ImmunityTimeProperty
immunityTimeProperty = Maybe ImmunityTimeProperty
a} :: CaptchaConfig)

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

instance Prelude.Hashable CaptchaConfig where
  hashWithSalt :: Int -> CaptchaConfig -> Int
hashWithSalt Int
_salt CaptchaConfig' {Maybe ImmunityTimeProperty
immunityTimeProperty :: Maybe ImmunityTimeProperty
$sel:immunityTimeProperty:CaptchaConfig' :: CaptchaConfig -> Maybe ImmunityTimeProperty
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ImmunityTimeProperty
immunityTimeProperty

instance Prelude.NFData CaptchaConfig where
  rnf :: CaptchaConfig -> ()
rnf CaptchaConfig' {Maybe ImmunityTimeProperty
immunityTimeProperty :: Maybe ImmunityTimeProperty
$sel:immunityTimeProperty:CaptchaConfig' :: CaptchaConfig -> Maybe ImmunityTimeProperty
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ImmunityTimeProperty
immunityTimeProperty

instance Data.ToJSON CaptchaConfig where
  toJSON :: CaptchaConfig -> Value
toJSON CaptchaConfig' {Maybe ImmunityTimeProperty
immunityTimeProperty :: Maybe ImmunityTimeProperty
$sel:immunityTimeProperty:CaptchaConfig' :: CaptchaConfig -> Maybe ImmunityTimeProperty
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ImmunityTimeProperty" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ImmunityTimeProperty
immunityTimeProperty
          ]
      )