{-# 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.WAFV2.Types.Rule 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.CaptchaConfig
import Amazonka.WAFV2.Types.ChallengeConfig
import Amazonka.WAFV2.Types.Label
import Amazonka.WAFV2.Types.OverrideAction
import Amazonka.WAFV2.Types.RuleAction
import Amazonka.WAFV2.Types.Statement
import Amazonka.WAFV2.Types.VisibilityConfig
data Rule = Rule'
{
Rule -> Maybe RuleAction
action :: Prelude.Maybe RuleAction,
Rule -> Maybe CaptchaConfig
captchaConfig :: Prelude.Maybe CaptchaConfig,
Rule -> Maybe ChallengeConfig
challengeConfig :: Prelude.Maybe ChallengeConfig,
Rule -> Maybe OverrideAction
overrideAction :: Prelude.Maybe OverrideAction,
Rule -> Maybe [Label]
ruleLabels :: Prelude.Maybe [Label],
Rule -> Text
name :: Prelude.Text,
Rule -> Natural
priority :: Prelude.Natural,
Rule -> Statement
statement :: Statement,
Rule -> VisibilityConfig
visibilityConfig :: VisibilityConfig
}
deriving (Rule -> Rule -> Bool
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]
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
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. 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 ->
Prelude.Natural ->
Statement ->
VisibilityConfig ->
Rule
newRule :: Text -> Natural -> Statement -> VisibilityConfig -> Rule
newRule
Text
pName_
Natural
pPriority_
Statement
pStatement_
VisibilityConfig
pVisibilityConfig_ =
Rule'
{ $sel:action:Rule' :: Maybe RuleAction
action = forall a. Maybe a
Prelude.Nothing,
$sel:captchaConfig:Rule' :: Maybe CaptchaConfig
captchaConfig = forall a. Maybe a
Prelude.Nothing,
$sel:challengeConfig:Rule' :: Maybe ChallengeConfig
challengeConfig = forall a. Maybe a
Prelude.Nothing,
$sel:overrideAction:Rule' :: Maybe OverrideAction
overrideAction = forall a. Maybe a
Prelude.Nothing,
$sel:ruleLabels:Rule' :: Maybe [Label]
ruleLabels = forall a. Maybe a
Prelude.Nothing,
$sel:name:Rule' :: Text
name = Text
pName_,
$sel:priority:Rule' :: Natural
priority = Natural
pPriority_,
$sel:statement:Rule' :: Statement
statement = Statement
pStatement_,
$sel:visibilityConfig:Rule' :: VisibilityConfig
visibilityConfig = VisibilityConfig
pVisibilityConfig_
}
rule_action :: Lens.Lens' Rule (Prelude.Maybe RuleAction)
rule_action :: Lens' Rule (Maybe RuleAction)
rule_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe RuleAction
action :: Maybe RuleAction
$sel:action:Rule' :: Rule -> Maybe RuleAction
action} -> Maybe RuleAction
action) (\s :: Rule
s@Rule' {} Maybe RuleAction
a -> Rule
s {$sel:action:Rule' :: Maybe RuleAction
action = Maybe RuleAction
a} :: Rule)
rule_captchaConfig :: Lens.Lens' Rule (Prelude.Maybe CaptchaConfig)
rule_captchaConfig :: Lens' Rule (Maybe CaptchaConfig)
rule_captchaConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe CaptchaConfig
captchaConfig :: Maybe CaptchaConfig
$sel:captchaConfig:Rule' :: Rule -> Maybe CaptchaConfig
captchaConfig} -> Maybe CaptchaConfig
captchaConfig) (\s :: Rule
s@Rule' {} Maybe CaptchaConfig
a -> Rule
s {$sel:captchaConfig:Rule' :: Maybe CaptchaConfig
captchaConfig = Maybe CaptchaConfig
a} :: Rule)
rule_challengeConfig :: Lens.Lens' Rule (Prelude.Maybe ChallengeConfig)
rule_challengeConfig :: Lens' Rule (Maybe ChallengeConfig)
rule_challengeConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe ChallengeConfig
challengeConfig :: Maybe ChallengeConfig
$sel:challengeConfig:Rule' :: Rule -> Maybe ChallengeConfig
challengeConfig} -> Maybe ChallengeConfig
challengeConfig) (\s :: Rule
s@Rule' {} Maybe ChallengeConfig
a -> Rule
s {$sel:challengeConfig:Rule' :: Maybe ChallengeConfig
challengeConfig = Maybe ChallengeConfig
a} :: Rule)
rule_overrideAction :: Lens.Lens' Rule (Prelude.Maybe OverrideAction)
rule_overrideAction :: Lens' Rule (Maybe OverrideAction)
rule_overrideAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe OverrideAction
overrideAction :: Maybe OverrideAction
$sel:overrideAction:Rule' :: Rule -> Maybe OverrideAction
overrideAction} -> Maybe OverrideAction
overrideAction) (\s :: Rule
s@Rule' {} Maybe OverrideAction
a -> Rule
s {$sel:overrideAction:Rule' :: Maybe OverrideAction
overrideAction = Maybe OverrideAction
a} :: Rule)
rule_ruleLabels :: Lens.Lens' Rule (Prelude.Maybe [Label])
rule_ruleLabels :: Lens' Rule (Maybe [Label])
rule_ruleLabels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe [Label]
ruleLabels :: Maybe [Label]
$sel:ruleLabels:Rule' :: Rule -> Maybe [Label]
ruleLabels} -> Maybe [Label]
ruleLabels) (\s :: Rule
s@Rule' {} Maybe [Label]
a -> Rule
s {$sel:ruleLabels:Rule' :: Maybe [Label]
ruleLabels = Maybe [Label]
a} :: Rule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
rule_name :: Lens.Lens' Rule Prelude.Text
rule_name :: Lens' Rule Text
rule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Text
name :: Text
$sel:name:Rule' :: Rule -> Text
name} -> Text
name) (\s :: Rule
s@Rule' {} Text
a -> Rule
s {$sel:name:Rule' :: Text
name = Text
a} :: Rule)
rule_priority :: Lens.Lens' Rule Prelude.Natural
rule_priority :: Lens' Rule Natural
rule_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Natural
priority :: Natural
$sel:priority:Rule' :: Rule -> Natural
priority} -> Natural
priority) (\s :: Rule
s@Rule' {} Natural
a -> Rule
s {$sel:priority:Rule' :: Natural
priority = Natural
a} :: Rule)
rule_statement :: Lens.Lens' Rule Statement
rule_statement :: Lens' Rule Statement
rule_statement = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Statement
statement :: Statement
$sel:statement:Rule' :: Rule -> Statement
statement} -> Statement
statement) (\s :: Rule
s@Rule' {} Statement
a -> Rule
s {$sel:statement:Rule' :: Statement
statement = Statement
a} :: Rule)
rule_visibilityConfig :: Lens.Lens' Rule VisibilityConfig
rule_visibilityConfig :: Lens' Rule VisibilityConfig
rule_visibilityConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {VisibilityConfig
visibilityConfig :: VisibilityConfig
$sel:visibilityConfig:Rule' :: Rule -> VisibilityConfig
visibilityConfig} -> VisibilityConfig
visibilityConfig) (\s :: Rule
s@Rule' {} VisibilityConfig
a -> Rule
s {$sel:visibilityConfig:Rule' :: VisibilityConfig
visibilityConfig = VisibilityConfig
a} :: Rule)
instance Data.FromJSON Rule where
parseJSON :: Value -> Parser Rule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Rule"
( \Object
x ->
Maybe RuleAction
-> Maybe CaptchaConfig
-> Maybe ChallengeConfig
-> Maybe OverrideAction
-> Maybe [Label]
-> Text
-> Natural
-> Statement
-> VisibilityConfig
-> Rule
Rule'
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
"Action")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CaptchaConfig")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ChallengeConfig")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OverrideAction")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RuleLabels" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Priority")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Statement")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"VisibilityConfig")
)
instance Prelude.Hashable Rule where
hashWithSalt :: Int -> Rule -> Int
hashWithSalt Int
_salt Rule' {Natural
Maybe [Label]
Maybe ChallengeConfig
Maybe CaptchaConfig
Maybe OverrideAction
Maybe RuleAction
Text
Statement
VisibilityConfig
visibilityConfig :: VisibilityConfig
statement :: Statement
priority :: Natural
name :: Text
ruleLabels :: Maybe [Label]
overrideAction :: Maybe OverrideAction
challengeConfig :: Maybe ChallengeConfig
captchaConfig :: Maybe CaptchaConfig
action :: Maybe RuleAction
$sel:visibilityConfig:Rule' :: Rule -> VisibilityConfig
$sel:statement:Rule' :: Rule -> Statement
$sel:priority:Rule' :: Rule -> Natural
$sel:name:Rule' :: Rule -> Text
$sel:ruleLabels:Rule' :: Rule -> Maybe [Label]
$sel:overrideAction:Rule' :: Rule -> Maybe OverrideAction
$sel:challengeConfig:Rule' :: Rule -> Maybe ChallengeConfig
$sel:captchaConfig:Rule' :: Rule -> Maybe CaptchaConfig
$sel:action:Rule' :: Rule -> Maybe RuleAction
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RuleAction
action
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CaptchaConfig
captchaConfig
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChallengeConfig
challengeConfig
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OverrideAction
overrideAction
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Label]
ruleLabels
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
priority
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Statement
statement
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` VisibilityConfig
visibilityConfig
instance Prelude.NFData Rule where
rnf :: Rule -> ()
rnf Rule' {Natural
Maybe [Label]
Maybe ChallengeConfig
Maybe CaptchaConfig
Maybe OverrideAction
Maybe RuleAction
Text
Statement
VisibilityConfig
visibilityConfig :: VisibilityConfig
statement :: Statement
priority :: Natural
name :: Text
ruleLabels :: Maybe [Label]
overrideAction :: Maybe OverrideAction
challengeConfig :: Maybe ChallengeConfig
captchaConfig :: Maybe CaptchaConfig
action :: Maybe RuleAction
$sel:visibilityConfig:Rule' :: Rule -> VisibilityConfig
$sel:statement:Rule' :: Rule -> Statement
$sel:priority:Rule' :: Rule -> Natural
$sel:name:Rule' :: Rule -> Text
$sel:ruleLabels:Rule' :: Rule -> Maybe [Label]
$sel:overrideAction:Rule' :: Rule -> Maybe OverrideAction
$sel:challengeConfig:Rule' :: Rule -> Maybe ChallengeConfig
$sel:captchaConfig:Rule' :: Rule -> Maybe CaptchaConfig
$sel:action:Rule' :: Rule -> Maybe RuleAction
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleAction
action
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CaptchaConfig
captchaConfig
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChallengeConfig
challengeConfig
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OverrideAction
overrideAction
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Label]
ruleLabels
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
priority
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Statement
statement
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf VisibilityConfig
visibilityConfig
instance Data.ToJSON Rule where
toJSON :: Rule -> Value
toJSON Rule' {Natural
Maybe [Label]
Maybe ChallengeConfig
Maybe CaptchaConfig
Maybe OverrideAction
Maybe RuleAction
Text
Statement
VisibilityConfig
visibilityConfig :: VisibilityConfig
statement :: Statement
priority :: Natural
name :: Text
ruleLabels :: Maybe [Label]
overrideAction :: Maybe OverrideAction
challengeConfig :: Maybe ChallengeConfig
captchaConfig :: Maybe CaptchaConfig
action :: Maybe RuleAction
$sel:visibilityConfig:Rule' :: Rule -> VisibilityConfig
$sel:statement:Rule' :: Rule -> Statement
$sel:priority:Rule' :: Rule -> Natural
$sel:name:Rule' :: Rule -> Text
$sel:ruleLabels:Rule' :: Rule -> Maybe [Label]
$sel:overrideAction:Rule' :: Rule -> Maybe OverrideAction
$sel:challengeConfig:Rule' :: Rule -> Maybe ChallengeConfig
$sel:captchaConfig:Rule' :: Rule -> Maybe CaptchaConfig
$sel:action:Rule' :: Rule -> Maybe RuleAction
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Action" 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 RuleAction
action,
(Key
"CaptchaConfig" 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 CaptchaConfig
captchaConfig,
(Key
"ChallengeConfig" 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 ChallengeConfig
challengeConfig,
(Key
"OverrideAction" 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 OverrideAction
overrideAction,
(Key
"RuleLabels" 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 [Label]
ruleLabels,
forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
forall a. a -> Maybe a
Prelude.Just (Key
"Priority" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
priority),
forall a. a -> Maybe a
Prelude.Just (Key
"Statement" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Statement
statement),
forall a. a -> Maybe a
Prelude.Just
(Key
"VisibilityConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= VisibilityConfig
visibilityConfig)
]
)