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