{-# 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.WAF.Types.RuleUpdate where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.ChangeAction
import Amazonka.WAF.Types.Predicate
data RuleUpdate = RuleUpdate'
{
RuleUpdate -> ChangeAction
action :: ChangeAction,
RuleUpdate -> Predicate
predicate :: Predicate
}
deriving (RuleUpdate -> RuleUpdate -> Bool
(RuleUpdate -> RuleUpdate -> Bool)
-> (RuleUpdate -> RuleUpdate -> Bool) -> Eq RuleUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleUpdate -> RuleUpdate -> Bool
$c/= :: RuleUpdate -> RuleUpdate -> Bool
== :: RuleUpdate -> RuleUpdate -> Bool
$c== :: RuleUpdate -> RuleUpdate -> Bool
Prelude.Eq, ReadPrec [RuleUpdate]
ReadPrec RuleUpdate
Int -> ReadS RuleUpdate
ReadS [RuleUpdate]
(Int -> ReadS RuleUpdate)
-> ReadS [RuleUpdate]
-> ReadPrec RuleUpdate
-> ReadPrec [RuleUpdate]
-> Read RuleUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleUpdate]
$creadListPrec :: ReadPrec [RuleUpdate]
readPrec :: ReadPrec RuleUpdate
$creadPrec :: ReadPrec RuleUpdate
readList :: ReadS [RuleUpdate]
$creadList :: ReadS [RuleUpdate]
readsPrec :: Int -> ReadS RuleUpdate
$creadsPrec :: Int -> ReadS RuleUpdate
Prelude.Read, Int -> RuleUpdate -> ShowS
[RuleUpdate] -> ShowS
RuleUpdate -> String
(Int -> RuleUpdate -> ShowS)
-> (RuleUpdate -> String)
-> ([RuleUpdate] -> ShowS)
-> Show RuleUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleUpdate] -> ShowS
$cshowList :: [RuleUpdate] -> ShowS
show :: RuleUpdate -> String
$cshow :: RuleUpdate -> String
showsPrec :: Int -> RuleUpdate -> ShowS
$cshowsPrec :: Int -> RuleUpdate -> ShowS
Prelude.Show, (forall x. RuleUpdate -> Rep RuleUpdate x)
-> (forall x. Rep RuleUpdate x -> RuleUpdate) -> Generic RuleUpdate
forall x. Rep RuleUpdate x -> RuleUpdate
forall x. RuleUpdate -> Rep RuleUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleUpdate x -> RuleUpdate
$cfrom :: forall x. RuleUpdate -> Rep RuleUpdate x
Prelude.Generic)
newRuleUpdate ::
ChangeAction ->
Predicate ->
RuleUpdate
newRuleUpdate :: ChangeAction -> Predicate -> RuleUpdate
newRuleUpdate ChangeAction
pAction_ Predicate
pPredicate_ =
RuleUpdate' :: ChangeAction -> Predicate -> RuleUpdate
RuleUpdate'
{ $sel:action:RuleUpdate' :: ChangeAction
action = ChangeAction
pAction_,
$sel:predicate:RuleUpdate' :: Predicate
predicate = Predicate
pPredicate_
}
ruleUpdate_action :: Lens.Lens' RuleUpdate ChangeAction
ruleUpdate_action :: (ChangeAction -> f ChangeAction) -> RuleUpdate -> f RuleUpdate
ruleUpdate_action = (RuleUpdate -> ChangeAction)
-> (RuleUpdate -> ChangeAction -> RuleUpdate)
-> Lens RuleUpdate RuleUpdate ChangeAction ChangeAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleUpdate' {ChangeAction
action :: ChangeAction
$sel:action:RuleUpdate' :: RuleUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: RuleUpdate
s@RuleUpdate' {} ChangeAction
a -> RuleUpdate
s {$sel:action:RuleUpdate' :: ChangeAction
action = ChangeAction
a} :: RuleUpdate)
ruleUpdate_predicate :: Lens.Lens' RuleUpdate Predicate
ruleUpdate_predicate :: (Predicate -> f Predicate) -> RuleUpdate -> f RuleUpdate
ruleUpdate_predicate = (RuleUpdate -> Predicate)
-> (RuleUpdate -> Predicate -> RuleUpdate)
-> Lens RuleUpdate RuleUpdate Predicate Predicate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleUpdate' {Predicate
predicate :: Predicate
$sel:predicate:RuleUpdate' :: RuleUpdate -> Predicate
predicate} -> Predicate
predicate) (\s :: RuleUpdate
s@RuleUpdate' {} Predicate
a -> RuleUpdate
s {$sel:predicate:RuleUpdate' :: Predicate
predicate = Predicate
a} :: RuleUpdate)
instance Prelude.Hashable RuleUpdate
instance Prelude.NFData RuleUpdate
instance Core.ToJSON RuleUpdate where
toJSON :: RuleUpdate -> Value
toJSON RuleUpdate' {ChangeAction
Predicate
predicate :: Predicate
action :: ChangeAction
$sel:predicate:RuleUpdate' :: RuleUpdate -> Predicate
$sel:action:RuleUpdate' :: RuleUpdate -> 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
"Predicate" Text -> Predicate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Predicate
predicate)
]
)