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