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