{-# 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.SetTimerAction where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data SetTimerAction = SetTimerAction'
{
SetTimerAction -> Maybe Text
durationExpression :: Prelude.Maybe Prelude.Text,
SetTimerAction -> Maybe Natural
seconds :: Prelude.Maybe Prelude.Natural,
SetTimerAction -> Text
timerName :: Prelude.Text
}
deriving (SetTimerAction -> SetTimerAction -> Bool
(SetTimerAction -> SetTimerAction -> Bool)
-> (SetTimerAction -> SetTimerAction -> Bool) -> Eq SetTimerAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetTimerAction -> SetTimerAction -> Bool
$c/= :: SetTimerAction -> SetTimerAction -> Bool
== :: SetTimerAction -> SetTimerAction -> Bool
$c== :: SetTimerAction -> SetTimerAction -> Bool
Prelude.Eq, ReadPrec [SetTimerAction]
ReadPrec SetTimerAction
Int -> ReadS SetTimerAction
ReadS [SetTimerAction]
(Int -> ReadS SetTimerAction)
-> ReadS [SetTimerAction]
-> ReadPrec SetTimerAction
-> ReadPrec [SetTimerAction]
-> Read SetTimerAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetTimerAction]
$creadListPrec :: ReadPrec [SetTimerAction]
readPrec :: ReadPrec SetTimerAction
$creadPrec :: ReadPrec SetTimerAction
readList :: ReadS [SetTimerAction]
$creadList :: ReadS [SetTimerAction]
readsPrec :: Int -> ReadS SetTimerAction
$creadsPrec :: Int -> ReadS SetTimerAction
Prelude.Read, Int -> SetTimerAction -> ShowS
[SetTimerAction] -> ShowS
SetTimerAction -> String
(Int -> SetTimerAction -> ShowS)
-> (SetTimerAction -> String)
-> ([SetTimerAction] -> ShowS)
-> Show SetTimerAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetTimerAction] -> ShowS
$cshowList :: [SetTimerAction] -> ShowS
show :: SetTimerAction -> String
$cshow :: SetTimerAction -> String
showsPrec :: Int -> SetTimerAction -> ShowS
$cshowsPrec :: Int -> SetTimerAction -> ShowS
Prelude.Show, (forall x. SetTimerAction -> Rep SetTimerAction x)
-> (forall x. Rep SetTimerAction x -> SetTimerAction)
-> Generic SetTimerAction
forall x. Rep SetTimerAction x -> SetTimerAction
forall x. SetTimerAction -> Rep SetTimerAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetTimerAction x -> SetTimerAction
$cfrom :: forall x. SetTimerAction -> Rep SetTimerAction x
Prelude.Generic)
newSetTimerAction ::
Prelude.Text ->
SetTimerAction
newSetTimerAction :: Text -> SetTimerAction
newSetTimerAction Text
pTimerName_ =
SetTimerAction' :: Maybe Text -> Maybe Natural -> Text -> SetTimerAction
SetTimerAction'
{ $sel:durationExpression:SetTimerAction' :: Maybe Text
durationExpression =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:seconds:SetTimerAction' :: Maybe Natural
seconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:timerName:SetTimerAction' :: Text
timerName = Text
pTimerName_
}
setTimerAction_durationExpression :: Lens.Lens' SetTimerAction (Prelude.Maybe Prelude.Text)
setTimerAction_durationExpression :: (Maybe Text -> f (Maybe Text))
-> SetTimerAction -> f SetTimerAction
setTimerAction_durationExpression = (SetTimerAction -> Maybe Text)
-> (SetTimerAction -> Maybe Text -> SetTimerAction)
-> Lens SetTimerAction SetTimerAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTimerAction' {Maybe Text
durationExpression :: Maybe Text
$sel:durationExpression:SetTimerAction' :: SetTimerAction -> Maybe Text
durationExpression} -> Maybe Text
durationExpression) (\s :: SetTimerAction
s@SetTimerAction' {} Maybe Text
a -> SetTimerAction
s {$sel:durationExpression:SetTimerAction' :: Maybe Text
durationExpression = Maybe Text
a} :: SetTimerAction)
setTimerAction_seconds :: Lens.Lens' SetTimerAction (Prelude.Maybe Prelude.Natural)
setTimerAction_seconds :: (Maybe Natural -> f (Maybe Natural))
-> SetTimerAction -> f SetTimerAction
setTimerAction_seconds = (SetTimerAction -> Maybe Natural)
-> (SetTimerAction -> Maybe Natural -> SetTimerAction)
-> Lens
SetTimerAction SetTimerAction (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTimerAction' {Maybe Natural
seconds :: Maybe Natural
$sel:seconds:SetTimerAction' :: SetTimerAction -> Maybe Natural
seconds} -> Maybe Natural
seconds) (\s :: SetTimerAction
s@SetTimerAction' {} Maybe Natural
a -> SetTimerAction
s {$sel:seconds:SetTimerAction' :: Maybe Natural
seconds = Maybe Natural
a} :: SetTimerAction)
setTimerAction_timerName :: Lens.Lens' SetTimerAction Prelude.Text
setTimerAction_timerName :: (Text -> f Text) -> SetTimerAction -> f SetTimerAction
setTimerAction_timerName = (SetTimerAction -> Text)
-> (SetTimerAction -> Text -> SetTimerAction)
-> Lens SetTimerAction SetTimerAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTimerAction' {Text
timerName :: Text
$sel:timerName:SetTimerAction' :: SetTimerAction -> Text
timerName} -> Text
timerName) (\s :: SetTimerAction
s@SetTimerAction' {} Text
a -> SetTimerAction
s {$sel:timerName:SetTimerAction' :: Text
timerName = Text
a} :: SetTimerAction)
instance Core.FromJSON SetTimerAction where
parseJSON :: Value -> Parser SetTimerAction
parseJSON =
String
-> (Object -> Parser SetTimerAction)
-> Value
-> Parser SetTimerAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SetTimerAction"
( \Object
x ->
Maybe Text -> Maybe Natural -> Text -> SetTimerAction
SetTimerAction'
(Maybe Text -> Maybe Natural -> Text -> SetTimerAction)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> Text -> SetTimerAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"durationExpression")
Parser (Maybe Natural -> Text -> SetTimerAction)
-> Parser (Maybe Natural) -> Parser (Text -> SetTimerAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"seconds")
Parser (Text -> SetTimerAction)
-> Parser Text -> Parser SetTimerAction
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
"timerName")
)
instance Prelude.Hashable SetTimerAction
instance Prelude.NFData SetTimerAction
instance Core.ToJSON SetTimerAction where
toJSON :: SetTimerAction -> Value
toJSON SetTimerAction' {Maybe Natural
Maybe Text
Text
timerName :: Text
seconds :: Maybe Natural
durationExpression :: Maybe Text
$sel:timerName:SetTimerAction' :: SetTimerAction -> Text
$sel:seconds:SetTimerAction' :: SetTimerAction -> Maybe Natural
$sel:durationExpression:SetTimerAction' :: SetTimerAction -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"durationExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
durationExpression,
(Text
"seconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
seconds,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"timerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
timerName)
]
)