{-# 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 #-}
module Amazonka.WAF.Types.RateBasedRule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.Predicate
import Amazonka.WAF.Types.RateKey
data RateBasedRule = RateBasedRule'
{
RateBasedRule -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
RateBasedRule -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
RateBasedRule -> Text
ruleId :: Prelude.Text,
RateBasedRule -> [Predicate]
matchPredicates :: [Predicate],
RateBasedRule -> RateKey
rateKey :: RateKey,
RateBasedRule -> Natural
rateLimit :: Prelude.Natural
}
deriving (RateBasedRule -> RateBasedRule -> Bool
(RateBasedRule -> RateBasedRule -> Bool)
-> (RateBasedRule -> RateBasedRule -> Bool) -> Eq RateBasedRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RateBasedRule -> RateBasedRule -> Bool
$c/= :: RateBasedRule -> RateBasedRule -> Bool
== :: RateBasedRule -> RateBasedRule -> Bool
$c== :: RateBasedRule -> RateBasedRule -> Bool
Prelude.Eq, ReadPrec [RateBasedRule]
ReadPrec RateBasedRule
Int -> ReadS RateBasedRule
ReadS [RateBasedRule]
(Int -> ReadS RateBasedRule)
-> ReadS [RateBasedRule]
-> ReadPrec RateBasedRule
-> ReadPrec [RateBasedRule]
-> Read RateBasedRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RateBasedRule]
$creadListPrec :: ReadPrec [RateBasedRule]
readPrec :: ReadPrec RateBasedRule
$creadPrec :: ReadPrec RateBasedRule
readList :: ReadS [RateBasedRule]
$creadList :: ReadS [RateBasedRule]
readsPrec :: Int -> ReadS RateBasedRule
$creadsPrec :: Int -> ReadS RateBasedRule
Prelude.Read, Int -> RateBasedRule -> ShowS
[RateBasedRule] -> ShowS
RateBasedRule -> String
(Int -> RateBasedRule -> ShowS)
-> (RateBasedRule -> String)
-> ([RateBasedRule] -> ShowS)
-> Show RateBasedRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RateBasedRule] -> ShowS
$cshowList :: [RateBasedRule] -> ShowS
show :: RateBasedRule -> String
$cshow :: RateBasedRule -> String
showsPrec :: Int -> RateBasedRule -> ShowS
$cshowsPrec :: Int -> RateBasedRule -> ShowS
Prelude.Show, (forall x. RateBasedRule -> Rep RateBasedRule x)
-> (forall x. Rep RateBasedRule x -> RateBasedRule)
-> Generic RateBasedRule
forall x. Rep RateBasedRule x -> RateBasedRule
forall x. RateBasedRule -> Rep RateBasedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RateBasedRule x -> RateBasedRule
$cfrom :: forall x. RateBasedRule -> Rep RateBasedRule x
Prelude.Generic)
newRateBasedRule ::
Prelude.Text ->
RateKey ->
Prelude.Natural ->
RateBasedRule
newRateBasedRule :: Text -> RateKey -> Natural -> RateBasedRule
newRateBasedRule Text
pRuleId_ RateKey
pRateKey_ Natural
pRateLimit_ =
RateBasedRule' :: Maybe Text
-> Maybe Text
-> Text
-> [Predicate]
-> RateKey
-> Natural
-> RateBasedRule
RateBasedRule'
{ $sel:metricName:RateBasedRule' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:RateBasedRule' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:ruleId:RateBasedRule' :: Text
ruleId = Text
pRuleId_,
$sel:matchPredicates:RateBasedRule' :: [Predicate]
matchPredicates = [Predicate]
forall a. Monoid a => a
Prelude.mempty,
$sel:rateKey:RateBasedRule' :: RateKey
rateKey = RateKey
pRateKey_,
$sel:rateLimit:RateBasedRule' :: Natural
rateLimit = Natural
pRateLimit_
}
rateBasedRule_metricName :: Lens.Lens' RateBasedRule (Prelude.Maybe Prelude.Text)
rateBasedRule_metricName :: (Maybe Text -> f (Maybe Text)) -> RateBasedRule -> f RateBasedRule
rateBasedRule_metricName = (RateBasedRule -> Maybe Text)
-> (RateBasedRule -> Maybe Text -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {Maybe Text
metricName :: Maybe Text
$sel:metricName:RateBasedRule' :: RateBasedRule -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: RateBasedRule
s@RateBasedRule' {} Maybe Text
a -> RateBasedRule
s {$sel:metricName:RateBasedRule' :: Maybe Text
metricName = Maybe Text
a} :: RateBasedRule)
rateBasedRule_name :: Lens.Lens' RateBasedRule (Prelude.Maybe Prelude.Text)
rateBasedRule_name :: (Maybe Text -> f (Maybe Text)) -> RateBasedRule -> f RateBasedRule
rateBasedRule_name = (RateBasedRule -> Maybe Text)
-> (RateBasedRule -> Maybe Text -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {Maybe Text
name :: Maybe Text
$sel:name:RateBasedRule' :: RateBasedRule -> Maybe Text
name} -> Maybe Text
name) (\s :: RateBasedRule
s@RateBasedRule' {} Maybe Text
a -> RateBasedRule
s {$sel:name:RateBasedRule' :: Maybe Text
name = Maybe Text
a} :: RateBasedRule)
rateBasedRule_ruleId :: Lens.Lens' RateBasedRule Prelude.Text
rateBasedRule_ruleId :: (Text -> f Text) -> RateBasedRule -> f RateBasedRule
rateBasedRule_ruleId = (RateBasedRule -> Text)
-> (RateBasedRule -> Text -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {Text
ruleId :: Text
$sel:ruleId:RateBasedRule' :: RateBasedRule -> Text
ruleId} -> Text
ruleId) (\s :: RateBasedRule
s@RateBasedRule' {} Text
a -> RateBasedRule
s {$sel:ruleId:RateBasedRule' :: Text
ruleId = Text
a} :: RateBasedRule)
rateBasedRule_matchPredicates :: Lens.Lens' RateBasedRule [Predicate]
rateBasedRule_matchPredicates :: ([Predicate] -> f [Predicate]) -> RateBasedRule -> f RateBasedRule
rateBasedRule_matchPredicates = (RateBasedRule -> [Predicate])
-> (RateBasedRule -> [Predicate] -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule [Predicate] [Predicate]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {[Predicate]
matchPredicates :: [Predicate]
$sel:matchPredicates:RateBasedRule' :: RateBasedRule -> [Predicate]
matchPredicates} -> [Predicate]
matchPredicates) (\s :: RateBasedRule
s@RateBasedRule' {} [Predicate]
a -> RateBasedRule
s {$sel:matchPredicates:RateBasedRule' :: [Predicate]
matchPredicates = [Predicate]
a} :: RateBasedRule) (([Predicate] -> f [Predicate])
-> RateBasedRule -> f RateBasedRule)
-> (([Predicate] -> f [Predicate]) -> [Predicate] -> f [Predicate])
-> ([Predicate] -> f [Predicate])
-> RateBasedRule
-> f RateBasedRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Predicate] -> f [Predicate]) -> [Predicate] -> f [Predicate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
rateBasedRule_rateKey :: Lens.Lens' RateBasedRule RateKey
rateBasedRule_rateKey :: (RateKey -> f RateKey) -> RateBasedRule -> f RateBasedRule
rateBasedRule_rateKey = (RateBasedRule -> RateKey)
-> (RateBasedRule -> RateKey -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule RateKey RateKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {RateKey
rateKey :: RateKey
$sel:rateKey:RateBasedRule' :: RateBasedRule -> RateKey
rateKey} -> RateKey
rateKey) (\s :: RateBasedRule
s@RateBasedRule' {} RateKey
a -> RateBasedRule
s {$sel:rateKey:RateBasedRule' :: RateKey
rateKey = RateKey
a} :: RateBasedRule)
rateBasedRule_rateLimit :: Lens.Lens' RateBasedRule Prelude.Natural
rateBasedRule_rateLimit :: (Natural -> f Natural) -> RateBasedRule -> f RateBasedRule
rateBasedRule_rateLimit = (RateBasedRule -> Natural)
-> (RateBasedRule -> Natural -> RateBasedRule)
-> Lens RateBasedRule RateBasedRule Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RateBasedRule' {Natural
rateLimit :: Natural
$sel:rateLimit:RateBasedRule' :: RateBasedRule -> Natural
rateLimit} -> Natural
rateLimit) (\s :: RateBasedRule
s@RateBasedRule' {} Natural
a -> RateBasedRule
s {$sel:rateLimit:RateBasedRule' :: Natural
rateLimit = Natural
a} :: RateBasedRule)
instance Core.FromJSON RateBasedRule where
parseJSON :: Value -> Parser RateBasedRule
parseJSON =
String
-> (Object -> Parser RateBasedRule)
-> Value
-> Parser RateBasedRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RateBasedRule"
( \Object
x ->
Maybe Text
-> Maybe Text
-> Text
-> [Predicate]
-> RateKey
-> Natural
-> RateBasedRule
RateBasedRule'
(Maybe Text
-> Maybe Text
-> Text
-> [Predicate]
-> RateKey
-> Natural
-> RateBasedRule)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Text -> [Predicate] -> RateKey -> Natural -> RateBasedRule)
forall (f :: * -> *) a b. Functor 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
-> Text -> [Predicate] -> RateKey -> Natural -> RateBasedRule)
-> Parser (Maybe Text)
-> Parser
(Text -> [Predicate] -> RateKey -> Natural -> RateBasedRule)
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 (Text -> [Predicate] -> RateKey -> Natural -> RateBasedRule)
-> Parser Text
-> Parser ([Predicate] -> RateKey -> Natural -> RateBasedRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RuleId")
Parser ([Predicate] -> RateKey -> Natural -> RateBasedRule)
-> Parser [Predicate]
-> Parser (RateKey -> Natural -> RateBasedRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [Predicate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchPredicates"
Parser (Maybe [Predicate]) -> [Predicate] -> Parser [Predicate]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Predicate]
forall a. Monoid a => a
Prelude.mempty
)
Parser (RateKey -> Natural -> RateBasedRule)
-> Parser RateKey -> Parser (Natural -> RateBasedRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RateKey
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RateKey")
Parser (Natural -> RateBasedRule)
-> Parser Natural -> Parser RateBasedRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RateLimit")
)
instance Prelude.Hashable RateBasedRule
instance Prelude.NFData RateBasedRule