{-# 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 Amazonka.IoTEvents.Types.ComparisonOperator
import qualified Amazonka.Lens as Lens
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
(SimpleRule -> SimpleRule -> Bool)
-> (SimpleRule -> SimpleRule -> Bool) -> Eq SimpleRule
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]
(Int -> ReadS SimpleRule)
-> ReadS [SimpleRule]
-> ReadPrec SimpleRule
-> ReadPrec [SimpleRule]
-> Read 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
(Int -> SimpleRule -> ShowS)
-> (SimpleRule -> String)
-> ([SimpleRule] -> ShowS)
-> Show SimpleRule
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. SimpleRule -> Rep SimpleRule x)
-> (forall x. Rep SimpleRule x -> SimpleRule) -> Generic SimpleRule
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' :: Text -> ComparisonOperator -> Text -> SimpleRule
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 :: (Text -> f Text) -> SimpleRule -> f SimpleRule
simpleRule_inputProperty = (SimpleRule -> Text)
-> (SimpleRule -> Text -> SimpleRule)
-> Lens SimpleRule SimpleRule Text Text
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 :: (ComparisonOperator -> f ComparisonOperator)
-> SimpleRule -> f SimpleRule
simpleRule_comparisonOperator = (SimpleRule -> ComparisonOperator)
-> (SimpleRule -> ComparisonOperator -> SimpleRule)
-> Lens SimpleRule SimpleRule ComparisonOperator 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 :: (Text -> f Text) -> SimpleRule -> f SimpleRule
simpleRule_threshold = (SimpleRule -> Text)
-> (SimpleRule -> Text -> SimpleRule)
-> Lens SimpleRule SimpleRule Text Text
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 Core.FromJSON SimpleRule where
parseJSON :: Value -> Parser SimpleRule
parseJSON =
String
-> (Object -> Parser SimpleRule) -> Value -> Parser SimpleRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SimpleRule"
( \Object
x ->
Text -> ComparisonOperator -> Text -> SimpleRule
SimpleRule'
(Text -> ComparisonOperator -> Text -> SimpleRule)
-> Parser Text -> Parser (ComparisonOperator -> Text -> SimpleRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"inputProperty")
Parser (ComparisonOperator -> Text -> SimpleRule)
-> Parser ComparisonOperator -> Parser (Text -> SimpleRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ComparisonOperator
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"comparisonOperator")
Parser (Text -> SimpleRule) -> Parser Text -> Parser SimpleRule
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
"threshold")
)
instance Prelude.Hashable SimpleRule
instance Prelude.NFData SimpleRule
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"inputProperty" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputProperty),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"comparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComparisonOperator
comparisonOperator),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"threshold" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
threshold)
]
)