{-# 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.WAFRegional.Types.RuleGroupUpdate
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WAFRegional.Types.RuleGroupUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.ActivatedRule
import Amazonka.WAFRegional.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
(RuleGroupUpdate -> RuleGroupUpdate -> Bool)
-> (RuleGroupUpdate -> RuleGroupUpdate -> Bool)
-> Eq RuleGroupUpdate
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]
(Int -> ReadS RuleGroupUpdate)
-> ReadS [RuleGroupUpdate]
-> ReadPrec RuleGroupUpdate
-> ReadPrec [RuleGroupUpdate]
-> Read 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
(Int -> RuleGroupUpdate -> ShowS)
-> (RuleGroupUpdate -> String)
-> ([RuleGroupUpdate] -> ShowS)
-> Show RuleGroupUpdate
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. RuleGroupUpdate -> Rep RuleGroupUpdate x)
-> (forall x. Rep RuleGroupUpdate x -> RuleGroupUpdate)
-> Generic RuleGroupUpdate
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' :: ChangeAction -> ActivatedRule -> RuleGroupUpdate
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 :: (ChangeAction -> f ChangeAction)
-> RuleGroupUpdate -> f RuleGroupUpdate
ruleGroupUpdate_action = (RuleGroupUpdate -> ChangeAction)
-> (RuleGroupUpdate -> ChangeAction -> RuleGroupUpdate)
-> Lens RuleGroupUpdate RuleGroupUpdate ChangeAction ChangeAction
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 :: (ActivatedRule -> f ActivatedRule)
-> RuleGroupUpdate -> f RuleGroupUpdate
ruleGroupUpdate_activatedRule = (RuleGroupUpdate -> ActivatedRule)
-> (RuleGroupUpdate -> ActivatedRule -> RuleGroupUpdate)
-> Lens RuleGroupUpdate RuleGroupUpdate ActivatedRule 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

instance Prelude.NFData RuleGroupUpdate

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> ChangeAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ChangeAction
action),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ActivatedRule" Text -> ActivatedRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActivatedRule
activatedRule)
          ]
      )