{-# 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.IoTEvents.Types.SimpleRule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.ComparisonOperator
import qualified Amazonka.Prelude as Prelude
data SimpleRule = SimpleRule'
{
SimpleRule -> Text
inputProperty :: Prelude.Text,
SimpleRule -> ComparisonOperator
comparisonOperator :: ComparisonOperator,
SimpleRule -> Text
threshold :: Prelude.Text
}
deriving (SimpleRule -> SimpleRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleRule -> SimpleRule -> Bool
$c/= :: SimpleRule -> SimpleRule -> Bool
== :: SimpleRule -> SimpleRule -> Bool
$c== :: SimpleRule -> SimpleRule -> Bool
Prelude.Eq, ReadPrec [SimpleRule]
ReadPrec SimpleRule
Int -> ReadS SimpleRule
ReadS [SimpleRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleRule]
$creadListPrec :: ReadPrec [SimpleRule]
readPrec :: ReadPrec SimpleRule
$creadPrec :: ReadPrec SimpleRule
readList :: ReadS [SimpleRule]
$creadList :: ReadS [SimpleRule]
readsPrec :: Int -> ReadS SimpleRule
$creadsPrec :: Int -> ReadS SimpleRule
Prelude.Read, Int -> SimpleRule -> ShowS
[SimpleRule] -> ShowS
SimpleRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleRule] -> ShowS
$cshowList :: [SimpleRule] -> ShowS
show :: SimpleRule -> String
$cshow :: SimpleRule -> String
showsPrec :: Int -> SimpleRule -> ShowS
$cshowsPrec :: Int -> SimpleRule -> ShowS
Prelude.Show, forall x. Rep SimpleRule x -> SimpleRule
forall x. SimpleRule -> Rep SimpleRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimpleRule x -> SimpleRule
$cfrom :: forall x. SimpleRule -> Rep SimpleRule x
Prelude.Generic)
newSimpleRule ::
Prelude.Text ->
ComparisonOperator ->
Prelude.Text ->
SimpleRule
newSimpleRule :: Text -> ComparisonOperator -> Text -> SimpleRule
newSimpleRule
Text
pInputProperty_
ComparisonOperator
pComparisonOperator_
Text
pThreshold_ =
SimpleRule'
{ $sel:inputProperty:SimpleRule' :: Text
inputProperty = Text
pInputProperty_,
$sel:comparisonOperator:SimpleRule' :: ComparisonOperator
comparisonOperator = ComparisonOperator
pComparisonOperator_,
$sel:threshold:SimpleRule' :: Text
threshold = Text
pThreshold_
}
simpleRule_inputProperty :: Lens.Lens' SimpleRule Prelude.Text
simpleRule_inputProperty :: Lens' SimpleRule Text
simpleRule_inputProperty = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRule' {Text
inputProperty :: Text
$sel:inputProperty:SimpleRule' :: SimpleRule -> Text
inputProperty} -> Text
inputProperty) (\s :: SimpleRule
s@SimpleRule' {} Text
a -> SimpleRule
s {$sel:inputProperty:SimpleRule' :: Text
inputProperty = Text
a} :: SimpleRule)
simpleRule_comparisonOperator :: Lens.Lens' SimpleRule ComparisonOperator
simpleRule_comparisonOperator :: Lens' SimpleRule ComparisonOperator
simpleRule_comparisonOperator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRule' {ComparisonOperator
comparisonOperator :: ComparisonOperator
$sel:comparisonOperator:SimpleRule' :: SimpleRule -> ComparisonOperator
comparisonOperator} -> ComparisonOperator
comparisonOperator) (\s :: SimpleRule
s@SimpleRule' {} ComparisonOperator
a -> SimpleRule
s {$sel:comparisonOperator:SimpleRule' :: ComparisonOperator
comparisonOperator = ComparisonOperator
a} :: SimpleRule)
simpleRule_threshold :: Lens.Lens' SimpleRule Prelude.Text
simpleRule_threshold :: Lens' SimpleRule Text
simpleRule_threshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRule' {Text
threshold :: Text
$sel:threshold:SimpleRule' :: SimpleRule -> Text
threshold} -> Text
threshold) (\s :: SimpleRule
s@SimpleRule' {} Text
a -> SimpleRule
s {$sel:threshold:SimpleRule' :: Text
threshold = Text
a} :: SimpleRule)
instance Data.FromJSON SimpleRule where
parseJSON :: Value -> Parser SimpleRule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"SimpleRule"
( \Object
x ->
Text -> ComparisonOperator -> Text -> SimpleRule
SimpleRule'
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
"inputProperty")
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
"comparisonOperator")
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
"threshold")
)
instance Prelude.Hashable SimpleRule where
hashWithSalt :: Int -> SimpleRule -> Int
hashWithSalt Int
_salt SimpleRule' {Text
ComparisonOperator
threshold :: Text
comparisonOperator :: ComparisonOperator
inputProperty :: Text
$sel:threshold:SimpleRule' :: SimpleRule -> Text
$sel:comparisonOperator:SimpleRule' :: SimpleRule -> ComparisonOperator
$sel:inputProperty:SimpleRule' :: SimpleRule -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
inputProperty
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComparisonOperator
comparisonOperator
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
threshold
instance Prelude.NFData SimpleRule where
rnf :: SimpleRule -> ()
rnf SimpleRule' {Text
ComparisonOperator
threshold :: Text
comparisonOperator :: ComparisonOperator
inputProperty :: Text
$sel:threshold:SimpleRule' :: SimpleRule -> Text
$sel:comparisonOperator:SimpleRule' :: SimpleRule -> ComparisonOperator
$sel:inputProperty:SimpleRule' :: SimpleRule -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
inputProperty
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ComparisonOperator
comparisonOperator
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
threshold
instance Data.ToJSON SimpleRule where
toJSON :: SimpleRule -> Value
toJSON SimpleRule' {Text
ComparisonOperator
threshold :: Text
comparisonOperator :: ComparisonOperator
inputProperty :: Text
$sel:threshold:SimpleRule' :: SimpleRule -> Text
$sel:comparisonOperator:SimpleRule' :: SimpleRule -> ComparisonOperator
$sel:inputProperty:SimpleRule' :: SimpleRule -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"inputProperty" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
inputProperty),
forall a. a -> Maybe a
Prelude.Just
(Key
"comparisonOperator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComparisonOperator
comparisonOperator),
forall a. a -> Maybe a
Prelude.Just (Key
"threshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
threshold)
]
)