{-# 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.FirewallManagerRuleGroup
-- 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.FirewallManagerRuleGroup 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.FirewallManagerStatement
import Amazonka.WAFV2.Types.OverrideAction
import Amazonka.WAFV2.Types.VisibilityConfig

-- | A rule group that\'s defined for an Firewall Manager WAF policy.
--
-- /See:/ 'newFirewallManagerRuleGroup' smart constructor.
data FirewallManagerRuleGroup = FirewallManagerRuleGroup'
  { -- | The name of the rule group. You cannot change the name of a rule group
    -- after you create it.
    FirewallManagerRuleGroup -> Text
name :: Prelude.Text,
    -- | If you define more than one rule group in the first or last Firewall
    -- Manager rule groups, WAF evaluates each request against the rule groups
    -- in order, starting from the lowest priority setting. The priorities
    -- don\'t need to be consecutive, but they must all be different.
    FirewallManagerRuleGroup -> Natural
priority :: Prelude.Natural,
    -- | The processing guidance for an Firewall Manager rule. This is like a
    -- regular rule Statement, but it can only contain a rule group reference.
    FirewallManagerRuleGroup -> FirewallManagerStatement
firewallManagerStatement :: FirewallManagerStatement,
    -- | 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.
    FirewallManagerRuleGroup -> OverrideAction
overrideAction :: OverrideAction,
    -- | Defines and enables Amazon CloudWatch metrics and web request sample
    -- collection.
    FirewallManagerRuleGroup -> VisibilityConfig
visibilityConfig :: VisibilityConfig
  }
  deriving (FirewallManagerRuleGroup -> FirewallManagerRuleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FirewallManagerRuleGroup -> FirewallManagerRuleGroup -> Bool
$c/= :: FirewallManagerRuleGroup -> FirewallManagerRuleGroup -> Bool
== :: FirewallManagerRuleGroup -> FirewallManagerRuleGroup -> Bool
$c== :: FirewallManagerRuleGroup -> FirewallManagerRuleGroup -> Bool
Prelude.Eq, ReadPrec [FirewallManagerRuleGroup]
ReadPrec FirewallManagerRuleGroup
Int -> ReadS FirewallManagerRuleGroup
ReadS [FirewallManagerRuleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FirewallManagerRuleGroup]
$creadListPrec :: ReadPrec [FirewallManagerRuleGroup]
readPrec :: ReadPrec FirewallManagerRuleGroup
$creadPrec :: ReadPrec FirewallManagerRuleGroup
readList :: ReadS [FirewallManagerRuleGroup]
$creadList :: ReadS [FirewallManagerRuleGroup]
readsPrec :: Int -> ReadS FirewallManagerRuleGroup
$creadsPrec :: Int -> ReadS FirewallManagerRuleGroup
Prelude.Read, Int -> FirewallManagerRuleGroup -> ShowS
[FirewallManagerRuleGroup] -> ShowS
FirewallManagerRuleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FirewallManagerRuleGroup] -> ShowS
$cshowList :: [FirewallManagerRuleGroup] -> ShowS
show :: FirewallManagerRuleGroup -> String
$cshow :: FirewallManagerRuleGroup -> String
showsPrec :: Int -> FirewallManagerRuleGroup -> ShowS
$cshowsPrec :: Int -> FirewallManagerRuleGroup -> ShowS
Prelude.Show, forall x.
Rep FirewallManagerRuleGroup x -> FirewallManagerRuleGroup
forall x.
FirewallManagerRuleGroup -> Rep FirewallManagerRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FirewallManagerRuleGroup x -> FirewallManagerRuleGroup
$cfrom :: forall x.
FirewallManagerRuleGroup -> Rep FirewallManagerRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'FirewallManagerRuleGroup' 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:
--
-- 'name', 'firewallManagerRuleGroup_name' - The name of the rule group. You cannot change the name of a rule group
-- after you create it.
--
-- 'priority', 'firewallManagerRuleGroup_priority' - If you define more than one rule group in the first or last Firewall
-- Manager rule groups, WAF evaluates each request against the rule groups
-- in order, starting from the lowest priority setting. The priorities
-- don\'t need to be consecutive, but they must all be different.
--
-- 'firewallManagerStatement', 'firewallManagerRuleGroup_firewallManagerStatement' - The processing guidance for an Firewall Manager rule. This is like a
-- regular rule Statement, but it can only contain a rule group reference.
--
-- 'overrideAction', 'firewallManagerRuleGroup_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.
--
-- 'visibilityConfig', 'firewallManagerRuleGroup_visibilityConfig' - Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
newFirewallManagerRuleGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'priority'
  Prelude.Natural ->
  -- | 'firewallManagerStatement'
  FirewallManagerStatement ->
  -- | 'overrideAction'
  OverrideAction ->
  -- | 'visibilityConfig'
  VisibilityConfig ->
  FirewallManagerRuleGroup
newFirewallManagerRuleGroup :: Text
-> Natural
-> FirewallManagerStatement
-> OverrideAction
-> VisibilityConfig
-> FirewallManagerRuleGroup
newFirewallManagerRuleGroup
  Text
pName_
  Natural
pPriority_
  FirewallManagerStatement
pFirewallManagerStatement_
  OverrideAction
pOverrideAction_
  VisibilityConfig
pVisibilityConfig_ =
    FirewallManagerRuleGroup'
      { $sel:name:FirewallManagerRuleGroup' :: Text
name = Text
pName_,
        $sel:priority:FirewallManagerRuleGroup' :: Natural
priority = Natural
pPriority_,
        $sel:firewallManagerStatement:FirewallManagerRuleGroup' :: FirewallManagerStatement
firewallManagerStatement =
          FirewallManagerStatement
pFirewallManagerStatement_,
        $sel:overrideAction:FirewallManagerRuleGroup' :: OverrideAction
overrideAction = OverrideAction
pOverrideAction_,
        $sel:visibilityConfig:FirewallManagerRuleGroup' :: VisibilityConfig
visibilityConfig = VisibilityConfig
pVisibilityConfig_
      }

-- | The name of the rule group. You cannot change the name of a rule group
-- after you create it.
firewallManagerRuleGroup_name :: Lens.Lens' FirewallManagerRuleGroup Prelude.Text
firewallManagerRuleGroup_name :: Lens' FirewallManagerRuleGroup Text
firewallManagerRuleGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallManagerRuleGroup' {Text
name :: Text
$sel:name:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Text
name} -> Text
name) (\s :: FirewallManagerRuleGroup
s@FirewallManagerRuleGroup' {} Text
a -> FirewallManagerRuleGroup
s {$sel:name:FirewallManagerRuleGroup' :: Text
name = Text
a} :: FirewallManagerRuleGroup)

-- | If you define more than one rule group in the first or last Firewall
-- Manager rule groups, WAF evaluates each request against the rule groups
-- in order, starting from the lowest priority setting. The priorities
-- don\'t need to be consecutive, but they must all be different.
firewallManagerRuleGroup_priority :: Lens.Lens' FirewallManagerRuleGroup Prelude.Natural
firewallManagerRuleGroup_priority :: Lens' FirewallManagerRuleGroup Natural
firewallManagerRuleGroup_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallManagerRuleGroup' {Natural
priority :: Natural
$sel:priority:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Natural
priority} -> Natural
priority) (\s :: FirewallManagerRuleGroup
s@FirewallManagerRuleGroup' {} Natural
a -> FirewallManagerRuleGroup
s {$sel:priority:FirewallManagerRuleGroup' :: Natural
priority = Natural
a} :: FirewallManagerRuleGroup)

-- | The processing guidance for an Firewall Manager rule. This is like a
-- regular rule Statement, but it can only contain a rule group reference.
firewallManagerRuleGroup_firewallManagerStatement :: Lens.Lens' FirewallManagerRuleGroup FirewallManagerStatement
firewallManagerRuleGroup_firewallManagerStatement :: Lens' FirewallManagerRuleGroup FirewallManagerStatement
firewallManagerRuleGroup_firewallManagerStatement = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallManagerRuleGroup' {FirewallManagerStatement
firewallManagerStatement :: FirewallManagerStatement
$sel:firewallManagerStatement:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> FirewallManagerStatement
firewallManagerStatement} -> FirewallManagerStatement
firewallManagerStatement) (\s :: FirewallManagerRuleGroup
s@FirewallManagerRuleGroup' {} FirewallManagerStatement
a -> FirewallManagerRuleGroup
s {$sel:firewallManagerStatement:FirewallManagerRuleGroup' :: FirewallManagerStatement
firewallManagerStatement = FirewallManagerStatement
a} :: FirewallManagerRuleGroup)

-- | 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.
firewallManagerRuleGroup_overrideAction :: Lens.Lens' FirewallManagerRuleGroup OverrideAction
firewallManagerRuleGroup_overrideAction :: Lens' FirewallManagerRuleGroup OverrideAction
firewallManagerRuleGroup_overrideAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallManagerRuleGroup' {OverrideAction
overrideAction :: OverrideAction
$sel:overrideAction:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> OverrideAction
overrideAction} -> OverrideAction
overrideAction) (\s :: FirewallManagerRuleGroup
s@FirewallManagerRuleGroup' {} OverrideAction
a -> FirewallManagerRuleGroup
s {$sel:overrideAction:FirewallManagerRuleGroup' :: OverrideAction
overrideAction = OverrideAction
a} :: FirewallManagerRuleGroup)

-- | Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
firewallManagerRuleGroup_visibilityConfig :: Lens.Lens' FirewallManagerRuleGroup VisibilityConfig
firewallManagerRuleGroup_visibilityConfig :: Lens' FirewallManagerRuleGroup VisibilityConfig
firewallManagerRuleGroup_visibilityConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallManagerRuleGroup' {VisibilityConfig
visibilityConfig :: VisibilityConfig
$sel:visibilityConfig:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> VisibilityConfig
visibilityConfig} -> VisibilityConfig
visibilityConfig) (\s :: FirewallManagerRuleGroup
s@FirewallManagerRuleGroup' {} VisibilityConfig
a -> FirewallManagerRuleGroup
s {$sel:visibilityConfig:FirewallManagerRuleGroup' :: VisibilityConfig
visibilityConfig = VisibilityConfig
a} :: FirewallManagerRuleGroup)

instance Data.FromJSON FirewallManagerRuleGroup where
  parseJSON :: Value -> Parser FirewallManagerRuleGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FirewallManagerRuleGroup"
      ( \Object
x ->
          Text
-> Natural
-> FirewallManagerStatement
-> OverrideAction
-> VisibilityConfig
-> FirewallManagerRuleGroup
FirewallManagerRuleGroup'
            forall (f :: * -> *) a b. Functor 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
"FirewallManagerStatement")
            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
"OverrideAction")
            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 FirewallManagerRuleGroup where
  hashWithSalt :: Int -> FirewallManagerRuleGroup -> Int
hashWithSalt Int
_salt FirewallManagerRuleGroup' {Natural
Text
OverrideAction
FirewallManagerStatement
VisibilityConfig
visibilityConfig :: VisibilityConfig
overrideAction :: OverrideAction
firewallManagerStatement :: FirewallManagerStatement
priority :: Natural
name :: Text
$sel:visibilityConfig:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> VisibilityConfig
$sel:overrideAction:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> OverrideAction
$sel:firewallManagerStatement:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> FirewallManagerStatement
$sel:priority:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Natural
$sel:name:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Text
..} =
    Int
_salt
      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` FirewallManagerStatement
firewallManagerStatement
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OverrideAction
overrideAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` VisibilityConfig
visibilityConfig

instance Prelude.NFData FirewallManagerRuleGroup where
  rnf :: FirewallManagerRuleGroup -> ()
rnf FirewallManagerRuleGroup' {Natural
Text
OverrideAction
FirewallManagerStatement
VisibilityConfig
visibilityConfig :: VisibilityConfig
overrideAction :: OverrideAction
firewallManagerStatement :: FirewallManagerStatement
priority :: Natural
name :: Text
$sel:visibilityConfig:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> VisibilityConfig
$sel:overrideAction:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> OverrideAction
$sel:firewallManagerStatement:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> FirewallManagerStatement
$sel:priority:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Natural
$sel:name:FirewallManagerRuleGroup' :: FirewallManagerRuleGroup -> Text
..} =
    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 FirewallManagerStatement
firewallManagerStatement
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OverrideAction
overrideAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf VisibilityConfig
visibilityConfig