{-# 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.SecurityHub.Types.AwsWafRateBasedRuleDetails
-- 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.SecurityHub.Types.AwsWafRateBasedRuleDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsWafRateBasedRuleMatchPredicate

-- | Details about a rate-based rule for global resources. A rate-based rule
-- provides settings to indicate when to allow, block, or count a request.
-- Rate-based rules include the number of requests that arrive over a
-- specified period of time.
--
-- /See:/ 'newAwsWafRateBasedRuleDetails' smart constructor.
data AwsWafRateBasedRuleDetails = AwsWafRateBasedRuleDetails'
  { -- | The maximum number of requests that have an identical value for the
    -- field specified in @RateKey@ that are allowed within a five-minute
    -- period. If the number of requests exceeds @RateLimit@ and the other
    -- predicates specified in the rule are met, WAF triggers the action for
    -- the rule.
    AwsWafRateBasedRuleDetails -> Maybe Integer
rateLimit :: Prelude.Maybe Prelude.Integer,
    -- | The field that WAF uses to determine whether requests are likely
    -- arriving from single source and are subject to rate monitoring.
    AwsWafRateBasedRuleDetails -> Maybe Text
rateKey :: Prelude.Maybe Prelude.Text,
    -- | The name of the metrics for the rate-based rule.
    AwsWafRateBasedRuleDetails -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the rate-based rule.
    AwsWafRateBasedRuleDetails -> Maybe Text
ruleId :: Prelude.Maybe Prelude.Text,
    -- | The name of the rate-based rule.
    AwsWafRateBasedRuleDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The predicates to include in the rate-based rule.
    AwsWafRateBasedRuleDetails
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates :: Prelude.Maybe [AwsWafRateBasedRuleMatchPredicate]
  }
  deriving (AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool
(AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool)
-> (AwsWafRateBasedRuleDetails
    -> AwsWafRateBasedRuleDetails -> Bool)
-> Eq AwsWafRateBasedRuleDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool
$c/= :: AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool
== :: AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool
$c== :: AwsWafRateBasedRuleDetails -> AwsWafRateBasedRuleDetails -> Bool
Prelude.Eq, ReadPrec [AwsWafRateBasedRuleDetails]
ReadPrec AwsWafRateBasedRuleDetails
Int -> ReadS AwsWafRateBasedRuleDetails
ReadS [AwsWafRateBasedRuleDetails]
(Int -> ReadS AwsWafRateBasedRuleDetails)
-> ReadS [AwsWafRateBasedRuleDetails]
-> ReadPrec AwsWafRateBasedRuleDetails
-> ReadPrec [AwsWafRateBasedRuleDetails]
-> Read AwsWafRateBasedRuleDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsWafRateBasedRuleDetails]
$creadListPrec :: ReadPrec [AwsWafRateBasedRuleDetails]
readPrec :: ReadPrec AwsWafRateBasedRuleDetails
$creadPrec :: ReadPrec AwsWafRateBasedRuleDetails
readList :: ReadS [AwsWafRateBasedRuleDetails]
$creadList :: ReadS [AwsWafRateBasedRuleDetails]
readsPrec :: Int -> ReadS AwsWafRateBasedRuleDetails
$creadsPrec :: Int -> ReadS AwsWafRateBasedRuleDetails
Prelude.Read, Int -> AwsWafRateBasedRuleDetails -> ShowS
[AwsWafRateBasedRuleDetails] -> ShowS
AwsWafRateBasedRuleDetails -> String
(Int -> AwsWafRateBasedRuleDetails -> ShowS)
-> (AwsWafRateBasedRuleDetails -> String)
-> ([AwsWafRateBasedRuleDetails] -> ShowS)
-> Show AwsWafRateBasedRuleDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsWafRateBasedRuleDetails] -> ShowS
$cshowList :: [AwsWafRateBasedRuleDetails] -> ShowS
show :: AwsWafRateBasedRuleDetails -> String
$cshow :: AwsWafRateBasedRuleDetails -> String
showsPrec :: Int -> AwsWafRateBasedRuleDetails -> ShowS
$cshowsPrec :: Int -> AwsWafRateBasedRuleDetails -> ShowS
Prelude.Show, (forall x.
 AwsWafRateBasedRuleDetails -> Rep AwsWafRateBasedRuleDetails x)
-> (forall x.
    Rep AwsWafRateBasedRuleDetails x -> AwsWafRateBasedRuleDetails)
-> Generic AwsWafRateBasedRuleDetails
forall x.
Rep AwsWafRateBasedRuleDetails x -> AwsWafRateBasedRuleDetails
forall x.
AwsWafRateBasedRuleDetails -> Rep AwsWafRateBasedRuleDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsWafRateBasedRuleDetails x -> AwsWafRateBasedRuleDetails
$cfrom :: forall x.
AwsWafRateBasedRuleDetails -> Rep AwsWafRateBasedRuleDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsWafRateBasedRuleDetails' 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:
--
-- 'rateLimit', 'awsWafRateBasedRuleDetails_rateLimit' - The maximum number of requests that have an identical value for the
-- field specified in @RateKey@ that are allowed within a five-minute
-- period. If the number of requests exceeds @RateLimit@ and the other
-- predicates specified in the rule are met, WAF triggers the action for
-- the rule.
--
-- 'rateKey', 'awsWafRateBasedRuleDetails_rateKey' - The field that WAF uses to determine whether requests are likely
-- arriving from single source and are subject to rate monitoring.
--
-- 'metricName', 'awsWafRateBasedRuleDetails_metricName' - The name of the metrics for the rate-based rule.
--
-- 'ruleId', 'awsWafRateBasedRuleDetails_ruleId' - The unique identifier for the rate-based rule.
--
-- 'name', 'awsWafRateBasedRuleDetails_name' - The name of the rate-based rule.
--
-- 'matchPredicates', 'awsWafRateBasedRuleDetails_matchPredicates' - The predicates to include in the rate-based rule.
newAwsWafRateBasedRuleDetails ::
  AwsWafRateBasedRuleDetails
newAwsWafRateBasedRuleDetails :: AwsWafRateBasedRuleDetails
newAwsWafRateBasedRuleDetails =
  AwsWafRateBasedRuleDetails' :: Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
-> AwsWafRateBasedRuleDetails
AwsWafRateBasedRuleDetails'
    { $sel:rateLimit:AwsWafRateBasedRuleDetails' :: Maybe Integer
rateLimit =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:rateKey:AwsWafRateBasedRuleDetails' :: Maybe Text
rateKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:AwsWafRateBasedRuleDetails' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleId:AwsWafRateBasedRuleDetails' :: Maybe Text
ruleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AwsWafRateBasedRuleDetails' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:matchPredicates:AwsWafRateBasedRuleDetails' :: Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates = Maybe [AwsWafRateBasedRuleMatchPredicate]
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of requests that have an identical value for the
-- field specified in @RateKey@ that are allowed within a five-minute
-- period. If the number of requests exceeds @RateLimit@ and the other
-- predicates specified in the rule are met, WAF triggers the action for
-- the rule.
awsWafRateBasedRuleDetails_rateLimit :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe Prelude.Integer)
awsWafRateBasedRuleDetails_rateLimit :: (Maybe Integer -> f (Maybe Integer))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_rateLimit = (AwsWafRateBasedRuleDetails -> Maybe Integer)
-> (AwsWafRateBasedRuleDetails
    -> Maybe Integer -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe Integer
rateLimit :: Maybe Integer
$sel:rateLimit:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Integer
rateLimit} -> Maybe Integer
rateLimit) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe Integer
a -> AwsWafRateBasedRuleDetails
s {$sel:rateLimit:AwsWafRateBasedRuleDetails' :: Maybe Integer
rateLimit = Maybe Integer
a} :: AwsWafRateBasedRuleDetails)

-- | The field that WAF uses to determine whether requests are likely
-- arriving from single source and are subject to rate monitoring.
awsWafRateBasedRuleDetails_rateKey :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe Prelude.Text)
awsWafRateBasedRuleDetails_rateKey :: (Maybe Text -> f (Maybe Text))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_rateKey = (AwsWafRateBasedRuleDetails -> Maybe Text)
-> (AwsWafRateBasedRuleDetails
    -> Maybe Text -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe Text
rateKey :: Maybe Text
$sel:rateKey:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
rateKey} -> Maybe Text
rateKey) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe Text
a -> AwsWafRateBasedRuleDetails
s {$sel:rateKey:AwsWafRateBasedRuleDetails' :: Maybe Text
rateKey = Maybe Text
a} :: AwsWafRateBasedRuleDetails)

-- | The name of the metrics for the rate-based rule.
awsWafRateBasedRuleDetails_metricName :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe Prelude.Text)
awsWafRateBasedRuleDetails_metricName :: (Maybe Text -> f (Maybe Text))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_metricName = (AwsWafRateBasedRuleDetails -> Maybe Text)
-> (AwsWafRateBasedRuleDetails
    -> Maybe Text -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe Text
metricName :: Maybe Text
$sel:metricName:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe Text
a -> AwsWafRateBasedRuleDetails
s {$sel:metricName:AwsWafRateBasedRuleDetails' :: Maybe Text
metricName = Maybe Text
a} :: AwsWafRateBasedRuleDetails)

-- | The unique identifier for the rate-based rule.
awsWafRateBasedRuleDetails_ruleId :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe Prelude.Text)
awsWafRateBasedRuleDetails_ruleId :: (Maybe Text -> f (Maybe Text))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_ruleId = (AwsWafRateBasedRuleDetails -> Maybe Text)
-> (AwsWafRateBasedRuleDetails
    -> Maybe Text -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe Text
ruleId :: Maybe Text
$sel:ruleId:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
ruleId} -> Maybe Text
ruleId) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe Text
a -> AwsWafRateBasedRuleDetails
s {$sel:ruleId:AwsWafRateBasedRuleDetails' :: Maybe Text
ruleId = Maybe Text
a} :: AwsWafRateBasedRuleDetails)

-- | The name of the rate-based rule.
awsWafRateBasedRuleDetails_name :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe Prelude.Text)
awsWafRateBasedRuleDetails_name :: (Maybe Text -> f (Maybe Text))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_name = (AwsWafRateBasedRuleDetails -> Maybe Text)
-> (AwsWafRateBasedRuleDetails
    -> Maybe Text -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe Text
name :: Maybe Text
$sel:name:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
name} -> Maybe Text
name) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe Text
a -> AwsWafRateBasedRuleDetails
s {$sel:name:AwsWafRateBasedRuleDetails' :: Maybe Text
name = Maybe Text
a} :: AwsWafRateBasedRuleDetails)

-- | The predicates to include in the rate-based rule.
awsWafRateBasedRuleDetails_matchPredicates :: Lens.Lens' AwsWafRateBasedRuleDetails (Prelude.Maybe [AwsWafRateBasedRuleMatchPredicate])
awsWafRateBasedRuleDetails_matchPredicates :: (Maybe [AwsWafRateBasedRuleMatchPredicate]
 -> f (Maybe [AwsWafRateBasedRuleMatchPredicate]))
-> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails
awsWafRateBasedRuleDetails_matchPredicates = (AwsWafRateBasedRuleDetails
 -> Maybe [AwsWafRateBasedRuleMatchPredicate])
-> (AwsWafRateBasedRuleDetails
    -> Maybe [AwsWafRateBasedRuleMatchPredicate]
    -> AwsWafRateBasedRuleDetails)
-> Lens
     AwsWafRateBasedRuleDetails
     AwsWafRateBasedRuleDetails
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleDetails' {Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates :: Maybe [AwsWafRateBasedRuleMatchPredicate]
$sel:matchPredicates:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates} -> Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates) (\s :: AwsWafRateBasedRuleDetails
s@AwsWafRateBasedRuleDetails' {} Maybe [AwsWafRateBasedRuleMatchPredicate]
a -> AwsWafRateBasedRuleDetails
s {$sel:matchPredicates:AwsWafRateBasedRuleDetails' :: Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates = Maybe [AwsWafRateBasedRuleMatchPredicate]
a} :: AwsWafRateBasedRuleDetails) ((Maybe [AwsWafRateBasedRuleMatchPredicate]
  -> f (Maybe [AwsWafRateBasedRuleMatchPredicate]))
 -> AwsWafRateBasedRuleDetails -> f AwsWafRateBasedRuleDetails)
-> ((Maybe [AwsWafRateBasedRuleMatchPredicate]
     -> f (Maybe [AwsWafRateBasedRuleMatchPredicate]))
    -> Maybe [AwsWafRateBasedRuleMatchPredicate]
    -> f (Maybe [AwsWafRateBasedRuleMatchPredicate]))
-> (Maybe [AwsWafRateBasedRuleMatchPredicate]
    -> f (Maybe [AwsWafRateBasedRuleMatchPredicate]))
-> AwsWafRateBasedRuleDetails
-> f AwsWafRateBasedRuleDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
-> Iso
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
     (Maybe [AwsWafRateBasedRuleMatchPredicate])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
  [AwsWafRateBasedRuleMatchPredicate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AwsWafRateBasedRuleDetails where
  parseJSON :: Value -> Parser AwsWafRateBasedRuleDetails
parseJSON =
    String
-> (Object -> Parser AwsWafRateBasedRuleDetails)
-> Value
-> Parser AwsWafRateBasedRuleDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsWafRateBasedRuleDetails"
      ( \Object
x ->
          Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
-> AwsWafRateBasedRuleDetails
AwsWafRateBasedRuleDetails'
            (Maybe Integer
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [AwsWafRateBasedRuleMatchPredicate]
 -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [AwsWafRateBasedRuleMatchPredicate]
      -> AwsWafRateBasedRuleDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RateLimit")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [AwsWafRateBasedRuleMatchPredicate]
   -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [AwsWafRateBasedRuleMatchPredicate]
      -> AwsWafRateBasedRuleDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RateKey")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [AwsWafRateBasedRuleMatchPredicate]
   -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [AwsWafRateBasedRuleMatchPredicate]
      -> AwsWafRateBasedRuleDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricName")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [AwsWafRateBasedRuleMatchPredicate]
   -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [AwsWafRateBasedRuleMatchPredicate]
      -> AwsWafRateBasedRuleDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleId")
            Parser
  (Maybe Text
   -> Maybe [AwsWafRateBasedRuleMatchPredicate]
   -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe [AwsWafRateBasedRuleMatchPredicate]
      -> AwsWafRateBasedRuleDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser
  (Maybe [AwsWafRateBasedRuleMatchPredicate]
   -> AwsWafRateBasedRuleDetails)
-> Parser (Maybe [AwsWafRateBasedRuleMatchPredicate])
-> Parser AwsWafRateBasedRuleDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Parser (Maybe (Maybe [AwsWafRateBasedRuleMatchPredicate]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchPredicates"
                            Parser (Maybe (Maybe [AwsWafRateBasedRuleMatchPredicate]))
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
-> Parser (Maybe [AwsWafRateBasedRuleMatchPredicate])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsWafRateBasedRuleMatchPredicate]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable AwsWafRateBasedRuleDetails

instance Prelude.NFData AwsWafRateBasedRuleDetails

instance Core.ToJSON AwsWafRateBasedRuleDetails where
  toJSON :: AwsWafRateBasedRuleDetails -> Value
toJSON AwsWafRateBasedRuleDetails' {Maybe Integer
Maybe [AwsWafRateBasedRuleMatchPredicate]
Maybe Text
matchPredicates :: Maybe [AwsWafRateBasedRuleMatchPredicate]
name :: Maybe Text
ruleId :: Maybe Text
metricName :: Maybe Text
rateKey :: Maybe Text
rateLimit :: Maybe Integer
$sel:matchPredicates:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails
-> Maybe [AwsWafRateBasedRuleMatchPredicate]
$sel:name:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
$sel:ruleId:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
$sel:metricName:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
$sel:rateKey:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Text
$sel:rateLimit:AwsWafRateBasedRuleDetails' :: AwsWafRateBasedRuleDetails -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RateLimit" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
rateLimit,
            (Text
"RateKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
rateKey,
            (Text
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricName,
            (Text
"RuleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleId,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"MatchPredicates" Text -> [AwsWafRateBasedRuleMatchPredicate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AwsWafRateBasedRuleMatchPredicate] -> Pair)
-> Maybe [AwsWafRateBasedRuleMatchPredicate] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AwsWafRateBasedRuleMatchPredicate]
matchPredicates
          ]
      )