{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.PayloadType
import qualified Amazonka.Prelude as Prelude
data Payload = Payload'
{
Payload -> Text
contentExpression :: Prelude.Text,
Payload -> PayloadType
type' :: PayloadType
}
deriving (Payload -> Payload -> Bool
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]
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
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. 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'
{ $sel:contentExpression:Payload' :: Text
contentExpression = Text
pContentExpression_,
$sel:type':Payload' :: PayloadType
type' = PayloadType
pType_
}
payload_contentExpression :: Lens.Lens' Payload Prelude.Text
payload_contentExpression :: Lens' Payload Text
payload_contentExpression = 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 :: Lens' Payload PayloadType
payload_type = 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 Data.FromJSON Payload where
parseJSON :: Value -> Parser Payload
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Payload"
( \Object
x ->
Text -> PayloadType -> Payload
Payload'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"contentExpression")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
)
instance Prelude.Hashable Payload where
hashWithSalt :: Int -> Payload -> Int
hashWithSalt Int
_salt Payload' {Text
PayloadType
type' :: PayloadType
contentExpression :: Text
$sel:type':Payload' :: Payload -> PayloadType
$sel:contentExpression:Payload' :: Payload -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contentExpression
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PayloadType
type'
instance Prelude.NFData Payload where
rnf :: Payload -> ()
rnf Payload' {Text
PayloadType
type' :: PayloadType
contentExpression :: Text
$sel:type':Payload' :: Payload -> PayloadType
$sel:contentExpression:Payload' :: Payload -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
contentExpression
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PayloadType
type'
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"contentExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contentExpression),
forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PayloadType
type')
]
)