{-# 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.WAF.Types.RuleGroupUpdate
-- 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.WAF.Types.RuleGroupUpdate 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.WAF.Types.ActivatedRule
import Amazonka.WAF.Types.ChangeAction

-- | This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Specifies an @ActivatedRule@ and indicates whether you want to add it to
-- a @RuleGroup@ or delete it from a @RuleGroup@.
--
-- /See:/ 'newRuleGroupUpdate' smart constructor.
data RuleGroupUpdate = RuleGroupUpdate'
  { -- | Specify @INSERT@ to add an @ActivatedRule@ to a @RuleGroup@. Use
    -- @DELETE@ to remove an @ActivatedRule@ from a @RuleGroup@.
    RuleGroupUpdate -> ChangeAction
action :: ChangeAction,
    -- | The @ActivatedRule@ object specifies a @Rule@ that you want to insert or
    -- delete, the priority of the @Rule@ in the @WebACL@, and the action that
    -- you want AWS WAF to take when a web request matches the @Rule@ (@ALLOW@,
    -- @BLOCK@, or @COUNT@).
    RuleGroupUpdate -> ActivatedRule
activatedRule :: ActivatedRule
  }
  deriving (RuleGroupUpdate -> RuleGroupUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleGroupUpdate -> RuleGroupUpdate -> Bool
$c/= :: RuleGroupUpdate -> RuleGroupUpdate -> Bool
== :: RuleGroupUpdate -> RuleGroupUpdate -> Bool
$c== :: RuleGroupUpdate -> RuleGroupUpdate -> Bool
Prelude.Eq, ReadPrec [RuleGroupUpdate]
ReadPrec RuleGroupUpdate
Int -> ReadS RuleGroupUpdate
ReadS [RuleGroupUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleGroupUpdate]
$creadListPrec :: ReadPrec [RuleGroupUpdate]
readPrec :: ReadPrec RuleGroupUpdate
$creadPrec :: ReadPrec RuleGroupUpdate
readList :: ReadS [RuleGroupUpdate]
$creadList :: ReadS [RuleGroupUpdate]
readsPrec :: Int -> ReadS RuleGroupUpdate
$creadsPrec :: Int -> ReadS RuleGroupUpdate
Prelude.Read, Int -> RuleGroupUpdate -> ShowS
[RuleGroupUpdate] -> ShowS
RuleGroupUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleGroupUpdate] -> ShowS
$cshowList :: [RuleGroupUpdate] -> ShowS
show :: RuleGroupUpdate -> String
$cshow :: RuleGroupUpdate -> String
showsPrec :: Int -> RuleGroupUpdate -> ShowS
$cshowsPrec :: Int -> RuleGroupUpdate -> ShowS
Prelude.Show, forall x. Rep RuleGroupUpdate x -> RuleGroupUpdate
forall x. RuleGroupUpdate -> Rep RuleGroupUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleGroupUpdate x -> RuleGroupUpdate
$cfrom :: forall x. RuleGroupUpdate -> Rep RuleGroupUpdate x
Prelude.Generic)

-- |
-- Create a value of 'RuleGroupUpdate' 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', 'ruleGroupUpdate_action' - Specify @INSERT@ to add an @ActivatedRule@ to a @RuleGroup@. Use
-- @DELETE@ to remove an @ActivatedRule@ from a @RuleGroup@.
--
-- 'activatedRule', 'ruleGroupUpdate_activatedRule' - The @ActivatedRule@ object specifies a @Rule@ that you want to insert or
-- delete, the priority of the @Rule@ in the @WebACL@, and the action that
-- you want AWS WAF to take when a web request matches the @Rule@ (@ALLOW@,
-- @BLOCK@, or @COUNT@).
newRuleGroupUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'activatedRule'
  ActivatedRule ->
  RuleGroupUpdate
newRuleGroupUpdate :: ChangeAction -> ActivatedRule -> RuleGroupUpdate
newRuleGroupUpdate ChangeAction
pAction_ ActivatedRule
pActivatedRule_ =
  RuleGroupUpdate'
    { $sel:action:RuleGroupUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:activatedRule:RuleGroupUpdate' :: ActivatedRule
activatedRule = ActivatedRule
pActivatedRule_
    }

-- | Specify @INSERT@ to add an @ActivatedRule@ to a @RuleGroup@. Use
-- @DELETE@ to remove an @ActivatedRule@ from a @RuleGroup@.
ruleGroupUpdate_action :: Lens.Lens' RuleGroupUpdate ChangeAction
ruleGroupUpdate_action :: Lens' RuleGroupUpdate ChangeAction
ruleGroupUpdate_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroupUpdate' {ChangeAction
action :: ChangeAction
$sel:action:RuleGroupUpdate' :: RuleGroupUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: RuleGroupUpdate
s@RuleGroupUpdate' {} ChangeAction
a -> RuleGroupUpdate
s {$sel:action:RuleGroupUpdate' :: ChangeAction
action = ChangeAction
a} :: RuleGroupUpdate)

-- | The @ActivatedRule@ object specifies a @Rule@ that you want to insert or
-- delete, the priority of the @Rule@ in the @WebACL@, and the action that
-- you want AWS WAF to take when a web request matches the @Rule@ (@ALLOW@,
-- @BLOCK@, or @COUNT@).
ruleGroupUpdate_activatedRule :: Lens.Lens' RuleGroupUpdate ActivatedRule
ruleGroupUpdate_activatedRule :: Lens' RuleGroupUpdate ActivatedRule
ruleGroupUpdate_activatedRule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroupUpdate' {ActivatedRule
activatedRule :: ActivatedRule
$sel:activatedRule:RuleGroupUpdate' :: RuleGroupUpdate -> ActivatedRule
activatedRule} -> ActivatedRule
activatedRule) (\s :: RuleGroupUpdate
s@RuleGroupUpdate' {} ActivatedRule
a -> RuleGroupUpdate
s {$sel:activatedRule:RuleGroupUpdate' :: ActivatedRule
activatedRule = ActivatedRule
a} :: RuleGroupUpdate)

instance Prelude.Hashable RuleGroupUpdate where
  hashWithSalt :: Int -> RuleGroupUpdate -> Int
hashWithSalt Int
_salt RuleGroupUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:RuleGroupUpdate' :: RuleGroupUpdate -> ActivatedRule
$sel:action:RuleGroupUpdate' :: RuleGroupUpdate -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ActivatedRule
activatedRule

instance Prelude.NFData RuleGroupUpdate where
  rnf :: RuleGroupUpdate -> ()
rnf RuleGroupUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:RuleGroupUpdate' :: RuleGroupUpdate -> ActivatedRule
$sel:action:RuleGroupUpdate' :: RuleGroupUpdate -> ChangeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ChangeAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ActivatedRule
activatedRule

instance Data.ToJSON RuleGroupUpdate where
  toJSON :: RuleGroupUpdate -> Value
toJSON RuleGroupUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:RuleGroupUpdate' :: RuleGroupUpdate -> ActivatedRule
$sel:action:RuleGroupUpdate' :: RuleGroupUpdate -> ChangeAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Action" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ChangeAction
action),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ActivatedRule" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ActivatedRule
activatedRule)
          ]
      )