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

-- | A single rule, which you can use in a WebACL or RuleGroup to identify
-- web requests that you want to allow, block, or count. Each rule includes
-- one top-level Statement that WAF uses to identify matching web requests,
-- and parameters that govern how WAF handles them.
--
-- /See:/ 'newRule' smart constructor.
data Rule = Rule'
  { -- | The action that WAF should take on a web request when it matches the
    -- rule statement. Settings at the web ACL level can override the rule
    -- action setting.
    --
    -- This is used only for rules whose statements do not reference a rule
    -- group. Rule statements that reference a rule group include
    -- @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
    --
    -- You must specify either this @Action@ setting or the rule
    -- @OverrideAction@ setting, but not both:
    --
    -- -   If the rule statement does not reference a rule group, use this rule
    --     action setting and not the rule override action setting.
    --
    -- -   If the rule statement references a rule group, use the override
    --     action setting and not this action setting.
    Rule -> Maybe RuleAction
action :: Prelude.Maybe RuleAction,
    -- | Specifies how WAF should handle @CAPTCHA@ evaluations. If you don\'t
    -- specify this, WAF uses the @CAPTCHA@ configuration that\'s defined for
    -- the web ACL.
    Rule -> Maybe CaptchaConfig
captchaConfig :: Prelude.Maybe CaptchaConfig,
    -- | Specifies how WAF should handle @Challenge@ evaluations. If you don\'t
    -- specify this, WAF uses the challenge configuration that\'s defined for
    -- the web ACL.
    Rule -> Maybe ChallengeConfig
challengeConfig :: Prelude.Maybe ChallengeConfig,
    -- | The action to use in the place of the action that results from the rule
    -- group evaluation. Set the override action to none to leave the result of
    -- the rule group alone. Set it to count to override the result to count
    -- only.
    --
    -- You can only use this for rule statements that reference a rule group,
    -- like @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
    --
    -- This option is usually set to none. It does not affect how the rules in
    -- the rule group are evaluated. If you want the rules in the rule group to
    -- only count matches, do not use this and instead use the rule action
    -- override option, with @Count@ action, in your rule group reference
    -- statement settings.
    Rule -> Maybe OverrideAction
overrideAction :: Prelude.Maybe OverrideAction,
    -- | Labels to apply to web requests that match the rule match statement. WAF
    -- applies fully qualified labels to matching web requests. A fully
    -- qualified label is the concatenation of a label namespace and a rule
    -- label. The rule\'s rule group or web ACL defines the label namespace.
    --
    -- Rules that run after this rule in the web ACL can match against these
    -- labels using a @LabelMatchStatement@.
    --
    -- For each label, provide a case-sensitive string containing optional
    -- namespaces and a label name, according to the following guidelines:
    --
    -- -   Separate each component of the label with a colon.
    --
    -- -   Each namespace or name can have up to 128 characters.
    --
    -- -   You can specify up to 5 namespaces in a label.
    --
    -- -   Don\'t use the following reserved words in your label specification:
    --     @aws@, @waf@, @managed@, @rulegroup@, @webacl@, @regexpatternset@,
    --     or @ipset@.
    --
    -- For example, @myLabelName@ or @nameSpace1:nameSpace2:myLabelName@.
    Rule -> Maybe [Label]
ruleLabels :: Prelude.Maybe [Label],
    -- | The name of the rule. You can\'t change the name of a @Rule@ after you
    -- create it.
    Rule -> Text
name :: Prelude.Text,
    -- | If you define more than one @Rule@ in a @WebACL@, WAF evaluates each
    -- request against the @Rules@ in order based on the value of @Priority@.
    -- WAF processes rules with lower priority first. The priorities don\'t
    -- need to be consecutive, but they must all be different.
    Rule -> Natural
priority :: Prelude.Natural,
    -- | The WAF processing statement for the rule, for example
    -- ByteMatchStatement or SizeConstraintStatement.
    Rule -> Statement
statement :: Statement,
    -- | Defines and enables Amazon CloudWatch metrics and web request sample
    -- collection.
    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)

-- |
-- Create a value of 'Rule' 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:
--
-- 'action', 'rule_action' - The action that WAF should take on a web request when it matches the
-- rule statement. Settings at the web ACL level can override the rule
-- action setting.
--
-- This is used only for rules whose statements do not reference a rule
-- group. Rule statements that reference a rule group include
-- @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
--
-- You must specify either this @Action@ setting or the rule
-- @OverrideAction@ setting, but not both:
--
-- -   If the rule statement does not reference a rule group, use this rule
--     action setting and not the rule override action setting.
--
-- -   If the rule statement references a rule group, use the override
--     action setting and not this action setting.
--
-- 'captchaConfig', 'rule_captchaConfig' - Specifies how WAF should handle @CAPTCHA@ evaluations. If you don\'t
-- specify this, WAF uses the @CAPTCHA@ configuration that\'s defined for
-- the web ACL.
--
-- 'challengeConfig', 'rule_challengeConfig' - Specifies how WAF should handle @Challenge@ evaluations. If you don\'t
-- specify this, WAF uses the challenge configuration that\'s defined for
-- the web ACL.
--
-- 'overrideAction', 'rule_overrideAction' - The action to use in the place of the action that results from the rule
-- group evaluation. Set the override action to none to leave the result of
-- the rule group alone. Set it to count to override the result to count
-- only.
--
-- You can only use this for rule statements that reference a rule group,
-- like @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
--
-- This option is usually set to none. It does not affect how the rules in
-- the rule group are evaluated. If you want the rules in the rule group to
-- only count matches, do not use this and instead use the rule action
-- override option, with @Count@ action, in your rule group reference
-- statement settings.
--
-- 'ruleLabels', 'rule_ruleLabels' - Labels to apply to web requests that match the rule match statement. WAF
-- applies fully qualified labels to matching web requests. A fully
-- qualified label is the concatenation of a label namespace and a rule
-- label. The rule\'s rule group or web ACL defines the label namespace.
--
-- Rules that run after this rule in the web ACL can match against these
-- labels using a @LabelMatchStatement@.
--
-- For each label, provide a case-sensitive string containing optional
-- namespaces and a label name, according to the following guidelines:
--
-- -   Separate each component of the label with a colon.
--
-- -   Each namespace or name can have up to 128 characters.
--
-- -   You can specify up to 5 namespaces in a label.
--
-- -   Don\'t use the following reserved words in your label specification:
--     @aws@, @waf@, @managed@, @rulegroup@, @webacl@, @regexpatternset@,
--     or @ipset@.
--
-- For example, @myLabelName@ or @nameSpace1:nameSpace2:myLabelName@.
--
-- 'name', 'rule_name' - The name of the rule. You can\'t change the name of a @Rule@ after you
-- create it.
--
-- 'priority', 'rule_priority' - If you define more than one @Rule@ in a @WebACL@, WAF evaluates each
-- request against the @Rules@ in order based on the value of @Priority@.
-- WAF processes rules with lower priority first. The priorities don\'t
-- need to be consecutive, but they must all be different.
--
-- 'statement', 'rule_statement' - The WAF processing statement for the rule, for example
-- ByteMatchStatement or SizeConstraintStatement.
--
-- 'visibilityConfig', 'rule_visibilityConfig' - Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
newRule ::
  -- | 'name'
  Prelude.Text ->
  -- | 'priority'
  Prelude.Natural ->
  -- | 'statement'
  Statement ->
  -- | 'visibilityConfig'
  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_
      }

-- | The action that WAF should take on a web request when it matches the
-- rule statement. Settings at the web ACL level can override the rule
-- action setting.
--
-- This is used only for rules whose statements do not reference a rule
-- group. Rule statements that reference a rule group include
-- @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
--
-- You must specify either this @Action@ setting or the rule
-- @OverrideAction@ setting, but not both:
--
-- -   If the rule statement does not reference a rule group, use this rule
--     action setting and not the rule override action setting.
--
-- -   If the rule statement references a rule group, use the override
--     action setting and not this action setting.
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)

-- | Specifies how WAF should handle @CAPTCHA@ evaluations. If you don\'t
-- specify this, WAF uses the @CAPTCHA@ configuration that\'s defined for
-- the web ACL.
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)

-- | Specifies how WAF should handle @Challenge@ evaluations. If you don\'t
-- specify this, WAF uses the challenge configuration that\'s defined for
-- the web ACL.
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)

-- | The action to use in the place of the action that results from the rule
-- group evaluation. Set the override action to none to leave the result of
-- the rule group alone. Set it to count to override the result to count
-- only.
--
-- You can only use this for rule statements that reference a rule group,
-- like @RuleGroupReferenceStatement@ and @ManagedRuleGroupStatement@.
--
-- This option is usually set to none. It does not affect how the rules in
-- the rule group are evaluated. If you want the rules in the rule group to
-- only count matches, do not use this and instead use the rule action
-- override option, with @Count@ action, in your rule group reference
-- statement settings.
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)

-- | Labels to apply to web requests that match the rule match statement. WAF
-- applies fully qualified labels to matching web requests. A fully
-- qualified label is the concatenation of a label namespace and a rule
-- label. The rule\'s rule group or web ACL defines the label namespace.
--
-- Rules that run after this rule in the web ACL can match against these
-- labels using a @LabelMatchStatement@.
--
-- For each label, provide a case-sensitive string containing optional
-- namespaces and a label name, according to the following guidelines:
--
-- -   Separate each component of the label with a colon.
--
-- -   Each namespace or name can have up to 128 characters.
--
-- -   You can specify up to 5 namespaces in a label.
--
-- -   Don\'t use the following reserved words in your label specification:
--     @aws@, @waf@, @managed@, @rulegroup@, @webacl@, @regexpatternset@,
--     or @ipset@.
--
-- For example, @myLabelName@ or @nameSpace1:nameSpace2:myLabelName@.
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

-- | The name of the rule. You can\'t change the name of a @Rule@ after you
-- create it.
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)

-- | If you define more than one @Rule@ in a @WebACL@, WAF evaluates each
-- request against the @Rules@ in order based on the value of @Priority@.
-- WAF processes rules with lower priority first. The priorities don\'t
-- need to be consecutive, but they must all be different.
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)

-- | The WAF processing statement for the rule, for example
-- ByteMatchStatement or SizeConstraintStatement.
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)

-- | Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
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)
          ]
      )