{-# 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.Rule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.Predicate
data Rule = Rule'
{
Rule -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
Rule -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
Rule -> Text
ruleId :: Prelude.Text,
Rule -> [Predicate]
predicates :: [Predicate]
}
deriving (Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Prelude.Eq, ReadPrec [Rule]
ReadPrec Rule
Int -> ReadS Rule
ReadS [Rule]
(Int -> ReadS Rule)
-> ReadS [Rule] -> ReadPrec Rule -> ReadPrec [Rule] -> Read Rule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rule]
$creadListPrec :: ReadPrec [Rule]
readPrec :: ReadPrec Rule
$creadPrec :: ReadPrec Rule
readList :: ReadS [Rule]
$creadList :: ReadS [Rule]
readsPrec :: Int -> ReadS Rule
$creadsPrec :: Int -> ReadS Rule
Prelude.Read, Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
(Int -> Rule -> ShowS)
-> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rule] -> ShowS
$cshowList :: [Rule] -> ShowS
show :: Rule -> String
$cshow :: Rule -> String
showsPrec :: Int -> Rule -> ShowS
$cshowsPrec :: Int -> Rule -> ShowS
Prelude.Show, (forall x. Rule -> Rep Rule x)
-> (forall x. Rep Rule x -> Rule) -> Generic Rule
forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rule x -> Rule
$cfrom :: forall x. Rule -> Rep Rule x
Prelude.Generic)
newRule ::
Prelude.Text ->
Rule
newRule :: Text -> Rule
newRule Text
pRuleId_ =
Rule' :: Maybe Text -> Maybe Text -> Text -> [Predicate] -> Rule
Rule'
{ $sel:metricName:Rule' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:Rule' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:ruleId:Rule' :: Text
ruleId = Text
pRuleId_,
$sel:predicates:Rule' :: [Predicate]
predicates = [Predicate]
forall a. Monoid a => a
Prelude.mempty
}
rule_metricName :: Lens.Lens' Rule (Prelude.Maybe Prelude.Text)
rule_metricName :: (Maybe Text -> f (Maybe Text)) -> Rule -> f Rule
rule_metricName = (Rule -> Maybe Text)
-> (Rule -> Maybe Text -> Rule)
-> Lens Rule Rule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe Text
metricName :: Maybe Text
$sel:metricName:Rule' :: Rule -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: Rule
s@Rule' {} Maybe Text
a -> Rule
s {$sel:metricName:Rule' :: Maybe Text
metricName = Maybe Text
a} :: Rule)
rule_name :: Lens.Lens' Rule (Prelude.Maybe Prelude.Text)
rule_name :: (Maybe Text -> f (Maybe Text)) -> Rule -> f Rule
rule_name = (Rule -> Maybe Text)
-> (Rule -> Maybe Text -> Rule)
-> Lens Rule Rule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe Text
name :: Maybe Text
$sel:name:Rule' :: Rule -> Maybe Text
name} -> Maybe Text
name) (\s :: Rule
s@Rule' {} Maybe Text
a -> Rule
s {$sel:name:Rule' :: Maybe Text
name = Maybe Text
a} :: Rule)
rule_ruleId :: Lens.Lens' Rule Prelude.Text
rule_ruleId :: (Text -> f Text) -> Rule -> f Rule
rule_ruleId = (Rule -> Text)
-> (Rule -> Text -> Rule) -> Lens Rule Rule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Text
ruleId :: Text
$sel:ruleId:Rule' :: Rule -> Text
ruleId} -> Text
ruleId) (\s :: Rule
s@Rule' {} Text
a -> Rule
s {$sel:ruleId:Rule' :: Text
ruleId = Text
a} :: Rule)
rule_predicates :: Lens.Lens' Rule [Predicate]
rule_predicates :: ([Predicate] -> f [Predicate]) -> Rule -> f Rule
rule_predicates = (Rule -> [Predicate])
-> (Rule -> [Predicate] -> Rule)
-> Lens Rule Rule [Predicate] [Predicate]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {[Predicate]
predicates :: [Predicate]
$sel:predicates:Rule' :: Rule -> [Predicate]
predicates} -> [Predicate]
predicates) (\s :: Rule
s@Rule' {} [Predicate]
a -> Rule
s {$sel:predicates:Rule' :: [Predicate]
predicates = [Predicate]
a} :: Rule) (([Predicate] -> f [Predicate]) -> Rule -> f Rule)
-> (([Predicate] -> f [Predicate]) -> [Predicate] -> f [Predicate])
-> ([Predicate] -> f [Predicate])
-> Rule
-> f Rule
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
instance Core.FromJSON Rule where
parseJSON :: Value -> Parser Rule
parseJSON =
String -> (Object -> Parser Rule) -> Value -> Parser Rule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Rule"
( \Object
x ->
Maybe Text -> Maybe Text -> Text -> [Predicate] -> Rule
Rule'
(Maybe Text -> Maybe Text -> Text -> [Predicate] -> Rule)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> [Predicate] -> Rule)
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] -> Rule)
-> Parser (Maybe Text) -> Parser (Text -> [Predicate] -> Rule)
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] -> Rule)
-> Parser Text -> Parser ([Predicate] -> Rule)
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] -> Rule) -> Parser [Predicate] -> Parser Rule
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
"Predicates" Parser (Maybe [Predicate]) -> [Predicate] -> Parser [Predicate]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Predicate]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Rule
instance Prelude.NFData Rule