{-# 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.ImmunityTimeProperty
-- 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.ImmunityTimeProperty 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

-- | Used for CAPTCHA and challenge token settings. Determines how long a
-- @CAPTCHA@ or challenge timestamp remains valid after WAF updates it for
-- a successful @CAPTCHA@ or challenge response.
--
-- /See:/ 'newImmunityTimeProperty' smart constructor.
data ImmunityTimeProperty = ImmunityTimeProperty'
  { -- | The amount of time, in seconds, that a @CAPTCHA@ or challenge timestamp
    -- is considered valid by WAF. The default setting is 300.
    --
    -- For the Challenge action, the minimum setting is 300.
    ImmunityTimeProperty -> Natural
immunityTime :: Prelude.Natural
  }
  deriving (ImmunityTimeProperty -> ImmunityTimeProperty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImmunityTimeProperty -> ImmunityTimeProperty -> Bool
$c/= :: ImmunityTimeProperty -> ImmunityTimeProperty -> Bool
== :: ImmunityTimeProperty -> ImmunityTimeProperty -> Bool
$c== :: ImmunityTimeProperty -> ImmunityTimeProperty -> Bool
Prelude.Eq, ReadPrec [ImmunityTimeProperty]
ReadPrec ImmunityTimeProperty
Int -> ReadS ImmunityTimeProperty
ReadS [ImmunityTimeProperty]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImmunityTimeProperty]
$creadListPrec :: ReadPrec [ImmunityTimeProperty]
readPrec :: ReadPrec ImmunityTimeProperty
$creadPrec :: ReadPrec ImmunityTimeProperty
readList :: ReadS [ImmunityTimeProperty]
$creadList :: ReadS [ImmunityTimeProperty]
readsPrec :: Int -> ReadS ImmunityTimeProperty
$creadsPrec :: Int -> ReadS ImmunityTimeProperty
Prelude.Read, Int -> ImmunityTimeProperty -> ShowS
[ImmunityTimeProperty] -> ShowS
ImmunityTimeProperty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImmunityTimeProperty] -> ShowS
$cshowList :: [ImmunityTimeProperty] -> ShowS
show :: ImmunityTimeProperty -> String
$cshow :: ImmunityTimeProperty -> String
showsPrec :: Int -> ImmunityTimeProperty -> ShowS
$cshowsPrec :: Int -> ImmunityTimeProperty -> ShowS
Prelude.Show, forall x. Rep ImmunityTimeProperty x -> ImmunityTimeProperty
forall x. ImmunityTimeProperty -> Rep ImmunityTimeProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImmunityTimeProperty x -> ImmunityTimeProperty
$cfrom :: forall x. ImmunityTimeProperty -> Rep ImmunityTimeProperty x
Prelude.Generic)

-- |
-- Create a value of 'ImmunityTimeProperty' 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:
--
-- 'immunityTime', 'immunityTimeProperty_immunityTime' - The amount of time, in seconds, that a @CAPTCHA@ or challenge timestamp
-- is considered valid by WAF. The default setting is 300.
--
-- For the Challenge action, the minimum setting is 300.
newImmunityTimeProperty ::
  -- | 'immunityTime'
  Prelude.Natural ->
  ImmunityTimeProperty
newImmunityTimeProperty :: Natural -> ImmunityTimeProperty
newImmunityTimeProperty Natural
pImmunityTime_ =
  ImmunityTimeProperty'
    { $sel:immunityTime:ImmunityTimeProperty' :: Natural
immunityTime =
        Natural
pImmunityTime_
    }

-- | The amount of time, in seconds, that a @CAPTCHA@ or challenge timestamp
-- is considered valid by WAF. The default setting is 300.
--
-- For the Challenge action, the minimum setting is 300.
immunityTimeProperty_immunityTime :: Lens.Lens' ImmunityTimeProperty Prelude.Natural
immunityTimeProperty_immunityTime :: Lens' ImmunityTimeProperty Natural
immunityTimeProperty_immunityTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImmunityTimeProperty' {Natural
immunityTime :: Natural
$sel:immunityTime:ImmunityTimeProperty' :: ImmunityTimeProperty -> Natural
immunityTime} -> Natural
immunityTime) (\s :: ImmunityTimeProperty
s@ImmunityTimeProperty' {} Natural
a -> ImmunityTimeProperty
s {$sel:immunityTime:ImmunityTimeProperty' :: Natural
immunityTime = Natural
a} :: ImmunityTimeProperty)

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

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

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

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