{-# 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.IotTopicPublishAction 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 IotTopicPublishAction = IotTopicPublishAction'
{
IotTopicPublishAction -> Maybe Payload
payload :: Prelude.Maybe Payload,
IotTopicPublishAction -> Text
mqttTopic :: Prelude.Text
}
deriving (IotTopicPublishAction -> IotTopicPublishAction -> Bool
(IotTopicPublishAction -> IotTopicPublishAction -> Bool)
-> (IotTopicPublishAction -> IotTopicPublishAction -> Bool)
-> Eq IotTopicPublishAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IotTopicPublishAction -> IotTopicPublishAction -> Bool
$c/= :: IotTopicPublishAction -> IotTopicPublishAction -> Bool
== :: IotTopicPublishAction -> IotTopicPublishAction -> Bool
$c== :: IotTopicPublishAction -> IotTopicPublishAction -> Bool
Prelude.Eq, ReadPrec [IotTopicPublishAction]
ReadPrec IotTopicPublishAction
Int -> ReadS IotTopicPublishAction
ReadS [IotTopicPublishAction]
(Int -> ReadS IotTopicPublishAction)
-> ReadS [IotTopicPublishAction]
-> ReadPrec IotTopicPublishAction
-> ReadPrec [IotTopicPublishAction]
-> Read IotTopicPublishAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IotTopicPublishAction]
$creadListPrec :: ReadPrec [IotTopicPublishAction]
readPrec :: ReadPrec IotTopicPublishAction
$creadPrec :: ReadPrec IotTopicPublishAction
readList :: ReadS [IotTopicPublishAction]
$creadList :: ReadS [IotTopicPublishAction]
readsPrec :: Int -> ReadS IotTopicPublishAction
$creadsPrec :: Int -> ReadS IotTopicPublishAction
Prelude.Read, Int -> IotTopicPublishAction -> ShowS
[IotTopicPublishAction] -> ShowS
IotTopicPublishAction -> String
(Int -> IotTopicPublishAction -> ShowS)
-> (IotTopicPublishAction -> String)
-> ([IotTopicPublishAction] -> ShowS)
-> Show IotTopicPublishAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IotTopicPublishAction] -> ShowS
$cshowList :: [IotTopicPublishAction] -> ShowS
show :: IotTopicPublishAction -> String
$cshow :: IotTopicPublishAction -> String
showsPrec :: Int -> IotTopicPublishAction -> ShowS
$cshowsPrec :: Int -> IotTopicPublishAction -> ShowS
Prelude.Show, (forall x. IotTopicPublishAction -> Rep IotTopicPublishAction x)
-> (forall x. Rep IotTopicPublishAction x -> IotTopicPublishAction)
-> Generic IotTopicPublishAction
forall x. Rep IotTopicPublishAction x -> IotTopicPublishAction
forall x. IotTopicPublishAction -> Rep IotTopicPublishAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IotTopicPublishAction x -> IotTopicPublishAction
$cfrom :: forall x. IotTopicPublishAction -> Rep IotTopicPublishAction x
Prelude.Generic)
newIotTopicPublishAction ::
Prelude.Text ->
IotTopicPublishAction
newIotTopicPublishAction :: Text -> IotTopicPublishAction
newIotTopicPublishAction Text
pMqttTopic_ =
IotTopicPublishAction' :: Maybe Payload -> Text -> IotTopicPublishAction
IotTopicPublishAction'
{ $sel:payload:IotTopicPublishAction' :: Maybe Payload
payload = Maybe Payload
forall a. Maybe a
Prelude.Nothing,
$sel:mqttTopic:IotTopicPublishAction' :: Text
mqttTopic = Text
pMqttTopic_
}
iotTopicPublishAction_payload :: Lens.Lens' IotTopicPublishAction (Prelude.Maybe Payload)
iotTopicPublishAction_payload :: (Maybe Payload -> f (Maybe Payload))
-> IotTopicPublishAction -> f IotTopicPublishAction
iotTopicPublishAction_payload = (IotTopicPublishAction -> Maybe Payload)
-> (IotTopicPublishAction
-> Maybe Payload -> IotTopicPublishAction)
-> Lens
IotTopicPublishAction
IotTopicPublishAction
(Maybe Payload)
(Maybe Payload)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotTopicPublishAction' {Maybe Payload
payload :: Maybe Payload
$sel:payload:IotTopicPublishAction' :: IotTopicPublishAction -> Maybe Payload
payload} -> Maybe Payload
payload) (\s :: IotTopicPublishAction
s@IotTopicPublishAction' {} Maybe Payload
a -> IotTopicPublishAction
s {$sel:payload:IotTopicPublishAction' :: Maybe Payload
payload = Maybe Payload
a} :: IotTopicPublishAction)
iotTopicPublishAction_mqttTopic :: Lens.Lens' IotTopicPublishAction Prelude.Text
iotTopicPublishAction_mqttTopic :: (Text -> f Text)
-> IotTopicPublishAction -> f IotTopicPublishAction
iotTopicPublishAction_mqttTopic = (IotTopicPublishAction -> Text)
-> (IotTopicPublishAction -> Text -> IotTopicPublishAction)
-> Lens IotTopicPublishAction IotTopicPublishAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotTopicPublishAction' {Text
mqttTopic :: Text
$sel:mqttTopic:IotTopicPublishAction' :: IotTopicPublishAction -> Text
mqttTopic} -> Text
mqttTopic) (\s :: IotTopicPublishAction
s@IotTopicPublishAction' {} Text
a -> IotTopicPublishAction
s {$sel:mqttTopic:IotTopicPublishAction' :: Text
mqttTopic = Text
a} :: IotTopicPublishAction)
instance Core.FromJSON IotTopicPublishAction where
parseJSON :: Value -> Parser IotTopicPublishAction
parseJSON =
String
-> (Object -> Parser IotTopicPublishAction)
-> Value
-> Parser IotTopicPublishAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"IotTopicPublishAction"
( \Object
x ->
Maybe Payload -> Text -> IotTopicPublishAction
IotTopicPublishAction'
(Maybe Payload -> Text -> IotTopicPublishAction)
-> Parser (Maybe Payload) -> Parser (Text -> IotTopicPublishAction)
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 -> IotTopicPublishAction)
-> Parser Text -> Parser IotTopicPublishAction
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
"mqttTopic")
)
instance Prelude.Hashable IotTopicPublishAction
instance Prelude.NFData IotTopicPublishAction
instance Core.ToJSON IotTopicPublishAction where
toJSON :: IotTopicPublishAction -> Value
toJSON IotTopicPublishAction' {Maybe Payload
Text
mqttTopic :: Text
payload :: Maybe Payload
$sel:mqttTopic:IotTopicPublishAction' :: IotTopicPublishAction -> Text
$sel:payload:IotTopicPublishAction' :: IotTopicPublishAction -> 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
"mqttTopic" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
mqttTopic)
]
)