{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $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 :: Lens' Predicate Bool
predicate_negated = 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 :: Lens' Predicate PredicateType
predicate_type = 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 :: Lens' Predicate Text
predicate_dataId = 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 Data.FromJSON Predicate where
parseJSON :: Value -> Parser Predicate
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Predicate"
( \Object
x ->
Bool -> PredicateType -> Text -> Predicate
Predicate'
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
"Negated")
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
"Type")
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
"DataId")
)
instance Prelude.Hashable Predicate where
hashWithSalt :: Int -> Predicate -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
negated
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PredicateType
type'
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataId
instance Prelude.NFData Predicate where
rnf :: Predicate -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Bool
negated
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PredicateType
type'
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dataId
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"Negated" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
negated),
forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PredicateType
type'),
forall a. a -> Maybe a
Prelude.Just (Key
"DataId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
dataId)
]
)