{-# 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.WAFRegional.Types.Predicate where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.PredicateType
data Predicate = Predicate'
{
Predicate -> Bool
negated :: Prelude.Bool,
Predicate -> PredicateType
type' :: PredicateType,
Predicate -> Text
dataId :: Prelude.Text
}
deriving (Predicate -> Predicate -> Bool
(Predicate -> Predicate -> Bool)
-> (Predicate -> Predicate -> Bool) -> Eq Predicate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Predicate -> Predicate -> Bool
$c/= :: Predicate -> Predicate -> Bool
== :: Predicate -> Predicate -> Bool
$c== :: Predicate -> Predicate -> Bool
Prelude.Eq, ReadPrec [Predicate]
ReadPrec Predicate
Int -> ReadS Predicate
ReadS [Predicate]
(Int -> ReadS Predicate)
-> ReadS [Predicate]
-> ReadPrec Predicate
-> ReadPrec [Predicate]
-> Read Predicate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Predicate]
$creadListPrec :: ReadPrec [Predicate]
readPrec :: ReadPrec Predicate
$creadPrec :: ReadPrec Predicate
readList :: ReadS [Predicate]
$creadList :: ReadS [Predicate]
readsPrec :: Int -> ReadS Predicate
$creadsPrec :: Int -> ReadS Predicate
Prelude.Read, Int -> Predicate -> ShowS
[Predicate] -> ShowS
Predicate -> String
(Int -> Predicate -> ShowS)
-> (Predicate -> String)
-> ([Predicate] -> ShowS)
-> Show Predicate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Predicate] -> ShowS
$cshowList :: [Predicate] -> ShowS
show :: Predicate -> String
$cshow :: Predicate -> String
showsPrec :: Int -> Predicate -> ShowS
$cshowsPrec :: Int -> Predicate -> ShowS
Prelude.Show, (forall x. Predicate -> Rep Predicate x)
-> (forall x. Rep Predicate x -> Predicate) -> Generic Predicate
forall x. Rep Predicate x -> Predicate
forall x. Predicate -> Rep Predicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Predicate x -> Predicate
$cfrom :: forall x. Predicate -> Rep Predicate x
Prelude.Generic)
newPredicate ::
Prelude.Bool ->
PredicateType ->
Prelude.Text ->
Predicate
newPredicate :: Bool -> PredicateType -> Text -> Predicate
newPredicate Bool
pNegated_ PredicateType
pType_ Text
pDataId_ =
Predicate' :: Bool -> PredicateType -> Text -> Predicate
Predicate'
{ $sel:negated:Predicate' :: Bool
negated = Bool
pNegated_,
$sel:type':Predicate' :: PredicateType
type' = PredicateType
pType_,
$sel:dataId:Predicate' :: Text
dataId = Text
pDataId_
}
predicate_negated :: Lens.Lens' Predicate Prelude.Bool
predicate_negated :: (Bool -> f Bool) -> Predicate -> f Predicate
predicate_negated = (Predicate -> Bool)
-> (Predicate -> Bool -> Predicate)
-> Lens Predicate Predicate Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Bool
negated :: Bool
$sel:negated:Predicate' :: Predicate -> Bool
negated} -> Bool
negated) (\s :: Predicate
s@Predicate' {} Bool
a -> Predicate
s {$sel:negated:Predicate' :: Bool
negated = Bool
a} :: Predicate)
predicate_type :: Lens.Lens' Predicate PredicateType
predicate_type :: (PredicateType -> f PredicateType) -> Predicate -> f Predicate
predicate_type = (Predicate -> PredicateType)
-> (Predicate -> PredicateType -> Predicate)
-> Lens Predicate Predicate PredicateType PredicateType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {PredicateType
type' :: PredicateType
$sel:type':Predicate' :: Predicate -> PredicateType
type'} -> PredicateType
type') (\s :: Predicate
s@Predicate' {} PredicateType
a -> Predicate
s {$sel:type':Predicate' :: PredicateType
type' = PredicateType
a} :: Predicate)
predicate_dataId :: Lens.Lens' Predicate Prelude.Text
predicate_dataId :: (Text -> f Text) -> Predicate -> f Predicate
predicate_dataId = (Predicate -> Text)
-> (Predicate -> Text -> Predicate)
-> Lens Predicate Predicate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Text
dataId :: Text
$sel:dataId:Predicate' :: Predicate -> Text
dataId} -> Text
dataId) (\s :: Predicate
s@Predicate' {} Text
a -> Predicate
s {$sel:dataId:Predicate' :: Text
dataId = Text
a} :: Predicate)
instance Core.FromJSON Predicate where
parseJSON :: Value -> Parser Predicate
parseJSON =
String -> (Object -> Parser Predicate) -> Value -> Parser Predicate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Predicate"
( \Object
x ->
Bool -> PredicateType -> Text -> Predicate
Predicate'
(Bool -> PredicateType -> Text -> Predicate)
-> Parser Bool -> Parser (PredicateType -> Text -> Predicate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Negated")
Parser (PredicateType -> Text -> Predicate)
-> Parser PredicateType -> Parser (Text -> Predicate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PredicateType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
Parser (Text -> Predicate) -> Parser Text -> Parser Predicate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DataId")
)
instance Prelude.Hashable Predicate
instance Prelude.NFData Predicate
instance Core.ToJSON Predicate where
toJSON :: Predicate -> Value
toJSON Predicate' {Bool
Text
PredicateType
dataId :: Text
type' :: PredicateType
negated :: Bool
$sel:dataId:Predicate' :: Predicate -> Text
$sel:type':Predicate' :: Predicate -> PredicateType
$sel:negated:Predicate' :: Predicate -> Bool
..} =
[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
"Negated" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
negated),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> PredicateType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PredicateType
type'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DataId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dataId)
]
)